revert mission timer to 32 bit, add signal level monitoring

This commit is contained in:
2025-05-05 09:01:52 +02:00
parent 0e7dfe61ab
commit bd599b43c8
4 changed files with 31 additions and 6 deletions

View File

@@ -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"

View File

@@ -29,6 +29,7 @@ void wifi_sniffer_packet_handler(void *buf, wifi_promiscuous_pkt_type_t type)
const wifi_promiscuous_pkt_t *ppkt = (wifi_promiscuous_pkt_t *)buf;
const uint8_t *payload = ppkt->payload;
uint32_t len = ppkt->rx_ctrl.sig_len + 44;
const int8_t rssi = ppkt->rx_ctrl.rssi;
// Simple PlecyC header check
if (len > 24 + 11 &&
@@ -44,7 +45,7 @@ void wifi_sniffer_packet_handler(void *buf, wifi_promiscuous_pkt_type_t type)
mbedtls_base64_encode(outBuf, sizeof(outBuf), &output_len, buf, len);
printf("\n the frame is %ld bytes long\n", len);
printf("\nGot 2400mhZ frame: %s\n", outBuf);
printf("\nGot 2400mhZ frame on %d: %s\n", rssi, outBuf);
// // Parse further as needed
// ESP_LOGI(TAG, "HEXko\n");
// ESP_LOG_BUFFER_HEXDUMP(TAG, buf, len, ESP_LOG_INFO);

View File

@@ -24,7 +24,7 @@ typedef struct __attribute__((packed))
char syncPhrase[10];
uint32_t packetIndex;
uint8_t packetType;
uint64_t missionTimer;
uint32_t missionTimer;
uint32_t CRCCheck;
} DownBoundPacket;

View File

@@ -7,6 +7,7 @@
#include "esp_timer.h"
#include "packets.h"
#include "esp_rom_crc.h"
#include "ctype.h"
#include "mbedtls/base64.h"
@@ -180,7 +181,28 @@ void printTelemetryPacket(const TelemetryPacket *packet)
ESP_LOGI(TAG, " TelemetryIndex: %d", packet->telemetryIndex);
}
void handle_downlink_packet(uint8_t *buf, uint8_t rxLen)
void hexdump(const void *data, size_t size) {
const unsigned char *byte = (const unsigned char *)data;
for (size_t i = 0; i < size; i += 16) {
printf("%08zx ", i); // print offset
// print hex bytes
for (size_t j = 0; j < 16; j++) {
if (i + j < size)
printf("%02x ", byte[i + j]);
else
printf(" ");
}
printf(" ");
// print ASCII representation
for (size_t j = 0; j < 16 && i + j < size; j++) {
unsigned char c = byte[i + j];
printf("%c", isprint(c) ? c : '.');
}
printf("\n");
}
}
void handle_downlink_packet(uint8_t *buf, uint8_t rxLen, int8_t rssi, int8_t snr)
{
if (rxLen < sizeof(DownBoundPacket))
{
@@ -205,6 +227,8 @@ void handle_downlink_packet(uint8_t *buf, uint8_t rxLen)
uint32_t crcCheck = esp_rom_crc32_le(0, payload, payloadSize);
hexdump(buf, rxLen);
if (crcCheck != down.CRCCheck)
{
ESP_LOGE(TAG, "Received BAD CRC for packet %ld, crc is %ld, should be %ld", down.packetIndex, crcCheck, down.CRCCheck);
@@ -215,7 +239,7 @@ void handle_downlink_packet(uint8_t *buf, uint8_t rxLen)
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);
printf("Got DownLink data L%d R%d S%d: %s\n", output_len, rssi, snr, outBuf);
switch (down.packetType)
{
@@ -299,7 +323,7 @@ void lora_comms_task(void *pvParameters)
GetPacketStatus(&rssi, &snr);
ESP_LOGI(TAG, "rssi=%d[dBm] snr=%d[dB]", rssi, snr);
handle_downlink_packet(bufIn, rxLen);
handle_downlink_packet(bufIn, rxLen, rssi, snr);
}
int lost = GetPacketLost();