update for better BLE

This commit is contained in:
richonguzman 2024-07-13 13:38:14 -04:00
parent 833dafda34
commit dbb8976e31
5 changed files with 11 additions and 2 deletions

View File

@ -45,7 +45,7 @@ TinyGPSPlus gps;
OneButton userButton = OneButton(BUTTON_PIN, true, true); OneButton userButton = OneButton(BUTTON_PIN, true, true);
#endif #endif
String versionDate = "2024.07.11"; String versionDate = "2024.07.13";
uint8_t myBeaconsIndex = 0; uint8_t myBeaconsIndex = 0;
int myBeaconsSize = Config.beacons.size(); int myBeaconsSize = Config.beacons.size();

View File

@ -38,6 +38,9 @@ class MyServerCallbacks : public NimBLEServerCallbacks {
bluetoothConnected = false; bluetoothConnected = false;
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "BLE", "%s", "BLE client Disconnected, Started Advertising"); logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "BLE", "%s", "BLE client Disconnected, Started Advertising");
pServer->startAdvertising(); pServer->startAdvertising();
LoRa_Utils::sleepRadio();
delay(500);
LoRa_Utils::wakeRadio();
} }
}; };

View File

@ -184,6 +184,7 @@ namespace LoRa_Utils {
receivedLoraPacket.freqError = radio.getFrequencyError(); receivedLoraPacket.freqError = radio.getFrequencyError();
} }
} else { } else {
//Serial.println(packet);
Serial.print(F("failed, code ")); // 7 = CRC mismatch Serial.print(F("failed, code ")); // 7 = CRC mismatch
Serial.println(state); Serial.println(state);
} }
@ -192,6 +193,10 @@ namespace LoRa_Utils {
return receivedLoraPacket; return receivedLoraPacket;
} }
void wakeRadio() {
radio.startReceive();
}
void sleepRadio() { void sleepRadio() {
radio.sleep(); radio.sleep();
} }

View File

@ -18,6 +18,7 @@ namespace LoRa_Utils {
void setup(); void setup();
void sendNewPacket(const String& newPacket); void sendNewPacket(const String& newPacket);
ReceivedLoRaPacket receivePacket(); ReceivedLoRaPacket receivePacket();
void wakeRadio();
void sleepRadio(); void sleepRadio();
} }

View File

@ -401,7 +401,7 @@ namespace MSG_Utils {
if (packet.text.substring(0,3) == "\x3c\xff\x01") { // its an APRS packet if (packet.text.substring(0,3) == "\x3c\xff\x01") { // its an APRS packet
//Serial.println(packet.text); // only for debug //Serial.println(packet.text); // only for debug
lastReceivedPacket = APRSPacketLib::processReceivedPacket(packet.text.substring(3),packet.rssi, packet.snr, packet.freqError); lastReceivedPacket = APRSPacketLib::processReceivedPacket(packet.text.substring(3),packet.rssi, packet.snr, packet.freqError);
if (lastReceivedPacket.sender!=currentBeacon->callsign) { if (lastReceivedPacket.sender != currentBeacon->callsign) {
if (lastReceivedPacket.message.indexOf("\x3c\xff\x01") != -1) { if (lastReceivedPacket.message.indexOf("\x3c\xff\x01") != -1) {
lastReceivedPacket.message = lastReceivedPacket.message.substring(0, lastReceivedPacket.message.indexOf("\x3c\xff\x01")); lastReceivedPacket.message = lastReceivedPacket.message.substring(0, lastReceivedPacket.message.indexOf("\x3c\xff\x01"));