diff --git a/Board320_240.cpp b/Board320_240.cpp index 0c2da3e..f54d0e4 100644 --- a/Board320_240.cpp +++ b/Board320_240.cpp @@ -1188,7 +1188,7 @@ void Board320_240::redrawScreen() { } // BLE not connected - if (!liveData->bleConnected && liveData->bleConnect && liveData->tmpSettings.commType == COMM_TYPE_OBD2BLE4) { + if (!liveData->commConnected && liveData->bleConnect && liveData->tmpSettings.commType == COMM_TYPE_OBD2BLE4) { // Print message spr.setTextSize(1); spr.setTextColor(TFT_WHITE, TFT_BLACK); diff --git a/CommObd2Ble4.cpp b/CommObd2Ble4.cpp index 37a09a5..c680a24 100644 --- a/CommObd2Ble4.cpp +++ b/CommObd2Ble4.cpp @@ -19,7 +19,7 @@ class MyClientCallback : public BLEClientCallbacks { // On BLE disconnect void onDisconnect(BLEClient* pclient) { - //connected = false; + liveDataObj->commConnected = false; Serial.println("onDisconnect"); boardObj->displayMessage("BLE disconnected", ""); @@ -323,7 +323,7 @@ void CommObd2Ble4::mainLoop() { liveData->pServerAddress = new BLEAddress(liveData->settings.obdMacAddress); if (connectToServer(*liveData->pServerAddress)) { - liveData->bleConnected = true; + liveData->commConnected = true; liveData->bleConnect = false; Serial.println("We are now connected to the BLE device."); @@ -354,7 +354,7 @@ void CommObd2Ble4::mainLoop() { void CommObd2Ble4::executeCommand(String cmd) { String tmpStr = cmd + "\r"; - if (liveData->bleConnected) { + if (liveData->commConnected) { liveData->pRemoteCharacteristicWrite->writeValue(tmpStr.c_str(), tmpStr.length()); } } diff --git a/CommObd2Can.cpp b/CommObd2Can.cpp index 48aa8b8..b085cc0 100644 --- a/CommObd2Can.cpp +++ b/CommObd2Can.cpp @@ -37,6 +37,7 @@ void CommObd2Can::connectDevice() { pinMode(pinCanInt, INPUT); // Configuring pin for /INT input // Serve first command (ATZ) + liveData->commConnected = true; doNextQueueCommand(); Serial.println("init_can() done"); @@ -47,6 +48,7 @@ void CommObd2Can::connectDevice() { */ void CommObd2Can::disconnectDevice() { + liveData->commConnected = false; Serial.println("COMM disconnectDevice"); } diff --git a/LiveData.h b/LiveData.h index 77606c6..3803134 100644 --- a/LiveData.h +++ b/LiveData.h @@ -219,9 +219,10 @@ class LiveData { uint16_t scanningDeviceIndex = 0; MENU_ITEM* menuItems; + // Comm + boolean commConnected = true; // Bluetooth4 boolean bleConnect = true; - boolean bleConnected = false; BLEAddress *pServerAddress; BLERemoteCharacteristic* pRemoteCharacteristic; BLERemoteCharacteristic* pRemoteCharacteristicWrite;