fix(gfsk): improve fixed-packet receive reliability
Use a longer preamble and 32-bit detector for the 100 kbps fixed 6-byte GMSK profile. Read RX payloads from the RxStartBufferPointer returned by GetRxBufferStatus. The previous subtract-by-length adjustment could read the previous FIFO slot once the continuous RX buffer advanced, causing duplicate and missing packet IDs on the gateway.
This commit is contained in:
@@ -490,8 +490,8 @@ struct gfsk_parameters_t {
|
|||||||
},
|
},
|
||||||
.packet_params =
|
.packet_params =
|
||||||
{
|
{
|
||||||
.preamble_bits = 32,
|
.preamble_bits = 64,
|
||||||
.detector_length = GfskPreambleDetector::Bits16,
|
.detector_length = GfskPreambleDetector::Bits32,
|
||||||
.sync_length_bits = 32,
|
.sync_length_bits = 32,
|
||||||
.address_filtering = GfskAddressFiltering::Disabled,
|
.address_filtering = GfskAddressFiltering::Disabled,
|
||||||
.packet_length_mode = GfskPacketLengthMode::Fixed,
|
.packet_length_mode = GfskPacketLengthMode::Fixed,
|
||||||
@@ -1057,8 +1057,7 @@ namespace llcc68 = app::driver::llcc68;
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace std {
|
namespace std {
|
||||||
template <>
|
template <> struct is_error_code_enum<app::driver::llcc68::Errc> : true_type {};
|
||||||
struct is_error_code_enum<app::driver::llcc68::Errc> : true_type {};
|
|
||||||
} // namespace std
|
} // namespace std
|
||||||
|
|
||||||
#endif /* ECC594CF_EDF0_42B5_8518_0EB3B3583727 */
|
#endif /* ECC594CF_EDF0_42B5_8518_0EB3B3583727 */
|
||||||
|
|||||||
+10
-18
@@ -108,10 +108,10 @@ error_code LLCC68::init() {
|
|||||||
|
|
||||||
// Internal helpers (TU-local)
|
// Internal helpers (TU-local)
|
||||||
namespace {
|
namespace {
|
||||||
// Max payload the radio supports and buffer sizing helpers
|
// Max payload the radio supports and buffer sizing helpers
|
||||||
constexpr size_t kMaxPayload = 32;
|
constexpr size_t kMaxPayload = 32;
|
||||||
|
|
||||||
error_code command_status_to_error(status_t st) {
|
error_code command_status_to_error(status_t st) {
|
||||||
switch (st.command_status) {
|
switch (st.command_status) {
|
||||||
case CommandStatus::FAILURE_TO_EXECUTE_COMMAND:
|
case CommandStatus::FAILURE_TO_EXECUTE_COMMAND:
|
||||||
return make_error_code(Errc::FailureToExecuteCommand);
|
return make_error_code(Errc::FailureToExecuteCommand);
|
||||||
@@ -122,9 +122,9 @@ namespace {
|
|||||||
default:
|
default:
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int wait_for_not_busy(const gpio_dt_spec &busy_gpio, uint16_t timeout_ms) {
|
int wait_for_not_busy(const gpio_dt_spec &busy_gpio, uint16_t timeout_ms) {
|
||||||
if (not device_is_ready(busy_gpio.port)) {
|
if (not device_is_ready(busy_gpio.port)) {
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
@@ -136,7 +136,7 @@ namespace {
|
|||||||
k_busy_wait(50); // ~50 us poll interval
|
k_busy_wait(50); // ~50 us poll interval
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void LLCC68::tx_rx_en_pin_set(TxRxPinState state) {
|
void LLCC68::tx_rx_en_pin_set(TxRxPinState state) {
|
||||||
@@ -430,10 +430,7 @@ LLCC68::read_rx_buffer_ref(timeout_ms_t busy_timeout) {
|
|||||||
auto r = get_rx_buffer_status(busy_timeout);
|
auto r = get_rx_buffer_status(busy_timeout);
|
||||||
APP_RADIO_RETURN_ERR_IGNORE_PROC_ERR(r);
|
APP_RADIO_RETURN_ERR_IGNORE_PROC_ERR(r);
|
||||||
const auto [sz, ptr] = r.value();
|
const auto [sz, ptr] = r.value();
|
||||||
// the rx pointer would become 0x80 at first, so we need to adapt that
|
return read_buffer_ref(ptr, sz, busy_timeout);
|
||||||
// behavior
|
|
||||||
const auto r_ptr = ptr - sz < DEFAULT_RX_BUFFER_ADDRESS ? ptr : ptr - sz;
|
|
||||||
return read_buffer_ref(r_ptr, sz, busy_timeout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
expected<unit, error_code>
|
expected<unit, error_code>
|
||||||
@@ -631,14 +628,9 @@ expected<ChipType, error_code> LLCC68::hal_get_chip_type() {
|
|||||||
|
|
||||||
expected<unit, error_code> LLCC68::set_dio_irq_params(irq_params_t params) {
|
expected<unit, error_code> LLCC68::set_dio_irq_params(irq_params_t params) {
|
||||||
const uint8_t data[8] = {
|
const uint8_t data[8] = {
|
||||||
params.irqMask.msb(),
|
params.irqMask.msb(), params.irqMask.lsb(), params.dio1Mask.msb(),
|
||||||
params.irqMask.lsb(),
|
params.dio1Mask.lsb(), params.dio2Mask.msb(), params.dio2Mask.lsb(),
|
||||||
params.dio1Mask.msb(),
|
params.dio3Mask.msb(), params.dio3Mask.lsb(),
|
||||||
params.dio1Mask.lsb(),
|
|
||||||
params.dio2Mask.msb(),
|
|
||||||
params.dio2Mask.lsb(),
|
|
||||||
params.dio3Mask.msb(),
|
|
||||||
params.dio3Mask.lsb(),
|
|
||||||
};
|
};
|
||||||
return write_stream(RADIOLIB_SX126X_CMD_SET_DIO_IRQ_PARAMS, data);
|
return write_stream(RADIOLIB_SX126X_CMD_SET_DIO_IRQ_PARAMS, data);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user