ready for testing
This commit is contained in:
parent
705a9b15bc
commit
c661527d07
|
|
@ -76,8 +76,7 @@ uint32_t refreshDisplayTime = millis();
|
|||
bool sendUpdate = true;
|
||||
|
||||
bool bluetoothConnected = false;
|
||||
bool sendBleToLoRa = false;
|
||||
String BLEToLoRaPacket = "";
|
||||
//String BLEToLoRaPacket = "";
|
||||
|
||||
uint32_t lastTx = 0.0;
|
||||
uint32_t txInterval = 60000L;
|
||||
|
|
@ -198,7 +197,7 @@ void loop() {
|
|||
BLE_Utils::sendToLoRa();
|
||||
} else {
|
||||
#ifdef HAS_BT_CLASSIC
|
||||
BLUETOOTH_Utils::sendPacket(packet.text.substring(3));
|
||||
BLUETOOTH_Utils::sendToPhone(packet.text.substring(3));
|
||||
BLUETOOTH_Utils::sendToLoRa();
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,9 +26,10 @@ BLECharacteristic *pCharacteristicRx;
|
|||
extern Configuration Config;
|
||||
extern Beacon *currentBeacon;
|
||||
extern logging::Logger logger;
|
||||
extern bool sendBleToLoRa;
|
||||
extern bool bluetoothConnected;
|
||||
extern String BLEToLoRaPacket;
|
||||
|
||||
bool shouldSendBLEtoLoRa = false;
|
||||
String BLEToLoRaPacket = "";
|
||||
|
||||
String kissSerialBuffer = "";
|
||||
|
||||
|
|
@ -66,7 +67,7 @@ class MyCallbacks : public NimBLECharacteristicCallbacks {
|
|||
BLEToLoRaPacket = KISS_Utils::decodeKISS(kissSerialBuffer, isDataFrame);
|
||||
|
||||
if (isDataFrame) {
|
||||
sendBleToLoRa = true;
|
||||
shouldSendBLEtoLoRa = true;
|
||||
kissSerialBuffer = "";
|
||||
}
|
||||
}
|
||||
|
|
@ -76,7 +77,7 @@ class MyCallbacks : public NimBLECharacteristicCallbacks {
|
|||
String receivedString = "";
|
||||
for (int i = 0; i < receivedData.length(); i++) receivedString += receivedData[i];
|
||||
BLEToLoRaPacket = receivedString;
|
||||
sendBleToLoRa = true;
|
||||
shouldSendBLEtoLoRa = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -129,12 +130,12 @@ namespace BLE_Utils {
|
|||
}
|
||||
|
||||
void sendToLoRa() {
|
||||
if (!sendBleToLoRa) return;
|
||||
if (!shouldSendBLEtoLoRa) return;
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, "BLE Tx", "%s", BLEToLoRaPacket.c_str());
|
||||
displayShow("BLE Tx >>", "", BLEToLoRaPacket, 1000);
|
||||
LoRa_Utils::sendNewPacket(BLEToLoRaPacket);
|
||||
BLEToLoRaPacket = "";
|
||||
sendBleToLoRa = false;
|
||||
shouldSendBLEtoLoRa = false;
|
||||
}
|
||||
|
||||
void txBLE(uint8_t p) {
|
||||
|
|
|
|||
|
|
@ -8,9 +8,6 @@ namespace BLE_Utils {
|
|||
void stop();
|
||||
void setup();
|
||||
void sendToLoRa();
|
||||
|
||||
void txBLE(uint8_t p);
|
||||
void txToPhoneOverBLE(const String& frame);
|
||||
void sendToPhone(const String& packet);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,18 +103,15 @@ namespace BLUETOOTH_Utils {
|
|||
}
|
||||
|
||||
void sendToLoRa() {
|
||||
if (!shouldSendToLoRa) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!shouldSendToLoRa) return;
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, "BT TX", "%s", serialReceived.c_str());
|
||||
displayShow("BT Tx >>", "", serialReceived, 1000);
|
||||
LoRa_Utils::sendNewPacket(serialReceived);
|
||||
shouldSendToLoRa = false;
|
||||
}
|
||||
|
||||
void sendPacket(const String& packet) {
|
||||
if (bluetoothActive && !packet.isEmpty()) {
|
||||
void sendToPhone(const String& packet) {
|
||||
if (!packet.isEmpty() && bluetoothActive) {
|
||||
if (useKiss) {
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, "BT RX Kiss", "%s", serialReceived.c_str());
|
||||
SerialBT.println(KISS_Utils::encodeKISS(packet));
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ namespace BLUETOOTH_Utils {
|
|||
void bluetoothCallback(esp_spp_cb_event_t event, esp_spp_cb_param_t *param);
|
||||
void getData(const uint8_t *buffer, size_t size);
|
||||
void sendToLoRa();
|
||||
void sendPacket(const String& packet);
|
||||
void sendToPhone(const String& packet);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue