mobile - Bluetooth dial with 32feet.net and c# -
i trying provide "click dial" solution bluetooth device such mobile phone. have been trying using 32feet.net bluetooth api.
i haven't done bluetooth (since days of @ commands via bluetooth serial port) have paired device in question, supports handsfree service pc. have following code attempt connect , send dial command.
string deviceaddr = "11:11:11:11:11:11"; bluetoothaddress addr = bluetoothaddress.parse(deviceaddr); bluetoothendpoint rep = new bluetoothendpoint(addr, bluetoothservice.handsfree); bluetoothclient cli = new bluetoothclient(); cli.connect(rep); stream peerstream = cli.getstream(); string dialcmd = "atd 0000000000\r\n"; byte[] dcb = system.text.encoding.ascii.getbytes(dialcmd); peerstream.write(dcb, 0, dcb.length); // begin edit ------------------------------------------------------------ byte[] sresponse = new byte[100]; peerstream.read(sresponse, 0, 99); textbox1.text = system.text.encoding.ascii.getstring(sresponse); // end edit -------------------------------------------------------------- peerstream.close(); cli.close(); messagebox.show("done");
since seems run through these lines of code, taking appropriate time connect @ relevant spot or crashing out if device address wrong , can't connect. @ command not right thing sending it.
can enlighten me might need send bluetooth device via handsfree profile dial?
begin edit -------------------------------------------
i decided read stream , see if there response of sort after sending @ command through. since testing see if can make work dumping response textbox.
the response read stream :
error
there doesn't seem error codes or anything.
end edit ---------------------------------------------
edit --------------------------------------------------
sent command : at+cmer\r
result : ok
then
sent command : at+cind=?\r
result : +cind: ("service",(0-1)),("call",(0-1)),("callsetup",(0-3)),("battchg",(0-5)),("signal",(0-5)),("roam",(0-1)),("callheld",(0-2))
then
send command : atd 0000000000\r
result: ok d: ("service",(0-1)),("call",(0-1)),("callsetup",(0-3)),("battchg",(0-5)),("signal",(0-5)),("roam",(0-1)),("callheld",(0-2))
still doesn't dial :(
end edit ----------------------------------------------
solution ----------------------------------------------
the following code works dial via iphone. it's rough @ moment, have been testing see if make work. it's enough started else wanting similar thing.
string deviceaddr = "00:00:00:00:00:00"; bluetoothaddress addr = bluetoothaddress.parse(deviceaddr); bluetoothendpoint rep = new bluetoothendpoint(addr, bluetoothservice.handsfree); bluetoothclient cli = new bluetoothclient(); cli.connect(rep); stream peerstream = cli.getstream(); string dialcmd1 = "at+cmer\r"; string dialcmd2 = "at+cind=?\r"; string dialcmd3 = "at+brsf=\r"; string dialcmd4 = "atd 0000000000;\r"; byte[] dcb = system.text.encoding.ascii.getbytes(dialcmd1); peerstream.write(dcb, 0, dcb.length); byte[] sres = new byte[200]; peerstream.read(sres, 0, 199); textbox1.text = textbox1.text + "\n\r----------\n\r" + system.text.encoding.ascii.getstring(sres); dcb = system.text.encoding.ascii.getbytes(dialcmd2); peerstream.write(dcb, 0, dcb.length); peerstream.read(sres, 0, 199); textbox1.text = textbox1.text + "\n\r----------\n\r" + system.text.encoding.ascii.getstring(sres); dcb = system.text.encoding.ascii.getbytes(dialcmd3); peerstream.write(dcb, 0, dcb.length); peerstream.read(sres, 0, 199); textbox1.text = textbox1.text + "\n\r----------\n\r" + system.text.encoding.ascii.getstring(sres); dcb = system.text.encoding.ascii.getbytes(dialcmd4); peerstream.write(dcb, 0, dcb.length); peerstream.read(sres, 0, 199); textbox1.text = textbox1.text + "\n\r----------\n\r" + system.text.encoding.ascii.getstring(sres); peerstream.close(); cli.close();
try find response at\r (or) ath\r. if response "ok\r\n", try dial command no space after atd , number.
Comments
Post a Comment