@@ -380,12 +380,12 @@ int pgmstrcmp(const char *str1, uint8_t str2Index, uint8_t table = CMP_TABLE)
380
380
381
381
switch (table) {
382
382
case CMP_ERR_TABLE:
383
- strcpy_P (str2, (char *)pgm_read_word (&(compareerr_table[str2Index])));
383
+ strcpy_P (str2, (char *)pgm_read_dword (&(compareerr_table[str2Index])));
384
384
break ;
385
385
386
386
default :
387
387
case CMP_TABLE:
388
- strcpy_P (str2, (char *)pgm_read_word (&(compare_table[str2Index])));
388
+ strcpy_P (str2, (char *)pgm_read_dword (&(compare_table[str2Index])));
389
389
}
390
390
391
391
return memcmp (str1, str2, min (strlen (str1), strlen (str2)));
@@ -603,7 +603,7 @@ ttn_response_code_t TheThingsNetwork::getLastError(){
603
603
void TheThingsNetwork::debugPrintIndex (uint8_t index, const char *value)
604
604
{
605
605
char message[100 ];
606
- strcpy_P (message, (char *)pgm_read_word (&(show_table[index ])));
606
+ strcpy_P (message, (char *)pgm_read_dword (&(show_table[index ])));
607
607
debugPrint (message);
608
608
if (value)
609
609
{
@@ -617,10 +617,10 @@ void TheThingsNetwork::debugPrintMessage(uint8_t type, uint8_t index, const char
617
617
switch (type)
618
618
{
619
619
case ERR_MESSAGE:
620
- strcpy_P (message, (char *)pgm_read_word (&(error_msg[index ])));
620
+ strcpy_P (message, (char *)pgm_read_dword (&(error_msg[index ])));
621
621
break ;
622
622
case SUCCESS_MESSAGE:
623
- strcpy_P (message, (char *)pgm_read_word (&(success_msg[index ])));
623
+ strcpy_P (message, (char *)pgm_read_dword (&(success_msg[index ])));
624
624
break ;
625
625
}
626
626
debugPrint (message);
@@ -1088,19 +1088,21 @@ bool TheThingsNetwork::checkValidModuleConnected(bool autoBaudFirst)
1088
1088
}
1089
1089
// buffer contains "RN2xx3[xx] x.x.x ...", getting only model (RN2xx3[xx])
1090
1090
char *model = strtok (buffer, " " );
1091
- debugPrintIndex (SHOW_MODEL, model);
1092
- // check if module is valid (must be RN2483, RN2483A, RN2903, RN2903AS or SAMR34)
1093
- if (pgmstrcmp (model, CMP_RN2483) == 0 || pgmstrcmp (model, CMP_RN2483A) == 0 || pgmstrcmp (model, CMP_RN2903) == 0 || pgmstrcmp (model, CMP_RN2903AS) == 0 )
1094
- {
1095
- setModemType (TTN_MODEM_TYPE_RN);
1096
- debugPrintMessage (SUCCESS_MESSAGE, SCS_VALID_MODULE);
1097
- return true ; // module responded and is valid (recognized/supported)
1098
- }
1099
- else if (pgmstrcmp (model, CMP_SAMR34) == 0 )
1100
- {
1101
- setModemType (TTN_MODEM_TYPE_SAMR34);
1102
- debugPrintMessage (SUCCESS_MESSAGE, SCS_VALID_MODULE); // module responded and is valid (recognized/supported)
1103
- return true ;
1091
+ if (model != NULL ) {
1092
+ debugPrintIndex (SHOW_MODEL, model);
1093
+ // check if module is valid (must be RN2483, RN2483A, RN2903, RN2903AS or SAMR34)
1094
+ if (pgmstrcmp (model, CMP_RN2483) == 0 || pgmstrcmp (model, CMP_RN2483A) == 0 || pgmstrcmp (model, CMP_RN2903) == 0 || pgmstrcmp (model, CMP_RN2903AS) == 0 )
1095
+ {
1096
+ setModemType (TTN_MODEM_TYPE_RN);
1097
+ debugPrintMessage (SUCCESS_MESSAGE, SCS_VALID_MODULE);
1098
+ return true ; // module responded and is valid (recognized/supported)
1099
+ }
1100
+ else if (pgmstrcmp (model, CMP_SAMR34) == 0 )
1101
+ {
1102
+ setModemType (TTN_MODEM_TYPE_SAMR34);
1103
+ debugPrintMessage (SUCCESS_MESSAGE, SCS_VALID_MODULE); // module responded and is valid (recognized/supported)
1104
+ return true ;
1105
+ }
1104
1106
}
1105
1107
debugPrintMessage (ERR_MESSAGE, ERR_INVALID_MODULE);
1106
1108
return false ; // module responded but is invalid (unrecognized/unsupported)
@@ -1457,28 +1459,28 @@ void TheThingsNetwork::sendCommand(uint8_t table, uint8_t index, bool appendSpac
1457
1459
switch (table)
1458
1460
{
1459
1461
case MAC_TABLE:
1460
- strcpy_P (command, (char *)pgm_read_word (&(mac_table[index ])));
1462
+ strcpy_P (command, (char *)pgm_read_dword (&(mac_table[index ])));
1461
1463
break ;
1462
1464
case MAC_GET_SET_TABLE:
1463
- strcpy_P (command, (char *)pgm_read_word (&(mac_options[index ])));
1465
+ strcpy_P (command, (char *)pgm_read_dword (&(mac_options[index ])));
1464
1466
break ;
1465
1467
case MAC_JOIN_TABLE:
1466
- strcpy_P (command, (char *)pgm_read_word (&(mac_join_mode[index ])));
1468
+ strcpy_P (command, (char *)pgm_read_dword (&(mac_join_mode[index ])));
1467
1469
break ;
1468
1470
case MAC_CH_TABLE:
1469
- strcpy_P (command, (char *)pgm_read_word (&(mac_ch_options[index ])));
1471
+ strcpy_P (command, (char *)pgm_read_dword (&(mac_ch_options[index ])));
1470
1472
break ;
1471
1473
case MAC_TX_TABLE:
1472
- strcpy_P (command, (char *)pgm_read_word (&(mac_tx_table[index ])));
1474
+ strcpy_P (command, (char *)pgm_read_dword (&(mac_tx_table[index ])));
1473
1475
break ;
1474
1476
case SYS_TABLE:
1475
- strcpy_P (command, (char *)pgm_read_word (&(sys_table[index ])));
1477
+ strcpy_P (command, (char *)pgm_read_dword (&(sys_table[index ])));
1476
1478
break ;
1477
1479
case RADIO_TABLE:
1478
- strcpy_P (command, (char *)pgm_read_word (&(radio_table[index ])));
1480
+ strcpy_P (command, (char *)pgm_read_dword (&(radio_table[index ])));
1479
1481
break ;
1480
1482
case MAC_RESET_TABLE:
1481
- strcpy_P (command, (char *)pgm_read_word (&(mac_reset_table[index ])));
1483
+ strcpy_P (command, (char *)pgm_read_dword (&(mac_reset_table[index ])));
1482
1484
break ;
1483
1485
default :
1484
1486
return ;
0 commit comments