mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
gnrc/lorawan : Improve debugging
gnrc_lorawan.c, gnrc_lorawan_mlme.c : Add additional debug statements net/gnrc/lorawan/region.h : Added debug statements
This commit is contained in:
parent
874d7d15cb
commit
1a54238244
@ -185,12 +185,14 @@ void gnrc_lorawan_radio_rx_timeout_cb(gnrc_lorawan_t *mac)
|
||||
(void)mac;
|
||||
switch (mac->state) {
|
||||
case LORAWAN_STATE_RX_1:
|
||||
DEBUG("gnrc_lorawan: RX1 timeout.\n");
|
||||
_configure_rx_window(mac, LORAMAC_DEFAULT_RX2_FREQ,
|
||||
mac->dl_settings &
|
||||
GNRC_LORAWAN_DL_RX2_DR_MASK);
|
||||
mac->state = LORAWAN_STATE_RX_2;
|
||||
break;
|
||||
case LORAWAN_STATE_RX_2:
|
||||
DEBUG("gnrc_lorawan: RX2 timeout.\n");
|
||||
gnrc_lorawan_event_no_rx(mac);
|
||||
mac->state = LORAWAN_STATE_IDLE;
|
||||
break;
|
||||
@ -246,6 +248,8 @@ void gnrc_lorawan_send_pkt(gnrc_lorawan_t *mac, iolist_t *psdu, uint8_t dr)
|
||||
|
||||
uint32_t chan = gnrc_lorawan_pick_channel(mac);
|
||||
|
||||
DEBUG("gnrc_lorawan: Channel: %" PRIu32 "Hz \n", chan);
|
||||
|
||||
_config_radio(mac, chan, dr, false);
|
||||
|
||||
uint8_t cr;
|
||||
|
@ -15,6 +15,9 @@
|
||||
#include "kernel_defines.h"
|
||||
#include "net/gnrc/lorawan/region.h"
|
||||
|
||||
#define ENABLE_DEBUG (0)
|
||||
#include "debug.h"
|
||||
|
||||
#define GNRC_LORAWAN_DATARATES_NUMOF (6U)
|
||||
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
@ -33,6 +36,7 @@ int gnrc_lorawan_set_dr(gnrc_lorawan_t *mac, uint8_t datarate)
|
||||
if (!gnrc_lorawan_validate_dr(datarate)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
DEBUG("gnrc_lorawan_region: Data Rate: DR%u \n",datarate);
|
||||
uint8_t bw = dr_bw[datarate];
|
||||
uint8_t sf = dr_sf[datarate];
|
||||
|
||||
@ -45,12 +49,14 @@ int gnrc_lorawan_set_dr(gnrc_lorawan_t *mac, uint8_t datarate)
|
||||
#if (IS_ACTIVE(CONFIG_LORAMAC_REGION_EU_868))
|
||||
uint8_t gnrc_lorawan_rx1_get_dr_offset(uint8_t dr_up, uint8_t dr_offset)
|
||||
{
|
||||
DEBUG("gnrc_lorawan_region: RX1DRoffset: %u \n", dr_offset);
|
||||
return (dr_up > dr_offset) ? (dr_up - dr_offset) : 0;
|
||||
}
|
||||
|
||||
#elif (IS_ACTIVE(CONFIG_LORAMAC_REGION_IN_865))
|
||||
uint8_t gnrc_lorawan_rx1_get_dr_offset(uint8_t dr_up, uint8_t dr_offset)
|
||||
{
|
||||
DEBUG("gnrc_lorawan_region: RX1DRoffset: %u \n", dr_offset);
|
||||
int dr_eff = dr_offset > 5 ? 5 - dr_offset : dr_offset;
|
||||
return MIN(5, MAX(0, dr_up - dr_eff));
|
||||
}
|
||||
@ -87,6 +93,7 @@ void gnrc_lorawan_channels_init(gnrc_lorawan_t *mac)
|
||||
{
|
||||
for (unsigned i = 0; i < GNRC_LORAWAN_DEFAULT_CHANNELS_NUMOF; i++) {
|
||||
mac->channel[i] = gnrc_lorawan_default_channels[i];
|
||||
DEBUG("gnrc_lorawan_region: Mac -> Channel %u %" PRIu32 " \n", i, mac->channel[i]);
|
||||
}
|
||||
|
||||
for (unsigned i = GNRC_LORAWAN_DEFAULT_CHANNELS_NUMOF;
|
||||
@ -116,6 +123,7 @@ void gnrc_lorawan_process_cflist(gnrc_lorawan_t *mac, uint8_t *cflist)
|
||||
memcpy(&cl, cflist, GNRC_LORAWAN_CFLIST_ENTRY_SIZE);
|
||||
mac->channel[i] = byteorder_ntohl(byteorder_ltobl(cl)) * 100;
|
||||
cflist += GNRC_LORAWAN_CFLIST_ENTRY_SIZE;
|
||||
DEBUG("gnrc_lorawan_region: Mac -> Channel %u %" PRIu32 " \n", i, mac->channel[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -137,6 +145,7 @@ bool gnrc_lorawan_validate_dr(uint8_t dr)
|
||||
if (dr < GNRC_LORAWAN_DATARATES_NUMOF) {
|
||||
return true;
|
||||
}
|
||||
DEBUG("gnrc_lorawan_region: Invalid DR.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user