Text menu driven ANSI/VT100 console test utility for LoRa transceivers

radio chip selection

Radio chip driver is not included, allowing choice of radio device.
If you're using SX1272 or SX1276, then import sx127x driver into your program.
if you're using SX1261 or SX1262, then import sx126x driver into your program.
if you're using SX1280, then import sx1280 driver into your program.
if you're using LR1110, then import LR1110 driver into your program.
If you're using NAmote72 or Murata discovery, then you must import only sx127x driver.
If you're using Type1SJ select target DISCO_L072CZ_LRWAN1 and import sx126x driver into your program.

This is VT100 text-based menu driven test program for SX12xx transceiver devices.
Serial console is divided into horizontally into top half and bottom half.
The bottom half serves as scrolling area to log activity.
The top half serves as menu, to configure the radio.
For all devices, the serial console operates at 115200 8N1, and requires terminal with ANSI-VT100 capability, such as putty/teraterm/minicom etc.
Use program only with keyboard up/down/left/right keys. Enter to change an item, or number for value item. Some items are single bit, requiring only enter key to toggle. Others with fixed choices give a drop-down menu.

Revision:
2:ea9245bb1c53
Parent:
1:0817a150122b
Child:
3:56fc764dee0a
--- a/main.cpp	Mon Aug 20 18:13:09 2018 -0700
+++ b/main.cpp	Wed Aug 22 09:50:32 2018 -0700
@@ -81,15 +81,15 @@
 
 const button_item_t clearirqs_item = { _ITEM_BUTTON, "clearIrqs", clearIrqs_push };
 
-const dropdown_item_t pktType_item = { _ITEM_DROPDOWN, Radio::pktType_strs, Radio::pktType_strs, Radio::pktType_read_cb, Radio::pktType_write_cb};
+const dropdown_item_t pktType_item = { _ITEM_DROPDOWN, Radio::pktType_strs, Radio::pktType_strs, Radio::pktType_read, Radio::pktType_write};
 
 
-unsigned msgType_read_cb(bool fw)
+unsigned msgType_read(bool fw)
 {
     return msg_type;
 }
 
-menuMode_e msgType_write_cb(unsigned widx)
+menuMode_e msgType_write(unsigned widx)
 {
     msg_type = (msgType_e)widx;
 
@@ -114,7 +114,7 @@
     NULL
 };
 
-const dropdown_item_t msgType_item = { _ITEM_DROPDOWN, msgType_strs, msgType_strs, msgType_read_cb, msgType_write_cb };
+const dropdown_item_t msgType_item = { _ITEM_DROPDOWN, msgType_strs, msgType_strs, msgType_read, msgType_write};
 
 #define LAST_CHIP_MENU_ROW          (MAX_MENU_ROWS-5)
 
@@ -125,8 +125,6 @@
     uint8_t i, len = Radio::get_payload_length();
     for (i = 0; i < len; i++)
         Radio::radio.tx_buf[i] = get_pn9_byte();
-
-    //menuState.mode = MENUMODE_REDRAW;
 }
 
 const button_item_t tx_payload_pn9_item  = { _ITEM_BUTTON, "PN9", pn9_push };
@@ -170,7 +168,7 @@
 }
 const button_item_t rx_pkt_item  = { _ITEM_BUTTON, "RXPKT", rxpkt_push };
 
-const dropdown_item_t opmode_item = { _ITEM_DROPDOWN, Radio::opmode_status_strs, Radio::opmode_select_strs, Radio::opmode_read_cb, Radio::opmode_write_cb };
+const dropdown_item_t opmode_item = { _ITEM_DROPDOWN, Radio::opmode_status_strs, Radio::opmode_select_strs, Radio::opmode_read, Radio::opmode_write };
 
 void tx_carrier_push()
 {
@@ -245,7 +243,7 @@
     return false;
 }
 
-value_item_t per_ipd_item = { _ITEM_VALUE, 7, tx_ipd_print, tx_ipd_write };
+value_item_t per_ipd_item = { _ITEM_VALUE, 4, tx_ipd_print, tx_ipd_write };
 
 void numpkts_print()
 {
@@ -258,7 +256,7 @@
     return false;
 }
 
-value_item_t per_numpkts_item = { _ITEM_VALUE, 8, numpkts_print, numpkts_write };
+value_item_t per_numpkts_item = { _ITEM_VALUE, 6, numpkts_print, numpkts_write };
 
 void perrx_push()
 {
@@ -272,11 +270,22 @@
 
 const button_item_t perrx_item = { _ITEM_BUTTON, "PERRX", perrx_push };
 
+void per_reset_push()
+{
+    PacketRxSequencePrev = 0;
+    CntPacketRxKO = 0;
+    CntPacketRxOK = 0;
+    RxTimeOutCount = 0;
+}
+
+const button_item_t per_clear_item = { _ITEM_BUTTON, "resetCount", per_reset_push };
+
 const menu_t msg_per_menu[] = {
     { {LAST_CHIP_MENU_ROW+3,  1},          NULL,       &pertx_item, FLAG_MSGTYPE_PER },
-    { {LAST_CHIP_MENU_ROW+3,  10}, "TX IPD ms:",     &per_ipd_item, FLAG_MSGTYPE_PER },
-    { {LAST_CHIP_MENU_ROW+3,  35},   "numPkts:", &per_numpkts_item, FLAG_MSGTYPE_PER },
-    { {LAST_CHIP_MENU_ROW+3,  55},         NULL,       &perrx_item, FLAG_MSGTYPE_PER, &opmode_item },
+    { {LAST_CHIP_MENU_ROW+3,  12}, "TX IPD ms:",     &per_ipd_item, FLAG_MSGTYPE_PER },
+    { {LAST_CHIP_MENU_ROW+3,  26},   "numPkts:", &per_numpkts_item, FLAG_MSGTYPE_PER },
+    { {LAST_CHIP_MENU_ROW+3,  40},         NULL,       &perrx_item, FLAG_MSGTYPE_PER, &opmode_item },
+    { {LAST_CHIP_MENU_ROW+3,  50},         NULL,   &per_clear_item, FLAG_MSGTYPE_PER, &opmode_item },
     { {0, 0}, NULL, NULL }
 };
 
@@ -393,7 +402,7 @@
 
 const value_item_t Radio::tx_dbm_item = { _ITEM_VALUE, 7, Radio::tx_dbm_print, Radio::tx_dbm_write };
 
-const dropdown_item_t tx_ramp_item = { _ITEM_DROPDOWN, Radio::tx_ramp_strs, Radio::tx_ramp_strs, Radio::tx_ramp_read_cb, Radio::tx_ramp_write_cb };
+const dropdown_item_t tx_ramp_item = { _ITEM_DROPDOWN, Radio::tx_ramp_strs, Radio::tx_ramp_strs, Radio::tx_ramp_read, Radio::tx_ramp_write };
 
 const button_item_t chipNum_item = { _ITEM_BUTTON, Radio::chipNum_str, NULL};
 
@@ -585,10 +594,7 @@
 menu_init_(const menu_t* in, tablexy_t* tc)
 {
     unsigned n;
-    /*int current_table_row = INT_MAX;
-    int current_table_col = 0;*/
 
-    //for (n = 0; in[n].itemPtr != NULL; n++)
     for (n = 0; in[n].pos.row > 0; n++) {
         const menu_t* m = &in[n];
         if (tc->row != m->pos.row - 1) {