// Obtain and save the Bluetooth manager object Tbluw.thmanager * BtManager = tbluw.thmanager: Current; // Obtain and save the Bluetooth adapter object BtAdapter = BtManager-> CurrentAdapter; // Obtain the list of paired Bluetooth devices Tbluw.thdevicelist * inclureddevices = BtManager-> getinclureddevices (); // Display the bluetooth device list in the cbw.reddevices combo box (Code omitted) // Obtain the selected bluetooth device object in the combo box Tblustmthdevice * SelDevice = repeated reddevices-> Items [cb1_reddevices-> ItemIndex]; // Obtain the service list of the bluetooth device Tbluw.thservicelist * ListServices = SelDevice-> GetServices (); // Check whether the SPP service is supported in the service list (Code omitted) // If the SPP service is supported // Use the SPP service UUID to create a client Socket. Tblustmthsocket * BtSocket = SelDevice-> CreateClientSocket (StringToGUID (SPP_GUI), false ); // Connect the bluetooth module with a client Socket. BtSocket-> Connect (); // Call SendData () of the client Socket to send data to the bluetooth module. The bluetooth module forwards the received data to the embedded device through UART. BtSocket-> SendData (DataArray); // DataArray is an array // If the embedded device sends data to the bluetooth module, the bluetooth module forwards the data to the mobile phone and the mobile phone caches the data. The App can call the client Socket ReceiveData () to receive the data. " BtSocket-> ReceiveData (50); // receives data, waiting for 50 ms |