From 9229711870a3c118bbb694699cfa63db978dda7a Mon Sep 17 00:00:00 2001 From: bruno Date: Mon, 28 Apr 2025 20:59:39 +0200 Subject: [PATCH] update --- .vscode/settings.json | 2 +- main/radio.c | 22 +++++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index b7c4a37..5f3816a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,6 @@ { "C_Cpp.intelliSenseEngine": "default", - "idf.espIdfPath": "/home/bruno/esp/master/esp-idf", + "idf.espIdfPath": "/home/bruno/esp/v5.4.1/esp-idf", "idf.pythonInstallPath": "/usr/bin/python", "idf.openOcdConfigs": [ "board/esp32s3-builtin.cfg" diff --git a/main/radio.c b/main/radio.c index 2e3d494..81c197a 100644 --- a/main/radio.c +++ b/main/radio.c @@ -8,6 +8,8 @@ #include "packets.h" #include "esp_rom_crc.h" +#include "mbedtls/base64.h" + #define TAG "LoRaGS" uint32_t uplinkPacketIndex = 0; @@ -145,7 +147,7 @@ void printTelemetryPacket(const TelemetryPacket *packet) // GPS Data ESP_LOGI(TAG, " GPS:"); - ESP_LOGI(TAG, " Time (seconds): %u", packet->time_seconds); + ESP_LOGI(TAG, " Time (seconds): %lu", packet->time_seconds); ESP_LOGI(TAG, " Latitude: %.4f°", packet->latitude_centi_degrees / 10000.0f); ESP_LOGI(TAG, " Longitude: %.4f°", packet->longitude_centi_degrees / 10000.0f); ESP_LOGI(TAG, " Altitude: %.2f m", packet->altitude_centi_meters / 100.0f); @@ -163,10 +165,10 @@ void printTelemetryPacket(const TelemetryPacket *packet) { // ADC Data ESP_LOGI(TAG, " ADC Sensors:"); - ESP_LOGI(TAG, " NH3: %d", packet->NH3); - ESP_LOGI(TAG, " CO: %d", packet->CO); - ESP_LOGI(TAG, " NO2: %d", packet->NO2); - ESP_LOGI(TAG, " UVC: %d", packet->UVC); + ESP_LOGI(TAG, " NH3: %ld", packet->NH3); + ESP_LOGI(TAG, " CO: %ld", packet->CO); + ESP_LOGI(TAG, " NO2: %ld", packet->NO2); + ESP_LOGI(TAG, " UVC: %ld", packet->UVC); } else { ESP_LOGE(TAG, " IO Expander not plugged in"); } @@ -205,10 +207,16 @@ void handle_downlink_packet(uint8_t *buf, uint8_t rxLen) if (crcCheck != down.CRCCheck) { - ESP_LOGE(TAG, "Received BAD CRC for packet %d, crc is %ld, should be %ld", down.packetIndex, crcCheck, down.CRCCheck); + ESP_LOGE(TAG, "Received BAD CRC for packet %ld, crc is %ld, should be %ld", down.packetIndex, crcCheck, down.CRCCheck); return; } + unsigned char outBuf[345]; + size_t output_len = 0; // will store the real output size + + mbedtls_base64_encode(outBuf, sizeof(outBuf), &output_len, buf, rxLen); + printf("Got DownLink data %d: %s\n", output_len, outBuf); + switch (down.packetType) { case DownlinkPacketType_Telemetry: @@ -221,7 +229,7 @@ void handle_downlink_packet(uint8_t *buf, uint8_t rxLen) } else { - ESP_LOGW(TAG, "Telemetry packet too small (%u bytes)", payloadSize); + ESP_LOGW(TAG, "Telemetry packet too small (%lu bytes)", payloadSize); } break; case DownlinkPacketType_Ping: