samples: lora/receive: Added support for RSSI, SNR
Change to display RSSI and SNR values of the received data. This change helps to test LoRa's communication distance and communication quality. Signed-off-by: Kwon Tae-young <tykwon@m2i.co.kr>
This commit is contained in:
parent
c86d7ff320
commit
c88816cb6e
1 changed files with 6 additions and 2 deletions
|
@ -22,6 +22,8 @@ void main(void)
|
||||||
struct lora_modem_config config;
|
struct lora_modem_config config;
|
||||||
int ret, len;
|
int ret, len;
|
||||||
u8_t data[MAX_DATA_LEN] = {0};
|
u8_t data[MAX_DATA_LEN] = {0};
|
||||||
|
s16_t rssi;
|
||||||
|
s8_t snr;
|
||||||
|
|
||||||
lora_dev = device_get_binding(DT_INST_0_SEMTECH_SX1276_LABEL);
|
lora_dev = device_get_binding(DT_INST_0_SEMTECH_SX1276_LABEL);
|
||||||
if (!lora_dev) {
|
if (!lora_dev) {
|
||||||
|
@ -45,12 +47,14 @@ void main(void)
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
/* Block until data arrives */
|
/* Block until data arrives */
|
||||||
len = lora_recv(lora_dev, data, MAX_DATA_LEN, K_FOREVER);
|
len = lora_recv(lora_dev, data, MAX_DATA_LEN, K_FOREVER,
|
||||||
|
&rssi, &snr);
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
LOG_ERR("LoRa receive failed");
|
LOG_ERR("LoRa receive failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_INF("Received data: %s", log_strdup(data));
|
LOG_INF("Received data: %s (RSSI:%ddBm, SNR:%ddBm)",
|
||||||
|
log_strdup(data), rssi, snr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue