Commit 31c74498 authored by Eric Duminil's avatar Eric Duminil
Browse files

Starting to parse Lora config

parent fcee9d6d
......@@ -65,11 +65,43 @@ namespace lorawan {
bool connected = false;
char last_transmission[23] = "";
uint8_t hexToByte(char c) {
int v = -1;
if ((c >= '0') && (c <= '9')) {
v = (c - '0');
} else if ((c >= 'A') && (c <= 'F')) {
v = (c - 'A' + 10);
} else if ((c >= 'a') && (c <= 'f')) {
v = (c - 'a' + 10);
}
return v;
}
void parseConfig(const char *hex) {
int n = strlen(hex);
Serial.println(hex);
Serial.print("Size : ");
Serial.println(n);
for (int i = 0; i < n; i = i + 2) {
uint8_t r = hexToByte(hex[i]) << 4 | hexToByte(hex[i + 1]);
Serial.print(r, HEX);
Serial.print(" ");
}
Serial.println();
Serial.println("-----");
}
void initialize() {
Serial.print(F("Starting LoRaWAN. Frequency plan : "));
Serial.print(config::lorawan_frequency_plan);
Serial.println(F(" MHz."));
parseConfig(config::lorawan_device_eui);
parseConfig(config::lorawan_app_eui);
parseConfig(config::lorawan_app_key);
// More info about pin mapping : https://github.com/mcci-catena/arduino-lmic#pin-mapping
// Has been tested successfully with ESP32 TTGO LoRa32 V1, and might work with other ESP32+LoRa boards.
const lmic_pinmap *pPinMap = Arduino_LMIC::GetPinmap_ThisBoard();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment