Cellular Phone Forum / General / Bluetooth / September 2007
programming/comunicating with bluetooth wirless rs232 device
|
|
Thread rating:  |
colin - 17 Sep 2007 21:26 GMT Hi, I have a LMT058 bluetooth wireless rs232 device wich is to allow a small microcontroller to talk to the PC over a short distance, with a bluetooth dongle connected to the PC with WIDCOMM software 5.1.0 and winxp sp2. the rs232 device is set up as a slave, as devb on com15.
I can set it up to work, however it occasionally stops working after a while, sometimes closing and re opening the com port in software starts it working again, however sometimes I need to switch off either the bluetooth rs232 device or unplug the dongle on the PC, or sometimes both.
sometimes the rs232 device still thinks its connected and the software takes ages to reopen the com port, when it does open it theres no comunication.
unplugging the dongle or the rs232 device clears the conection and allows it to work again (usually).
while it is hung up the widdcom software is unable to open the connection by clicking on the devb icon.
how can I clear the connection so it starts to work again ? the system is left 24hrs a day and I cant be there to do it manually.
its realy annoying becuase I need many complete days of data and I find its not been gathering data for a few hours and days of collecting data have been wasted :(
im programing with c# and just opening the com15 port as if it was a normal rs232 port.
any help would be realy appreciated thanks, Colin =^.^=
John Henderson - 17 Sep 2007 22:22 GMT > Hi, > I have a LMT058 bluetooth wireless rs232 device [quoted text clipped - 32 lines] > any help would be realy appreciated thanks, > Colin =^.^= Instead of your program addressing the LMT058's serial port directly on com15, can you interact with the dongle itself with "AT" commands? If you can, you've obviously got far more control over connection status.
I took a different hardware approach. I use two Bluetooth RS232 adaptors (a TDK blu2i and a Parani SD100), and talk directly to the unit plugged into the PC's serial port. It controls the session to the remote unit, and once a session is made I'm then communicating with the remote unit's serial port until I drop back to local command mode with the standard modem "+++" escape sequence (or detect that the connection has been lost).
Both these units seem to have a much more powerful "AT" command set than the LMT058, but I'd recommend the Parani as being the more bullet-proof of the two (you can set the baud rate with DIP switches instead of only via software, for example).
I like talking to serial ports directly - it distances me from drivers with bugs :)
John
colin - 17 Sep 2007 22:45 GMT >> Hi, >> I have a LMT058 bluetooth wireless rs232 device [quoted text clipped - 53 lines] > I like talking to serial ports directly - it distances me from > drivers with bugs :) thanks, it seems absurd but the device I have cant be made to drop out with the +++ command. I can detect 'connect' and 'disconnect' on the remote device but this isnt entirly helpfull, as it is in connected mode when it isnt working.
I was hoping not to have to use the pc serial port as im using it for something else, and seems they might be becoming obselete on pcs. also buad rate is rather limited, I can just get away with ~100kb
il look up those devices you mentioned, I could get another unit like the one I have to use rs232 to rs232 as they are suposed to work as pairs, but if its this device thats cuasing problems il be no better off, maybe il get one of the devices you seem to be having succes with.
one other thing I havnt tried is to put the remote unit in master mode.
I gues I could control the power to the remote unit from the micro but this as something id rather not have to.
idealy I would like to be able to just break the connection from the PC by sending a command to the bluetooth driver, is this possible ?
Colin =^.^=
colin - 20 Sep 2007 22:02 GMT >> Hi, >> I have a LMT058 bluetooth wireless rs232 device [quoted text clipped - 53 lines] > I like talking to serial ports directly - it distances me from > drivers with bugs :) Ive made some improvment, I noticed the rts line was always inactive when the problem arises, for handshaking I rely on the PC acknowledging the messages, I hadnt planed on using rts there isnt realy any room for going slow, I managed a very crude flow control by putting an led from the rts line to the rxinput wich has a resistance of 220r
seems to no longer stay in the state with the rts line inactive.
Colin =^.^=
John Henderson - 21 Sep 2007 01:36 GMT > Ive made some improvment, > I noticed the rts line was always inactive when the problem [quoted text clipped - 3 lines] > putting an led from the rts line to the rxinput wich has a > resistance of 220r I notice that the default for the LMT058 is to use CTS/RTS hardware flow control. You can disable it with the "ATC0" (that's the number zero) command issued over its serial port according to http://www.datasoft.se/documents/LMT058Usersmanualver2.1_000.pdf
But you're likely to suffer data corruption (loss) without flow control is the line speed is fast and more characters are transmitted than will fit into the receiver's buffer. The slower you can run the line speed the less likely it is that characters will be lost with flow control turned off.
Wiring RTS high to the LMT058 would have the same effect as using "ATC0".
If you're going this way, I'd recommend disabling flow control on your com15 too.
> seems to no longer stay in the state with the rts line > inactive. I'm not sure what you're saying here.
John
colin - 21 Sep 2007 13:12 GMT >> Ive made some improvment, >> I noticed the rts line was always inactive when the problem [quoted text clipped - 18 lines] > Wiring RTS high to the LMT058 would have the same effect as > using "ATC0". yeah thanks, but it didnt seem to have that command in the manual im lookin at, (v2.00) so I just wired cts high and ignored rts.
> If you're going this way, I'd recommend disabling flow control > on your com15 too. im not sure what the pc end does with flow hw control as its via the bluetooth dongle, I cld play around with this if it still gives trouble, but for now it seems to have solved this last problem.
I think I just have it set so the hw flow control output lines are asserted but the flow control inputs lines are ignored.
>> seems to no longer stay in the state with the rts line >> inactive. > > I'm not sure what you're saying here. well, when it went wrong the rts line was de asserted, and reading all the characters available at the pc didnt clear the condition and didnt re assert rts, anything I did at the pc end didnt clear it, and it just stayed connected.
hmm maybe the confusion is im never clear wich direction rts/cts are going in, despite wiring up rs232 conections 100s of times, we seem to be using oposite directions, but going by the manual rts is an output from the modem, I usualy just go by wether the manual says is input or output.
I think it messed it up when it got many more characters when rts was inactive. idealy it should just ignore any more chars, and recover gracefully, but this doesnt seem to be the case.
the messages are short packets of 25chars avg csv (comma seperated variables).
the remote device isnt realy capable of buffering much so the data logging eqpmnt just simply has to keep up. it does usually, seems to be when I stop the data loging aplication to debug it or some other windows thing suddenly decides to hog the cpu that it hangs up.
I did have the appp as high priority but under some conditions it could hang the pc, particularly sometimes when it trties to open the com15 port and it doesnt open straight away. or maybe its garbage collection in my c# app hmmm ...
the odd missed data packet isnt too much trouble, but when it hangs up for hours it is.
I had to add crc error detection becuase the microcontroller uart dma has an intermitent problem where it repeats chars. but otherwise the system has virtualy no errors
the system is rotating so needs wirless transmision, but is right next to the pc, although I wish id used a diferent method, maybe more slip rings wich I use 2 for power already, or irda.
what would be realy neat is if I could have a wirless usb conection, then the usb microcontroller programer could remain on the moving platform. there are wirless routers wich have usb ports, but these only claim to support a limited set of printers etc.
anyway thanks again for you help and interest, seems i might of solved it, although ive had it apart for the last few days, there are parts spinning at 10krpm and its taking a lot of fiddling with to get it running smothly enough.
Colin =^.^=
http://members.lycos.co.uk/dariusjack/ - 27 Sep 2007 05:35 GMT > > Ive made some improvment, > > I noticed the rts line was always inactive when the problem [quoted text clipped - 27 lines] > > John Hi John, Hi Colin,
thanks for your very interesting discussion. My problem with bluetooth gps units is the following. I use Nokia 770 to connect to a remote bluetooth ghps device to read nmea sentences by a navigation application. One option toi select provided by software is scanning for bluetooth enabled devices. So I select scan and get a list of bluetooth devices and their respective mac addreses, than I select one and connect to my gps unit. Unfortunately, sometimes fix or signal is lost and a software reconnects.
So sometims I test few gps units and would like my application to perform scanning, self-selection and re-select another gps unit given its fix is on . So to have a number of gps units on and have an application to switch into discovering mode and select another unit if signal from the first is lost or no fix is available.
As I see, bluetooth enabled device like gps can be considered a serial modem and AT commands are valid. There is a number of application , open-source under Linux to work with BT gps devices. But I still can't understand how they work in discovering mode, discovering every BT gps unit in proximity, reading its mac address. How scanning is done ? Thanks for your kind explanations.
Darius
John Henderson - 27 Sep 2007 07:24 GMT > thanks for your very interesting discussion. > My problem with bluetooth gps units is the following. [quoted text clipped - 22 lines] > mac address. How scanning is done ? > Thanks for your kind explanations. I don't have any experience so far with connecting to GPS units and issuing NMEA sentences. But I do have experience with connecting to Bluetooth-enabled mobile phones.
Below is the log of a session with the Parani SD100, using minicom (the Linux version of Hyperterminal). I have added some comments. They are the lines beginning with "*".
I assume that a connection to a GPS unit would be very similiar, except that NMEA sentences would be issued instead of cellular-specific "AT" commands.
* start
ATZ
OK
* issue the command to scan for visible devices
AT+BTINQ?
0001E36B52C0,John S55,720204
0016209D8A7C,John V600i,520204
OK
* 2 mobile phones found on this scan - connect to the Siemens * S55
ATD0001E36B52C0
OK
CONNECT 0001E36B52C0
* from here, we're talking to the S55 * * issue the phone some commands to tell us the cell ID and * Location Area Code whenever the phone changes serving cell, * and also the name (in PDU-mode encoding) of that cell
AT+CREG=2 OK AT+CNMI=1,0,2,0,1;+CSCB=0,50,"0-15" OK
+CBM: 88 1B20003201114679785E96371A8D46A3D168341A8D46A3D168341A8D46A3D168341A8D46A3D16834 1A8D46A3D168341A8D46A3D168341A8D46A3D168341A8D46A3D168341A8D46A3D168341A8D46A3D1 68341A8D46A3D100
* what phone network are we connected to?
AT+COPS? +COPS: 2,0,"Telstra"
OK AT+CREG? +CREG: 2,1,"1030","639E"
OK
+CREG: 1,"1030","1401"
+CBM: 88 07B000320111C8F4F99C76CF418D46A3D168341A8D46A3D168341A8D46A3D168341A8D46A3D16834 1A8D46A3D168341A8D46A3D168341A8D46A3D168341A8D46A3D168341A8D46A3D168341A8D46A3D1 68341A8D46A3D100
+CREG: 1,"1030","639E"
+CBM: 88 1B20003201114679785E96371A8D46A3D168341A8D46A3D168341A8D46A3D168341A8D46A3D16834 1A8D46A3D168341A8D46A3D168341A8D46A3D168341A8D46A3D168341A8D46A3D168341A8D46A3D1 68341A8D46A3D100 AT+CSQ +CSQ: 18,99
OK
+CREG: 1,"1030","1401"
+CBM: 88 07B000320111C8F4F99C76CF418D46A3D168341A8D46A3D168341A8D46A3D168341A8D46A3D16834 1A8D46A3D168341A8D46A3D168341A8D46A3D168341A8D46A3D168341A8D46A3D168341A8D46A3D1 68341A8D46A3D100
OK
* give the escape sequence to the Parani to drop back into * command mode
+++
* now disconnect from the phone
ATH
OK
DISCONNECT
* end
Please note that the Parani and the S55 were previously paired.
John
http://members.lycos.co.uk/dariusjack/ - 30 Sep 2007 20:29 GMT > http://members.lycos.co.uk/dariusjack/wrote: > > thanks for your very interesting discussion. [quoted text clipped - 133 lines] > > John Thanks John. Sorry for not responding earlier but for the last 3 days I was trying to install, deinstall, reinstall my IVT BlueSoleil driver to my Bluetooth usb dongle. Driver installed a lot of virtual COM ports and a number of services but non is modem. Opening hyperterminal, selecting COM port and trying to type anything crashes systems and blue screen is all I can see. So no chance to enter any AT command yet.
What I read from the net is: " What Bluetooth software are you using on your computers? Widcomm or Windows XP SP2?
Check what kind of network is supported by TECOM, either LAP or PAN. If they are using LAP and you are using the Windows XP SP2 Bluetooth software then it may not work with your computers since this software supports only PAN. " My drivr is IVT BlueSoleil not Widcomm. And frankly speaking I have no idea if my Bluetooth usb dongle is LAP or PAN. Anyway IVT driver installed no LAP or PAN device on LPT or COM port to use. So mayby I have to give up. But I can still tranfer files between my Nokia 770 and PC. So any form of modem should work. As Nokia 770 is Debian OS based device I will try to install minicom terminal application ported to that device and start the above procedure using Nokia 770.
Darius
John Henderson - 30 Sep 2007 21:47 GMT Hi Darius,
> So no chance to enter any AT command yet. I should have mentioned that the scanning command I used:
AT+BTINQ?
is specific to my Parani adaptor. As far as I know, there is no standardisation for Bluetooth "AT" commands (unlike the industry-standard cellular extensions, which begin with "AT+C").
I also have a TDK blu2i Bluetooth RS232 adaptor. It has a much more powerful "AT" command set than the Parani, and uses the command:
AT+BTI
to scan for other visible devices.
So you'd need to consult documentation for your specific device if you want to scan for nearby units.
John
http://members.lycos.co.uk/dariusjack/ - 01 Oct 2007 00:08 GMT > Hi Darius, > [quoted text clipped - 22 lines] > > John Thanks again. I have deinstalled all and installed back my bluetooth DUN and LAP modems to com4 and com5 respectively. Pinging modems with AT command from diagnostic menu I get no reply.
>From diagnostics: Modem type: Bluetooth DUN Modem DSR state low, CTS state low, CD state high on initialization.
Diagnostics says devices work ok. Bluetooth LAP modem diagnostics or works ok diagnostics log file didn't open a device on error 00000020 So it looks I have DUN Modem.
Downloaded 119 page long pdf manual from IVT BlueSoleil.
DUN stays for Bluetooth Dial-up Networking (DUN) PAN stays for Personal Area Networking
I am just reading manual and it looks very complicated. Just installed Bluetooth Fax Modem but still can't ping it. Windows says it works ok.
Something must be wrong.
Darius
|
|
|