40NBT SDK: Can I send data over SPP via BT SDK?

Q: Do you have any C / C++ examples of how to set up an SPP service and exchange data across it using the Laird BT SDK? For example a simple "Chat" example? What I want to do is set up an SPP connection between the Laird module (running on our system acting as a server) and an Android tablet / phone acting as a client. I want to be able to send / receive data over this SPP link.

A: The Bluetooth SDK does not handle the SPP data directly. The SPP data is piped through a Virtual Serial Port that is installed on the system when the stack starts. Also, by default the stack has an SPP Service running when it starts. Typically when the SPP Service is installed it is running on COM Port #7 (this is the default number that the SPP service uses). You will have to.

  1. Have the tablet discover and pair with your Laird module (on your system acting as a server).
  2. The tablet should do a search for services and will find the Laird module has an SPP service available.
  3. The tablet will then connect on your service. From there, you will have to open a COM port using Microsofts API call of CreateFile(). Something similar to the effect of CreateFile("COM7:", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); Here is an example for opening the COM port. You must make sure that your tablet supports SPP as well. If SPP isn't supported then your tablet will not be able to discover your Laird Modules' SPP service.

Products