Author Topic: SPP Connection Detection  (Read 41348 times)

servel333

  • Guest
SPP Connection Detection
« on: May 12, 2008, 04:54:19 PM »
We have a device that connects to a computer via SPP.  The device connects to the computer, sometimes on a schedule and sometimes by user interaction.

Ideally, we would like to have the device connect, the software detect the connection attempt, create and/or open a COM port and route the devices connection to that COM port.  It would also work if the software could identify the COM port the device is about to connect to and open that COM port at that time.  Both of these situations would require the software to be able to detect connection attempts by a device, and before the connection attempt is completed, respond to that event.

From what my coworker and I understand, in order for a device to successfully connect to a computer using SPP, the corresponding COM port must already be open or the connection attempt will fail.  This means our application would have to sit, listening with the COM port open all the time.  In this situation, we run into the following problems:
  • If our application keeps the COM port open all the time and some other software needs to do the same thing, the one of the applications will be blocked form working correctly, depending on who opens the first com port first.
  • We need a way to detect all the Bluetooth COM ports and identify the first COM port.

More Info:
  • We are working in Visual Basic 2005. Examples in C# are fine.
  • The questions here assume the device has already been paired with the computer.
  • We need to support the 4 major Bluetooth stacks with all functionality.


Thank you for your time.

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3675
  • Karma: 1000
    • Wireless Communication Libraries
Re: SPP Connection Detection
« Reply #1 on: May 12, 2008, 05:37:42 PM »
To work with bluetooth COM ports are not required. The library will not have any COM virtual COM ports support for future version except BFCOMPortCreate in BTF 5.2.2. If you need to use it with COM ports you should use third party solution to create virtual COM ports. Let say com2com (or com2hum).

servel333

  • Guest
Re: SPP Connection Detection
« Reply #2 on: May 12, 2008, 06:17:49 PM »
Thank you for your response.  They are always very quick.

To be more specific, the questions I am looking for answers for are:
  • Is there a way to create virtual COM ports? (Yes in BTF 5.2.2, No in WCL?)
  • Is there a way to get a list of all COM ports that were created by the Bluetooth stack?
  • Is there a way to detect when a device is making a connection attempt?
  • Is there a way to detect what COM port a device has connected to using SPP?
  • Is there a way to force a connecting device to connect to a specific COM port?
  • Is it true that the COM port must already be open in order for a device to successfully connect using SPP?
  • Would you please provide a link to com2com or a description of what it is.

I did some searching and only found the following related to com2com.

http://com0com.sourceforge.net/ -  Null-modem emulator (com0com)
This project appears to create COM port pairs for connecting one application with another on the same computer.  Not really what we want to do, but open source so it might be useful to take a look at.


I know I have a lot of very specific and detailed questions.  I don't have a very strong understanding of the way Bluetooth and the Bluetooth stacks work and I'm still trying to figure the details out.  Any help you can provide, as well as any additional details would be appreciated.

Thank you for your time.

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3675
  • Karma: 1000
    • Wireless Communication Libraries
Re: SPP Connection Detection
« Reply #3 on: May 12, 2008, 08:34:38 PM »
1. Yes. There is a way to do so but with some limitations
2. Yes. But it hard depends on the low-level drivers.
3. Of course.
4. Yes and no. Depends on stack.
5. Once again (it seems to be 100000000 times). BLUETOOTH DOES NOT NEED COM PORT FOR WORK!

If you need exactly COM ports and nothing more we can discuss custom solution.

servel333

  • Guest
Re: SPP Connection Detection
« Reply #4 on: May 12, 2008, 10:26:43 PM »
Thank you for your response.

I'm not sure what you mean by, "To work with bluetooth COM ports are not required."  Will you please clarify and expand on this statement. 

Keep in mind our device uses Serial Port Profile to connect and has no further Bluetooth profile support.  The Serial Port Profile is the only way for this device to connect and communicate.  If Bluetooth does not need COM ports to work, how do you communicate with a device using the Serial Port Profile?  Is there some other way to send the messages back and forth that I am not aware of?

Again, it is my understanding that when a Bluetooth device attempts to connect using the Serial Port Profile (After it has been successfully paired) it will connect to the first available Virtual COM port that was created by the installed Bluetooth Stack.

Also, you mentioned com2com before.  I still have no idea what this is.

Thank you for your time.

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3675
  • Karma: 1000
    • Wireless Communication Libraries
Re: SPP Connection Detection
« Reply #5 on: May 12, 2008, 11:10:11 PM »
Did you ever use IrDA modems? It works fine without any com ports (virtual or real). The same with Bluetooth. SPP is just abstraction. The serial device emulation over radio bluetooth interface. It does not matter how it appears on the PC side. It can be SerialPort (virtual) or WinSock (for Win drivers) or something else for other drivers. Even you can communicate with this device directly without any abstraction like SPP just using L2CAP or HCI level. You are simple mixing up different things. Forgot about COM ports when using Bluetooth.

Sure, some drivers allow to create virtual com ports for easy use connection from third party app. But WCL (and BTF) uses native generic drivers functions. And it does not need any COM ports (virtual or real) for work.

The BT device will NEVER contact with COM ports. It does not know about COM ports, LPT ports or any other ports. It only know the radio frequency and PSM number for L2CAP level. Also it may (or may not) knw the service UUID and the RFCOMM channel (if it uses RFCOMM) or something else for other protocol.

P.S. I mixed up the name com2com with com0com you have already found.

servel333

  • Guest
Re: SPP Connection Detection
« Reply #6 on: May 12, 2008, 11:29:38 PM »
Thank you for your response.

I think I understand what your saying now.  From what you are saying, I don't specifically need a COM port, I just need to use one of the many interfaces that talks SPP.  I'll do some more research and playing around and see what I can figure out.

Thank you very much.

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3675
  • Karma: 1000
    • Wireless Communication Libraries
Re: SPP Connection Detection
« Reply #7 on: May 12, 2008, 11:37:38 PM »
to use any service on the device you can simple use wclClient component (for custom protocols) or any other component for predefined (standard) protocols.

nbakarania

  • Guest
Re: SPP Connection Detection
« Reply #8 on: September 04, 2008, 06:48:04 PM »
I work with sevel333 and have taken over this task.

I still have some questions.  I would appreciate any help you can provide on this matter.

What I need to accomplish.
The PC will be in slave mode constantly monitoring for already paired devices to connect to it.  Once a device connects, the PC/device will communicate using a ASCII protocol over the SPP profile.

Current Implementation
 1) We create a Incoming Bluetooth virtual COM port.
 2) Open virtual COM Port
 3) Wait until a device connects.  (done by monitoring the "DSR" signal of the COM Port and waiting till it goes HIGH)
 4) Send data over the virtual com port to talk with the device.

Note:
 * The device is the Master.  The device's Bluetooth is normally off.   It powers on it's Bluetooth and initiates master mode connection to the PC.  If the PC does not respond via the ASCII protocol within a few seconds of the device connecting, the  device times out, disconnects, and powers off the Bluetooth..

Problems
Our current setup works fine.  However, there are a number of downfalls that I would like to address by eliminating the dependency of the virtual com port.

Your library has the ability to talk directly with the stack.  I would like to use this ability to bypass the need to utilize a virtual com port.  However, I'm at a loss on how to accomplish this with your library.  I would appreciate any help you may be able to provide.

I tried the wclnet.wclClient class unsuccessfully.  I set this client up as follows

' Set up radio
Dim _discovery As new wclnet.wclBluetoothDiscovery
Dim _radio As wclnet.wclBluetoothRadio = _discovery.EnumRadios(0)      'Yes I know I should have error checking.
Dim _client As new wclnet.wclClient


' I am not sure if I have to set up the serial baudrate but I did regardless because I know the baud set by the device is 115200
_client.SerialParams.BaudRate = wclnet.wclBaudRate.br115200


_client.ClientTransport = wclnet.wclClientTransport.ctBluetooth
_client.BluetoothParams.Radio = _radio
_client.BluetoothParams.Channel = 1
_client.BluetoothParams.Service = new Guid("00001101-0000-1000-8000-00805F9B34FB")

_client.Open()

After this I'm stuck.  I'm not sure how to detect when the device connects so that I can send it something.
I know I'm doing something wrong because, the device never makes a successful connection. The behavior observed is the same as if the virtual COM Port is closed.

Am I completely off target here?  Any help would be appreciated.




Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3675
  • Karma: 1000
    • Wireless Communication Libraries
Re: SPP Connection Detection
« Reply #9 on: September 04, 2008, 07:06:04 PM »
As the device is client the PC must be a server. WCL has no server part implemented yet. For server you may use BTF (it has server part).

nbakarania

  • Guest
Re: SPP Connection Detection
« Reply #10 on: September 04, 2008, 08:13:31 PM »
Thank you for the response.

Are there plans for adding this feature to WCL?  The reason I ask is since I have already purchased WCL Lite and not the BTF.

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3675
  • Karma: 1000
    • Wireless Communication Libraries
Re: SPP Connection Detection
« Reply #11 on: September 04, 2008, 08:52:18 PM »
Of course, that features are in plan: http://www.btframework.com/compare.htm

Unfortunatelly Lite version could be updated for free. If you have Personal or high version I could give you BTF because it is the same library (WCL is new version of BTF).

nan805

  • Guest
Re: SPP Connection Detection
« Reply #12 on: October 12, 2008, 05:17:14 PM »
Hi

Good day
I saw that you mentioned a tools "com0com", and I like to know is it possible to be programmed and called  in my C++ builder to create a virtual com port?

My application is now using the personal version of WCL, and My tools built by WCL need to transmit data at the same time to other application.


Here is a simple procedure frame
My tools built by WCL is named "Tools A", and user tools they did is named "Tools B"
========================

Tools A <----------------------- receive SPP service data from <-------------- bluetooth SPP device

Tools A -------------> transmit SPP data to ------------> Tools B

User tools only support to receive data from the handle of serial port.
So my idea is going to send data on the serial port which user specified.

Do you have any idea or tell me what to do for this case!

Thank you so much
Nan







Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3675
  • Karma: 1000
    • Wireless Communication Libraries
Re: SPP Connection Detection
« Reply #13 on: October 12, 2008, 09:17:54 PM »
wclClient with trSerial transport does not help?

nan805

  • Guest
Re: SPP Connection Detection
« Reply #14 on: October 13, 2008, 04:36:44 AM »
Good day
Thanks for your reply.

Yes,  The function of trSerial transport will definitely help the application
However, Tools B needs to know which serial port i created by "com0com" tools before i send data to it.

Thanks
Nan


 

Sitemap 1 2 3 4 5 6 7