diff --git a/data/tracker_config.json b/data/tracker_config.json index b1a3848..6e39d84 100644 --- a/data/tracker_config.json +++ b/data/tracker_config.json @@ -72,7 +72,7 @@ "standingUpdateTime": 15, "sendAltitude": true, "sendBatteryInfo": false, - "bluetoothType": 0, + "bluetoothType": 1, "bluetoothActive": true, "disableGPS": false }, diff --git a/src/LoRa_APRS_Tracker.cpp b/src/LoRa_APRS_Tracker.cpp index 5ed0e78..fa8b7d1 100644 --- a/src/LoRa_APRS_Tracker.cpp +++ b/src/LoRa_APRS_Tracker.cpp @@ -6,6 +6,7 @@ #include #include #include +#include "APRSPacketLib.h" #include "notification_utils.h" #include "bluetooth_utils.h" #include "keyboard_utils.h" @@ -19,14 +20,11 @@ #include "msg_utils.h" #include "gps_utils.h" #include "bme_utils.h" +#include "ble_utils.h" #include "display.h" #include "SPIFFS.h" #include "utils.h" -#include "APRSPacketLib.h" -#include "ble_utils.h" - - Configuration Config; PowerManagement powerManagement; HardwareSerial neo6m_gps(1); @@ -34,7 +32,7 @@ TinyGPSPlus gps; BluetoothSerial SerialBT; OneButton userButton = OneButton(BUTTON_PIN, true, true); -String versionDate = "2023.12.02"; +String versionDate = "2023.12.03"; int myBeaconsIndex = 0; int myBeaconsSize = Config.beacons.size(); @@ -56,9 +54,8 @@ bool sendStandingUpdate = false; bool statusState = true; uint32_t statusTime = millis(); bool bluetoothConnected = false; -bool bluetoothActive = Config.bluetooth; +bool bluetoothActive = Config.bluetoothActive; bool sendBleToLoRa = false; -bool bleConnected = false; String BLEToLoRaPacket = ""; bool messageLed = false; @@ -130,8 +127,11 @@ void setup() { WiFi.mode(WIFI_OFF); logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "Main", "WiFi controller stopped"); - //BLUETOOTH_Utils::setup(); - BLE_Utils::setup(); + if (Config.bluetoothType==0) { + BLE_Utils::setup(); + } else { + BLUETOOTH_Utils::setup(); + } if (!Config.simplifiedTrackerMode) { userButton.attachClick(BUTTON_Utils::singlePress); @@ -170,8 +170,11 @@ void loop() { MSG_Utils::checkReceivedMessage(LoRa_Utils::receivePacket()); MSG_Utils::ledNotification(); STATION_Utils::checkListenedTrackersByTimeAndDelete(); - //BLUETOOTH_Utils::sendToLoRa(); - BLE_Utils::sendToLoRa(); + if (Config.bluetoothType==0) { + BLE_Utils::sendToLoRa(); + } else { + BLUETOOTH_Utils::sendToLoRa(); + } int currentSpeed = (int) gps.speed.kmph(); diff --git a/src/ble_utils.cpp b/src/ble_utils.cpp index 52937ec..4f1d073 100644 --- a/src/ble_utils.cpp +++ b/src/ble_utils.cpp @@ -16,18 +16,18 @@ BLECharacteristic *pCharacteristicRx; extern logging::Logger logger; extern bool sendBleToLoRa; -extern bool bleConnected; +extern bool bluetoothConnected; extern String BLEToLoRaPacket; class MyServerCallbacks : public NimBLEServerCallbacks { void onConnect(NimBLEServer* pServer) { - bleConnected = true; + bluetoothConnected = true; logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "BLE", "%s", "BLE Client Connected"); } void onDisconnect(NimBLEServer* pServer) { - bleConnected = false; + bluetoothConnected = false; logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "BLE", "%s", "BLE client Disconnected, Started Advertising"); pServer->startAdvertising(); } @@ -47,7 +47,7 @@ class MyCallbacks : public NimBLECharacteristicCallbacks { namespace BLE_Utils { - + void setup() { BLEDevice::init("LoRa APRS Tracker"); pServer = BLEDevice::createServer(); diff --git a/src/configuration.cpp b/src/configuration.cpp index e8ba468..d5079bd 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -86,7 +86,8 @@ void Configuration::readFile(fs::FS &fs, const char *fileName) { standingUpdateTime = data["other"]["standingUpdateTime"].as(); sendAltitude = data["other"]["sendAltitude"].as(); sendBatteryInfo = data["other"]["sendBatteryInfo"].as(); - bluetooth = data["other"]["bluetooth"].as(); + bluetoothType = data["other"]["bluetoothType"].as(); + bluetoothActive = data["other"]["bluetoothActive"].as(); disableGPS = data["other"]["disableGPS"].as(); configFile.close();