Home > OS >  Windows virtual serial port using bluetooth
Windows virtual serial port using bluetooth

Time:11-11

Recently, according to the needs of the project need to use bluetooth in the Windows above 10, connecting peripherals, using VC bluetooth related API, communication, code process: local bluetooth device enumeration - & gt; Search nearby bluetooth devices - & gt; Find specifies the name of bluetooth devices, matching, matching success, virtual serial port - & gt; Open the serial port to send and receive data, close the serial port, the pressure of the bluetooth connection tests (tests) require hundreds of times, usually in about dozens of times, open the serial port will fail, open the serial port code is as follows:
CreateFile (strCom,
GENERIC_READ | GENERIC_WRITE,
0,//exclusive access
NULL,//no security attrs
OPEN_EXISTING,//OPEN_EXISTING,
0,//| FILE_FLAG_OVERLAPPED, FILE_ATTRIBUTE_NORMAL
NULL);
Return 1, call GetLastError. Error code: 121, on the Internet to find error description: the semaphore timeout time had come, don't quite understand the specific refers to what? Looks at each ace to give directions, thank you very much!

CodePudding user response:

Now connect is all right, but the stability can not meet the requirements, your help to look at,

CodePudding user response:

Xie asked I'm not very familiar with bluetooth
Whether can only estimate the because of frequent close open and bluetooth or disconnected serial level process need some time to complete the cause at the time of closing, try to open the other end?
Might try to frequently open and close between increase a waiting to see whether can improve stability?

CodePudding user response:

Before I open and closed, increase a certain delay, try effect, thank you very much
  • Related