@@ -118,6 +118,36 @@ bool bluetoothIsConnected()
118118 return (false );
119119}
120120
121+ // Return true if the BLE Command channel is connected
122+ bool bluetoothCommandIsConnected ()
123+ {
124+ #ifdef COMPILE_BT
125+ if (bluetoothGetState () == BT_OFF)
126+ return (false );
127+
128+ if (settings.bluetoothRadioType == BLUETOOTH_RADIO_SPP_AND_BLE)
129+ {
130+ if (bluetoothSerialBleCommands->connected () == true )
131+ return (true );
132+ }
133+ else if (settings.bluetoothRadioType == BLUETOOTH_RADIO_SPP)
134+ {
135+ return (false );
136+ }
137+ else if (settings.bluetoothRadioType == BLUETOOTH_RADIO_BLE)
138+ {
139+ if (bluetoothSerialBleCommands->connected () == true )
140+ return (true );
141+ }
142+ else if (settings.bluetoothRadioType == BLUETOOTH_RADIO_SPP_ACCESSORY_MODE)
143+ {
144+ return (false );
145+ }
146+ #endif // COMPILE_BT
147+
148+ return (false );
149+ }
150+
121151// Return the Bluetooth state
122152byte bluetoothGetState ()
123153{
@@ -254,23 +284,19 @@ int bluetoothCommandAvailable()
254284}
255285
256286// Pass a command string to the BLE Serial interface
257- void bluetoothProcessCommand (char *rxData)
287+ void bluetoothSendCommand (char *rxData)
258288{
259289#ifdef COMPILE_BT
260290 // Direct output to Bluetooth Command
261291 PrintEndpoint originalPrintEndpoint = printEndpoint;
262292
263- printEndpoint = PRINT_ENDPOINT_BLUETOOTH_COMMAND;
264- if (settings.debugCLI == true )
265- printEndpoint = PRINT_ENDPOINT_ALL;
266- else
267- printEndpoint = PRINT_ENDPOINT_BLUETOOTH_COMMAND;
293+ printEndpoint = PRINT_ENDPOINT_ALL;
268294
269- processCommand (rxData); // Send command proccesor output to BLE
295+ systemPrint (rxData); // Send command output to BLE, SPP, and Serial
270296 printEndpoint = originalPrintEndpoint;
271297
272298#else // COMPILE_BT
273- processCommand (rxData); // Send command proccesor output to Serial
299+ systemPrint (rxData); // Send command output to Serial
274300#endif // COMPILE_BT
275301}
276302
@@ -534,9 +560,9 @@ void bluetoothStart()
534560 memcpy (record.uuid .uuid .uuid128 , UUID_IAP2, sizeof (UUID_IAP2));
535561 record.service_name_length = strlen (sdp_service_name) + 1 ;
536562 record.service_name = (char *)sdp_service_name;
537- // record.service_name_length = strlen(deviceName) + 1; // Doesn't seem to help the failed connects
538- // record.service_name = (char *)deviceName;
539- // record.rfcomm_channel_number = 1; // Doesn't seem to help the failed connects
563+ // record.service_name_length = strlen(deviceName) + 1; // Doesn't seem to help the failed connects
564+ // record.service_name = (char *)deviceName;
565+ // record.rfcomm_channel_number = 1; // Doesn't seem to help the failed connects
540566 esp_sdp_create_record ((esp_bluetooth_sdp_record_t *)&record);
541567 }
542568 }
0 commit comments