Bluetooth sockets

| 435 Comments

This morning I decided to investigate the Windows XP SP1 Bluetooth support. I played with the BluetoothXXXX API and quickly became disapointed. I then moved on to looking at how to access the Bluetooth hardware using Winsock and decided that is a much better route to take...

The Bluetooth API that lives in Irprops.cpl appears to be the easy way in to Bluetooth. The API itself has an 'interesting' design, but I can kinda understand why it looks like it does. Unfortunately it's very limited in what it offers to the developer. Basically it's an API on to the wireless link control panel applet - the fact that it lives in the same dll should have given that away... Once you realise that's all it is then it's quite good. You can programatically control all of the stuff that the control panel applet lets you do and pop up their standard dialogs, etc. So, if you want to search for devices and enumerate the 'dialup network service' then it's fine. If you want to do more then it's not for you...

Accessing Bluetooth hardware using Winsock is more cumbersome, but it looks like you can do pretty much everything you'd want to. This morning I spent some time knocking up a simple 'MSDN style' sample that iterated devices and services. It works nicely, once you understand what you're supposed to do. And you get back all of the services that your devices offer and details of the ports that they're being offered on. Since I didn't have net access I didn't go and look up the specs over at www.bluetooth.com but that's on the list for this week. The docs imply that you can register a service profile and then just listen on a socket in the usual winsock way to wait for connections, sounds cool and easy. Should be fun...

// blue.cpp : Defines the entry point for the console application.
//

#include <winsock2.h>
#include <Ws2bth.h>
#include <BluetoothAPIs.h>

#include <stdio.h>

#pragma comment(lib, "ws2_32.lib")

#pragma comment(lib, "irprops.lib")

TCHAR *GetLastErrorMessage(DWORD last_error)
{
   static TCHAR errmsg[512];

   if (!FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 
      0,
      last_error,
      0,
      errmsg, 
      511,
      NULL))
   {
      /* if we fail, call ourself to find out why and return that error */
      return (GetLastErrorMessage(GetLastError()));  
   }
  
   return errmsg;
} 

BOOL __stdcall callback(
  ULONG uAttribId,
  LPBYTE pValueStream,
  ULONG cbStreamSize,
  LPVOID pvParam)
{
//   printf("Callback %d\n", uAttribId);

   SDP_ELEMENT_DATA element;

   if (ERROR_SUCCESS != BluetoothSdpGetElementData(pValueStream,  cbStreamSize, &element))
   {
	   printf("%s\n", GetLastErrorMessage(GetLastError()));
   }


   return true;
}



int main(int argc, char* argv[])
{
   WORD wVersionRequested = 0x202;
   WSADATA m_data;

   if (0 == ::WSAStartup(wVersionRequested, &m_data))
   {
      SOCKET s = ::socket(AF_BTH, SOCK_STREAM, BTHPROTO_RFCOMM); 

      const DWORD lastError = ::GetLastError();

      if (s == INVALID_SOCKET)
      {
	      printf("Failed to get bluetooth socket! %s\n", GetLastErrorMessage(lastError));
         exit(1);
      }

      WSAPROTOCOL_INFO protocolInfo;

      int protocolInfoSize = sizeof(protocolInfo);

      if (0 != getsockopt(s, SOL_SOCKET, SO_PROTOCOL_INFO, (char*)&protocolInfo, &protocolInfoSize))
      {
         exit(1);
      }

      
      WSAQUERYSET querySet;

      memset(&querySet, 0, sizeof(querySet));

      querySet.dwSize = sizeof(querySet);

      querySet.dwNameSpace = NS_BTH;

      HANDLE hLookup;
      DWORD flags = LUP_RETURN_NAME | LUP_CONTAINERS | LUP_RETURN_ADDR | LUP_FLUSHCACHE | LUP_RETURN_TYPE | LUP_RETURN_BLOB | LUP_RES_SERVICE;

      int result = WSALookupServiceBegin(&querySet, flags, &hLookup);

      if (0 == result)
      {
         while (0 == result)
         {
            BYTE buffer[1000];

            DWORD bufferLength = sizeof(buffer);

            WSAQUERYSET *pResults = (WSAQUERYSET*)&buffer;

            result = WSALookupServiceNext(hLookup, flags, &bufferLength, pResults);

            if (result != 0)
            {
               printf("%s\n", GetLastErrorMessage(GetLastError()));
               printf("%d\n", bufferLength);
            }
            else
            {
               printf("%s\n", pResults->lpszServiceInstanceName);

               CSADDR_INFO *pCSAddr = (CSADDR_INFO *)pResults->lpcsaBuffer;

               BTH_DEVICE_INFO *pDeviceInfo = (BTH_DEVICE_INFO*)pResults->lpBlob;

               WSAQUERYSET querySet2;

               memset(&querySet2, 0, sizeof(querySet2));

               querySet2.dwSize = sizeof(querySet2);

               GUID protocol = L2CAP_PROTOCOL_UUID;

               querySet2.lpServiceClassId = &protocol;
   
               querySet2.dwNameSpace = NS_BTH;

               char addressAsString[1000];

               DWORD addressSize = sizeof(addressAsString);

               addressSize = sizeof(addressAsString);

               if (0 == WSAAddressToString(pCSAddr->LocalAddr.lpSockaddr, pCSAddr->LocalAddr.iSockaddrLength, &protocolInfo, addressAsString, &addressSize))
               {  
                  printf("local address: %s\n", addressAsString);
               }

               addressSize = sizeof(addressAsString);

               if (0 == WSAAddressToString(pCSAddr->RemoteAddr.lpSockaddr, pCSAddr->RemoteAddr.iSockaddrLength, &protocolInfo, addressAsString, &addressSize))
               {
                  printf("device address: %s\n", addressAsString);
               }




               querySet2.lpszContext = addressAsString;

               HANDLE hLookup2;
               DWORD flags = LUP_FLUSHCACHE |LUP_RETURN_NAME | LUP_RETURN_TYPE | LUP_RETURN_ADDR | LUP_RETURN_BLOB | LUP_RETURN_COMMENT;

               int result = WSALookupServiceBegin(&querySet2, flags, &hLookup2);

               if (0 == result)
               {
                  while (0 == result)
                  {
                     BYTE buffer[2000];

                     DWORD bufferLength = sizeof(buffer);

                     WSAQUERYSET *pResults = (WSAQUERYSET*)&buffer;

                     result = WSALookupServiceNext(hLookup2, flags, &bufferLength, pResults);

                     if (result != 0)
                     {
                        printf("%s\n", GetLastErrorMessage(GetLastError()));
                        printf("%d\n", bufferLength);
                     }
                     else
                     {
                        printf("%s\n", pResults->lpszServiceInstanceName);
                        //printf("%s\n", pResults->lpszComment);

                        CSADDR_INFO *pCSAddr = (CSADDR_INFO *)pResults->lpcsaBuffer;

                        addressSize = sizeof(addressAsString);

                        if (0 == WSAAddressToString(pCSAddr->LocalAddr.lpSockaddr, pCSAddr->LocalAddr.iSockaddrLength, &protocolInfo, addressAsString, &addressSize))
                        {  
                           printf("local address: %s\n", addressAsString);
                        }

                        addressSize = sizeof(addressAsString);

                        if (0 == WSAAddressToString(pCSAddr->RemoteAddr.lpSockaddr, pCSAddr->RemoteAddr.iSockaddrLength, &protocolInfo, addressAsString, &addressSize))
                        {
                           printf("device address: %s\n", addressAsString);
                        }

                        if (pResults->lpBlob)
                        {
                           const BLOB *pBlob = (BLOB*)pResults->lpBlob;

                           if (!BluetoothSdpEnumAttributes(pBlob->pBlobData, pBlob->cbSize, callback, 0))
                           {
                              printf("BluetoothSdpEnumAttributes - %s\n", GetLastErrorMessage(GetLastError()));
                           }

                        }

                     }
                  }
         
                  result = WSALookupServiceEnd(hLookup2);

               }
               else
               {
                  printf("%s\n", GetLastErrorMessage(GetLastError()));
               }

            }
         }
         
         result = WSALookupServiceEnd(hLookup);
      }
      else
      {
         printf("%s\n", GetLastErrorMessage(GetLastError()));
      }

      WSACleanup();
   }

   HANDLE hRadio;
   BLUETOOTH_FIND_RADIO_PARAMS btfrp = { sizeof(btfrp) };

   HBLUETOOTH_RADIO_FIND hFind = BluetoothFindFirstRadio( &btfrp, &hRadio );

   if ( NULL != hFind )
   {
      printf("hFind\n");

      do
      {
         //
         //  TODO: Do something with the radio handle.
         //

		 BLUETOOTH_RADIO_INFO radioInfo;

		 radioInfo.dwSize = sizeof(radioInfo);

		 if (ERROR_SUCCESS == BluetoothGetRadioInfo(hRadio, &radioInfo))
		 {
			wprintf(L"Raido: %s\n", radioInfo.szName);
		 }

		 BLUETOOTH_DEVICE_INFO_STRUCT deviceInfo;

		 deviceInfo.dwSize = sizeof(deviceInfo);

		 BLUETOOTH_DEVICE_SEARCH_PARAMS deviceSearchParams;

		 memset(&deviceSearchParams, 0, sizeof(deviceSearchParams));

		 deviceSearchParams.dwSize = sizeof(deviceSearchParams);

		 //deviceSearchParams.fReturnAuthenticated = true;
		 deviceSearchParams.fReturnRemembered = true;
		 //deviceSearchParams.fReturnUnknown = true;
		 //deviceSearchParams.fReturnConnected = true;

		 deviceSearchParams.hRadio = hRadio;

		 HANDLE hDeviceFind = BluetoothFindFirstDevice(&deviceSearchParams, &deviceInfo);

		 if (NULL != hDeviceFind)
		 {
			 do
			 {
				 wprintf(L"Device: %s\n", deviceInfo.szName);

				 //BluetoothDisplayDeviceProperties(0, &deviceInfo);
			 }
			 while(BluetoothFindNextDevice(hDeviceFind, &deviceInfo));

			 BluetoothFindDeviceClose(hDeviceFind);
		 }


		 if (BluetoothGetDeviceInfo(hRadio, &deviceInfo))
		 {
			wprintf(L"+ Device: %s\n", deviceInfo.szName);

			// BluetoothUpdateDeviceRecord - change name

			// BluetoothRemoveDevice

		 }

		 GUID guidServices[10];

		 DWORD numServices = sizeof(guidServices);

		 DWORD result = BluetoothEnumerateInstalledServices(hRadio, &deviceInfo, &numServices, guidServices);

		          CloseHandle( hRadio );
      } while( BluetoothFindNextRadio( hFind, &hRadio ) );

      BluetoothFindRadioClose( hFind );
   }


	return 0;
}

435 Comments

Len

Many thanks for posting the Bluetooth Sockets code on your webpage as is is extremely useful in the bluetooth client-server application I am currently developing.

However I am having a problem in that I get an unresolved symbol for _L2CAP_PROTOCOL_UUID, so please could you identify which library this is declared in, and where I might be able to find documentation on it?

Many thanks again as I have been having many problems in getting my bluetooth code working (so far I have not got it going yet) so all the help I can get is appreciated

john

I'll take a look at the code at the weekend and find out where it links it in from.

(Answer to the previous question is: The symbol is probably in library Uuid.lib.)

Very interesting sample. I also tried to work with bluetooth and use MS Bluetooth API and this is probably only page on net, where BluetoothFindFirstRadio function is used.
However, I have still problems with this function and also with using sockets. After running your sample I get error
"Failed to get bluetooth socket! An address incompatible with the requested protocol was used."
and alse the second part (BluetoothFindFirstRadio ...) works weird - it finds no radios despite the fact, that I have Win XP SP1 + Bluetooth QFE and Windows normally recognizes my cellular phone and can communicat with that.

Please, if you or any reader, know the answer, why this is happening, post it here.
Thank you.

Thanks Len,

it helped me alot taken first steps into Bluetooth communication. After applying your sample, i was able to send my first message via bluetooth.

Ronald.

len

Thanks for identifying which library the symbol was in and you will be pleased to hear that the code now compiles and executes.

However the socket s returns INVALID_SOCKET and the application therefore fails. I have tried establishing a simple socket connection but this also fails.

Do you have any idea why this might be failing, and why I am having problems with the socket?

Thanks

What does GetLastError() or GetLastErrorMessage() (shown above) return? As far as I know you need to have bluetooth hardware that is directly supported by XP to get this to work...

Len

I think this boils down to a hardware compatability issue with Windows as I am using a 3Com USB dongle to provide Bluetooth services.

Please could you let me know which operating system and Bluetooth hardware you are using?

John

John,

For this code to work you MUST have hardware that is supported and recognised natively by XP SP1. I'm using XP SP1 and the built in bluetooth hardware that comes with the Sony Vaio PCG-Z1SP.

See http://www.lenholgate.com/archives/000089.html for my complaints about the difficulty in finding hardware that's compatible (I also have a TDK USB dongle which doesnt work with XPs bluetooth support)

Help...great confusion!!
I've win Xp sp1 and Digicom USB dongle...
Can I use c++ code (like that one shown here)?

Thanks of all

Help...great confusion!!
I've win Xp sp1, Platform SDK, Visual Studio .net and Digicom USB dongle...
Can I use c++ code (like that one shown here)?

Thanks of all

Do you have a bluetooth tab on your wireless link control panel applet?

Does it work? If the bluetooth device is recognised by xp then you should have the tab and you should be able to do stuff with your bluetooth device via the tab. If you dont then the code above wont work.

I'm sorry for my ingnorance...but I can't understand you. :°(
My wireless link in control panel works well, I think It's software written by Widcomm...but I can't understand what do you mean about tab!
Please help me soon...

Thanks of all

As far as I know it will only work if XP recognises your bluetooth device and doesnt need additional drivers. I have a TDK dongle that needs its own drivers and doesnt integrate with XP's wireless link control panel applet and that doesnt work with the code above. I have built in bluetooth on the Sony Vaio and that integrates with XP's control panel applet and works with the code above. That's all I know. Compile the code, see if it works.

Len

Hi, after trying out the blue.c code, I also got the "Failed to get bluetooth socket! An address incompatible with the requested protocol was used" message that Vit encountered. I wonder whether you encounter the same kind of problem when you use the non-winxp compatible bluetooth device that you had? For my bluetooth device, it's a csr usb bluetooth endpoint.

Thank you and hopefully you have some thoughts on this.

Allen

Allen,

Yes, I get that error message if I run the code on my XP SP1 machine with the TDK dongle.

The TDK device doesn't seem to be supported by XP directly yet. I think their bluetooth stuff is done by Widcomm and I think you need to purchase an SDK from Widcomm to be able to programatically control it...

I think it coul be helpful make a sort of list of BT device native recognized by win xp sp 1.
I'm start here with my device:

Digicom USB Palladio with Chipset CSR frimware version 373 not supported

Please, insert your experiences

Does anyone know if the Microsoft bluetooth adapter that comes with the MS bluetooth desktop is XP-compatible? Or any other compatible bluetooth adapters? With my AmbiCom BT2000C-USB adapter I get the error "Failed to get bluetooth socket! An address incompatible with the requested protocol was used"...

Eirik

thanks for that code.
it compiled fine after I downloaded the latest windows platform SDK.
HOWEVER, when running the program, i get an error (translated from german):
procedure entry point "BluetoothFindNextRadio" was not found in DLL "irprops.cpl".

does anybody know what that means?
has anybody has similar problems?
thx

That means that you dont have the correct version of the irprops.cpl control panel applet. This means that the native XP SP 1 bluetooth support isnt installed which in turn means that your hardware doesnt work with the code shown in the article.

Len,
great code, but my hardware is unsupported, sigh
:-((
I've a question:
Why you create a SOCKET and get its options ?
It's only to get a string translation of addresses or is necessary to start using WSALookupServiceXXX functions ?

Max

> Why you create a SOCKET and get its options ?

No reason. The code just grew and never got cleaned up. The socket creation at the start is a good way to tell if it's going to work, if that fails then your hardware isn't supported... I probably grabbed the socket options to work something out and then never removed the call...

Does anyone know how to get Ws2bth.h and BluetoothAPIs.h ??? I have installed WIN XP SP1,Visual Studio .NET I have even Q323183_WXP_SP2_X86_ENU.exe but I could't find those files. I anyone could help I would be appreciate.

Platform SDK?

Hi,
I have CSR chip based Bluetooth USB dongle and iPAQ 3870 with built-in Bluetooth.

I tried your code on WIN XP and it shows all the services offered by iPAQ.i also tried other bluetooth functions from Platform SDK and all works fine.

I want my desktop with WIN XP to act as server for BLuetooth client-server communication.

I am able to open bluetooth socket and advertise SPP service on WIN XP. iPaq discovers it but when i try to connect to SPP on WIN XP, it says "Unable to connect to device" same happens when i try to connect to File Transfer Service.
On WIN XP, my application is waiting on accept().. it never accepts any call.

When i try to connect from WIN XP to iPAQ to SPP using bluetooth Sockets, it works fine.. i am able to connect it and also i can send data to iPAQ using send(), but again when i try to receive data from iPAQ using recv(), my application on WIN XP waits on recv(), but never receive any data..

i tried on WIN 98 and used createfile() to open COM4 to receive data from iPAQ to check if iPAQ is sending data or not and i receivec data on WIN 98, so my application on iPAQ is working fine.

Can you help me or tell me, why i am not able to accept incoming connections or receive data on WIN XP. i have installed everything, Platform SDK, MS Bluetooth Stack, QFE 323183.

Thanks and Regards,
Deepak

I get a connection accepted if I advertise the service like this:

SOCKADDR_BTH address;

address.addressFamily = AF_BTH;
address.btAddr = 0;
address.serviceClassId = GUID_NULL;
address.port = BT_PORT_ANY;

sockaddr *pAddr = (sockaddr*)&address;

if (0 != bind(s, pAddr, sizeof(SOCKADDR_BTH)))
{
printf("%s\n", GetLastErrorMessage(GetLastError()));
}

int size = sizeof(SOCKADDR_BTH);

if (0 != getsockname(s, pAddr, &size))
{
printf("%s\n", GetLastErrorMessage(GetLastError()));
}

if (0 != listen(s, 10))
{
printf("%s\n", GetLastErrorMessage(GetLastError()));
}


WSAQUERYSET service;

memset(&service, 0, sizeof(service));

service.dwSize = sizeof(service);

service.lpszServiceInstanceName = "My Service";
service.lpszComment = "My comment";

GUID serviceID = OBEXFileTransferServiceClass_UUID;

service.lpServiceClassId = &serviceID;

service.dwNumberOfCsAddrs = 1;
service.dwNameSpace = NS_BTH;

CSADDR_INFO csAddr;

memset(&csAddr, 0, sizeof(csAddr));

csAddr.LocalAddr.iSockaddrLength = sizeof(SOCKADDR_BTH);
csAddr.LocalAddr.lpSockaddr = pAddr;

csAddr.iSocketType = SOCK_STREAM;
csAddr.iProtocol = BTHPROTO_RFCOMM;

service.lpcsaBuffer = &csAddr;

if (0 != WSASetService(&service, RNRSERVICE_REGISTER, 0))
{
printf("%s\n", GetLastErrorMessage(GetLastError()));
}

SOCKET s1 = accept(s, 0, 0);

unsigned char buffer[2000];

memset(buffer, 0, sizeof(buffer));

int r = recv(s1,(char*)buffer, sizeof(buffer), 0);

printf("%s\n", DumpData(buffer, r, 40).c_str());

HandlePacket(s1, r, buffer);

memset(buffer, 0, sizeof(buffer));

r = recv(s1,(char*)buffer, sizeof(buffer), 0);

printf("%s\n", DumpData(buffer, r, 40).c_str());

closesocket(s1);

if (0 != WSASetService(&service, RNRSERVICE_DELETE, 0))
{
printf("%s\n", GetLastErrorMessage(GetLastError()));
}

closesocket(s);

WSACleanup();
}

Visual C++

No, I meant have you downloaded and installed the latest plaform sdk? (or installed it from MSDN)

Hi,
I tried this code, but same thing happened,it waits on accept and never accepts any request..
Is the problem with my Dongle??
Deepak

I've no idea. It works fine for me...

Can you tell me which BT USB adapter or Dongle you are using?
Or Can you tell me what all BT Adapters are fully supported by MS BLUETOOTH API's.
I will buy that one and try it.
Thanks.
Deepak

I have whatever is built in to my Sony Vaio. That works fine. I have a TDK dongle and that doesnt work.

I have tried DBlink's DBT 120 USB adapter and Belkin USB adapter..both of the are not working.

Have anyone resolve the problem about INVALID_SOCKET?
I have the same problem that Vit Kovalcik. Could any one help me?
I have the MS SDK installed. MAy be a problem with any dll?
Thanks

The reason you get an INVALID_SOCKET error is because you dont have appropriate drivers installed for your device. Read the comments here and on the other bluetooth entry.

Is there any USB Bluetooth dongle that will work with Microsofts API for Bluetooth? While reading this, it seems, that there is a API which isn't supported by most of the manufacturers.
The actual Bluetooth .inf file from Microsoft should recognize about 12 different Bluetooth devices, but i'm not sure if these devices also are working correctly with the API. Does anyone know more?

Is there any way to connect to L2CAP layer on Microsoft BT stack ?? Because when I'm trying to make a socket "socket(AF_BTH,SOCK_STREAM, BTHPROTO_L2CAP);" But in bluetoothapis.h there is a definition of BTHPROTO_L2CAP and RFCOMM. So my quastion is: Is there any way to make a socket to L2CAP layer ?

Can I run your application without QFE 323183?
I can install that.

I've no idea, the bluetooth hardware in my Vaio just works and I never bothered to try and get my non functioning TDK dongle to work.

In the .inf file there is an entry for sony built-in devices, but there is also an entry for a tdk device (driver expected soon since 3 month).
What about the Widcomm Bluetooth stack? Are there any header files, that can be downloaded with out buying the hole development kit?

I've tried your code and it worked flawlessly once and the other times it gave me "The parameter is incorrect" errors even though it managed to discover the local and remote device address.

I'm currently using the USB Bluetooth Adapter that came with the Microsoft Bluetooth Mouse. For some odd reason, if the mouse is not connected, the program would fail to discover even the local address. Once it is connected, it discovers both remote and local address. This makes no sense since the adapter itself should contain an address. Furthermore, even when I set the serviceClassId to OBEXFileTransfer_UUID, it still returns the mouse's remote address!

The one time that I managed to successfully do it was in the presense of another Bluetooth laptop. Do you think that was the reason? If so, then I would be relieved because my project involves laptop to laptop communications anyways.

Quite confused and frustrated by Microsoft. Anyone know of another adapter that uses the MS Bluetooth stack? The only reason I brought the mouse is because I knew MS would definitely use their own stack.

I do have XP Professional SP1 but I can't seem to find irprops.cpl. This seems to be a common issue. Where do you get the file ?

The correct irprops.cpl for bluetooth use comes with bluetooth devices that are supported by MS's drivers. If you dont have a supported device you cant use the bluetooth functionality.

hi!
I need help!!
I try test Bluetooth API in Windows XP SP1, but drivers for my dongle not are compatible with BlueTooth API. The dongle is MSI USB MS-6967 compatible Windows® 2000/ME/98/XP :(

You can recommend another device compatible with WinXP SP1 BlueTooth API ?

Thanks.

Anyone has a 10050 error (A socket operation encountered a dead network.) when executing "bind". May be a problem with the support of my device? I have a Dell TrueMobile 300, and it´s no supported by Windows XP (I think)

Len, could you tell me what hardware, software, devices, and operating system do you have?
Is necessary to include any "*.lib" or "*.dll" of the Bluetooth adapter in the compiler?
Thank you very much.

Windows XP SP 1.
Sony Vaio PCG-Z1SP with whatever built in Bluetooth hardware that has.
Platform SDK.

Len - Thanks for your help and puting up with all us "dongles" who keep pelting you with questions :) Here's what I have gleaned so far: if the dongle isn't directly supported by M$, this code and the Bluetooth API ain't gonna work. Even if the dongle is supported by M$, it might not work (such as the TDK device). I have a D-Link DBT-120 which doesn't work with this code. The driver is written by Widcom and I'm guessing I'd have to get their SDK to control it. Fine.

Which devices work with the OS out of the box without the need for buying someone's SDK ? You have stated that your TDK doesn't work. What does work ? Who has had success and what devices were they using ?

Thanks

There is an USB adaptor that seems to work with this code. It´s Brain Boxes BL-554. I haven´t probed it yet, but they say that it can be programmed with MS SDK and is supported by MS Bluetooth Stack.
Len, could you tell me what Bluetooth adapter has your Sony Vaio? I tried in sony web but I couldn,t find it. Do you have an USB dongle of sony too?
Thanks for all.

Len,

I'm trying to communicate from my PC to the Bluetooth enabled printer through the BTH socket programming(using RFCOMM protocol).

Currently in our application, in case of USB, transfer of a file is happening through the Symbolic link and we are transferring chunks of data of length 2048 bytes through this symbolic link.

Now I need to replace the entire USB communication to Bluetooth connection.

I need to know how can I tranfer a file in chunks of 2048 bytes, which is as similar to sending through USB port using device's symbolic link.

I'm able to create a BTH socket and binding it with the device address and now I need to communicate with the printer by sending chunks of data of 2048 bytes of a file(Just like through symboli link in USB).

I need to know what is the equivalent of symbolic link is this RFCOMM specification and how do I tranfer the data to the printer.

Awaiting response eagerly.

Thanks in advance for your help.

Nacho

Will check when I get back to the office.

Motive

I think you need to read up on socket programming. Using sockets with bluetooth isnt much different than using them in any other way.

Leave a comment

About this Entry

Working for Microsoft was the previous entry in this blog.

Sunny day in Kensington Gardens is the next entry in this blog.

I usually write about C++ development on Windows platforms, but I often ramble on about other less technical stuff...

Find recent content on the main index or look in the archives to find all content.

I have other blogs...

Subscribe to feed The Server Framework - high performance server development
Subscribe to feed Lock Explorer - deadlock detection and multi-threaded performance tools
Subscribe to feed l'Hexapod - embedded electronics and robotics
Subscribe to feed MegèveSki - skiing