Skip to content

Commit

Permalink
optimize lora-radio-test-shell
Browse files Browse the repository at this point in the history
  • Loading branch information
Forest-Rain committed Oct 29, 2020
1 parent 974c5a8 commit 1a6a84a
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions samples/lora-radio-test-shell/lora-radio-test-shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ static bool lora_radio_test_init(void)
rt_thread_startup(lora_radio_test_thread);
}
else
LORA_RADIO_DEBUG_LOG(LR_DBG_APP, LOG_LEVEL, "lora radio test thread create failed!\n");
rt_kprintf("lora radio test thread create failed!\n");
}

/* Radio initialization */
Expand All @@ -264,7 +264,7 @@ static bool lora_radio_test_init(void)
}
else
{
LORA_RADIO_DEBUG_LOG(LR_DBG_APP, LOG_LEVEL, "lora radio Init failed!\n");
rt_kprintf("lora radio Init failed!\n");

return false;
}
Expand Down Expand Up @@ -342,9 +342,9 @@ static void lora_radio_test_thread_entry(void* parameter)
{
if( rx_only_flag == false )
{
LORA_RADIO_DEBUG_LOG(LR_DBG_APP, LOG_LEVEL, "Slaver Address(SA):[0x%X]",slaver_address);
rt_kprintf("Slaver Address(SA):[0x%X]",slaver_address);
}
LORA_RADIO_DEBUG_LOG(LR_DBG_APP, LOG_LEVEL, "Stay to Rx Continuous with freq=%d, SF=%d, CR=%d, BW=%d\n", lora_radio_test_paras.frequency, lora_radio_test_paras.sf, lora_radio_test_paras.cr, lora_radio_test_paras.bw);
rt_kprintf("Stay to Rx Continuous with freq=%d, SF=%d, CR=%d, BW=%d\n", lora_radio_test_paras.frequency, lora_radio_test_paras.sf, lora_radio_test_paras.cr, lora_radio_test_paras.bw);

Radio.Rx( 0 );
}
Expand Down Expand Up @@ -377,7 +377,7 @@ static void lora_radio_test_thread_entry(void* parameter)
received_seqno |= Buffer[11] << 16;
received_seqno |= Buffer[12] << 24;

LORA_RADIO_DEBUG_LOG(LR_DBG_APP, LOG_LEVEL, "Reply from [0x%X]:seqno=%d, bytes=%d,total time=%d ms,rssi=%d,snr=%d",slaver_addr, received_seqno, BufferSize,( rx_timestamp - tx_timestamp ),rssi_value,snr_value );
rt_kprintf("Reply from [0x%X]:seqno=%d, bytes=%d,total time=%d ms,rssi=%d,snr=%d",slaver_addr, received_seqno, BufferSize,( rx_timestamp - tx_timestamp ),rssi_value,snr_value );

/* Send the next PING frame */
rt_event_send(&radio_event, EV_RADIO_TX_START);
Expand All @@ -390,7 +390,7 @@ static void lora_radio_test_thread_entry(void* parameter)
}
else
{
LORA_RADIO_DEBUG_LOG(LR_DBG_APP, LOG_LEVEL, "RX ERR:BufferSize = 0");
rt_kprintf("RX ERR:BufferSize = 0");
}
}
else
Expand Down Expand Up @@ -424,7 +424,7 @@ static void lora_radio_test_thread_entry(void* parameter)
/* RX continuous */
Radio.Rx( 0 );

LORA_RADIO_DEBUG_LOG(LR_DBG_APP, LOG_LEVEL, "Received: Totals=%d,bytes=%d,timestamp=%d ms,rssi=%d,snr=%d",rx_correct_cnt, BufferSize,rx_timestamp,rssi_value,snr_value );
rt_kprintf("Received: Totals=%d,bytes=%d,timestamp=%d ms,rssi=%d,snr=%d",rx_correct_cnt, BufferSize,rx_timestamp,rssi_value,snr_value );

#ifdef RT_USING_ULOG
ulog_hexdump(LOG_TAG,16,Buffer,BufferSize);
Expand Down Expand Up @@ -457,7 +457,7 @@ static void lora_radio_test_thread_entry(void* parameter)
break;
case EV_RADIO_RX_TIMEOUT:
rx_timeout_cnt++;
LORA_RADIO_DEBUG_LOG(LR_DBG_APP, LOG_LEVEL, "Request [SA=0x%X] timed out: seqno=%d, time=%d ms", slaver_address, tx_seq_cnt, ( rx_timestamp - tx_timestamp ) );
rt_kprintf("Request [SA=0x%X] timed out: seqno=%d, time=%d ms", slaver_address, tx_seq_cnt, ( rx_timestamp - tx_timestamp ) );
case EV_RADIO_RX_ERROR:
case EV_RADIO_TX_START:
if( master_flag == true )
Expand All @@ -469,9 +469,9 @@ static void lora_radio_test_thread_entry(void* parameter)
if( !tx_seq_cnt )
{
uint32_t packet_toa = Radio.TimeOnAir(lora_radio_test_paras.modem,lora_radio_test_paras.bw,lora_radio_test_paras.sf,lora_radio_test_paras.cr,LORA_PREAMBLE_LENGTH, LORA_FIX_LENGTH_PAYLOAD_ON_DISABLE,payload_len,true);
LORA_RADIO_DEBUG_LOG(LR_DBG_APP, LOG_LEVEL, "Master Address(MA):[0x%X]",master_address);
LORA_RADIO_DEBUG_LOG(LR_DBG_APP, LOG_LEVEL, "Pinging [SA=0x%X] with %d bytes(ToA=%d ms) of data for %d counters:", slaver_address, payload_len, packet_toa, max_tx_nbtrials);
LORA_RADIO_DEBUG_LOG(LR_DBG_APP, LOG_LEVEL, "With radio parameters: freq=%d, TxPower=%d, SF=%d, CR=%d, BW=%d\n", lora_radio_test_paras.frequency, lora_radio_test_paras.txpower, lora_radio_test_paras.sf, lora_radio_test_paras.cr, lora_radio_test_paras.bw);
rt_kprintf("Master Address(MA):[0x%X]",master_address);
rt_kprintf("Pinging [SA=0x%X] with %d bytes(ToA=%d ms) of data for %d counters:", slaver_address, payload_len, packet_toa, max_tx_nbtrials);
rt_kprintf("With radio parameters: freq=%d, TxPower=%d, SF=%d, CR=%d, BW=%d\n", lora_radio_test_paras.frequency, lora_radio_test_paras.txpower, lora_radio_test_paras.sf, lora_radio_test_paras.cr, lora_radio_test_paras.bw);
}

send_ping_packet(master_address,slaver_address,payload_len);
Expand All @@ -495,12 +495,12 @@ static void lora_radio_test_thread_entry(void* parameter)
}
/* wait for PHY log output done */
rt_thread_mdelay(10);
LORA_RADIO_DEBUG_LOG(LR_DBG_APP, LOG_LEVEL, "\r\n====== LoRa Ping statistics for [MA=0x%X <-> SA=0x%X] with [TxPower=%d,SF=%d] ======",master_address, slaver_address, lora_radio_test_paras.txpower, lora_radio_test_paras.sf);
LORA_RADIO_DEBUG_LOG(LR_DBG_APP, LOG_LEVEL, "-> Tx pakcets: sent = %d, tx_total = %d.%d KByte",tx_seq_cnt, tx_total_kbyte_integer, tx_total_kbyte_decimal);
LORA_RADIO_DEBUG_LOG(LR_DBG_APP, LOG_LEVEL, "-> Rx pakcets: received = %d, lost = %d, per = %d%, rx_total = %d.%d KByte",rx_correct_cnt, rx_timeout_cnt + rx_error_cnt, per,rx_total_kbyte_integer,rx_total_kbyte_decimal);
LORA_RADIO_DEBUG_LOG(LR_DBG_APP, LOG_LEVEL, "--> Rx rssi: max_rssi = %d, min_rssi = %d, avg_rssi = %d",rssi_value_max,rssi_value_min,avg_rssi);
LORA_RADIO_DEBUG_LOG(LR_DBG_APP, LOG_LEVEL, "--> Rx snr: max_snr = %d, min_snr = %d, avg_snr = %d",snr_value_max,snr_value_min,avg_snr);
LORA_RADIO_DEBUG_LOG(LR_DBG_APP, LOG_LEVEL, "====== LoRa Ping Test Finished ======\r\n");
rt_kprintf("\r\n====== LoRa Ping statistics for [MA=0x%X <-> SA=0x%X] with [TxPower=%d,SF=%d] ======",master_address, slaver_address, lora_radio_test_paras.txpower, lora_radio_test_paras.sf);
rt_kprintf("-> Tx pakcets: sent = %d, tx_total = %d.%d KByte",tx_seq_cnt, tx_total_kbyte_integer, tx_total_kbyte_decimal);
rt_kprintf("-> Rx pakcets: received = %d, lost = %d, per = %d%, rx_total = %d.%d KByte",rx_correct_cnt, rx_timeout_cnt + rx_error_cnt, per,rx_total_kbyte_integer,rx_total_kbyte_decimal);
rt_kprintf("--> Rx rssi: max_rssi = %d, min_rssi = %d, avg_rssi = %d",rssi_value_max,rssi_value_min,avg_rssi);
rt_kprintf("--> Rx snr: max_snr = %d, min_snr = %d, avg_snr = %d",snr_value_max,snr_value_min,avg_snr);
rt_kprintf("====== LoRa Ping Test Finished ======\r\n");
}
}
else
Expand Down

0 comments on commit 1a6a84a

Please sign in to comment.