Skip to content

Commit 33d469f

Browse files
committed
Allow get config to work with older radio firmware
1 parent e9a8ab4 commit 33d469f

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

include/lora.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22

33
#include <stdbool.h>
4+
#include <stddef.h>
45
#include <stdint.h>
56
#include "driver/gpio.h"
67
#include "esp_err.h"
@@ -63,6 +64,8 @@ typedef struct {
6364
bool use_automatic_correction; // Enable automatic frequency correction
6465
} __attribute__((packed)) lora_protocol_config_params_t;
6566

67+
#define LORA_PROTOCOL_CONFIG_PARAMS_LEGACY_SIZE offsetof(lora_protocol_config_params_t, low_data_rate_optimization)
68+
6669
typedef struct {
6770
uint16_t errors;
6871
lora_protocol_chip_t chip_type;

lora.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ esp_err_t lora_get_config(lora_handle_t* handle, lora_protocol_config_params_t*
754754
if (result != ESP_OK) {
755755
return result;
756756
}
757-
if (response_length < sizeof(lora_protocol_header_t) + sizeof(lora_protocol_config_params_t)) {
757+
if (response_length < sizeof(lora_protocol_header_t) + LORA_PROTOCOL_CONFIG_PARAMS_LEGACY_SIZE) {
758758
ESP_LOGE(TAG, "Invalid response length: %u\r\n", response_length);
759759
return ESP_FAIL;
760760
}
@@ -767,6 +767,7 @@ esp_err_t lora_get_config(lora_handle_t* handle, lora_protocol_config_params_t*
767767
ESP_LOGE(TAG, "Invalid response type: %u\r\n", header->type);
768768
return ESP_FAIL;
769769
}
770+
770771
lora_protocol_config_params_t* params =
771772
(lora_protocol_config_params_t*)(response + sizeof(lora_protocol_header_t));
772773
memcpy(out_config, params, sizeof(lora_protocol_config_params_t));

0 commit comments

Comments
 (0)