If you wondered how to connect to a BT serial device using SPP over sockets... heres how!
// create your BT socket
SOCKET s = socket (AF_BTH, SOCK_STREAM, BTHPROTO_RFCOMM);
// Create the connection information, this is the RFComm protocol for SPP
SOCKADDR_BTH sa;
memset (&sa, 0, sizeof(sa));
sa.addressFamily = AF_BTH;
sa.btAddr = device;
sa.port = BT_PORT_ANY;
sa.serviceClassId = RFCOMM_PROTOCOL_UUID;
// connect...
connect (s, (SOCKADDR *)&sa, sizeof(sa))
Once connected you can use send/recieve to send over the SPP connection:
send (connectedSocket, (char*)str, len,0)
recv( connectedSocket, str, len,0)
This way you don't have to map serial ports, this was tested on Windows XP but should also work on windows CE.
It was tested printing GPS information from a TOMTOM reciever.
Showing posts with label bluetooth spp sockets gps. Show all posts
Showing posts with label bluetooth spp sockets gps. Show all posts
Wednesday, 25 April 2007
Subscribe to:
Posts (Atom)

