Skip to content

Commit 3326813

Browse files
committed
Changed pgm_read_dword to pgm_read_ptr so it works in both AVR and ESP32
1 parent ef877ff commit 3326813

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/TheThingsNetwork.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -380,12 +380,12 @@ int pgmstrcmp(const char *str1, uint8_t str2Index, uint8_t table = CMP_TABLE)
380380

381381
switch (table) {
382382
case CMP_ERR_TABLE:
383-
strcpy_P(str2, (char *)pgm_read_dword(&(compareerr_table[str2Index])));
383+
strcpy_P(str2, (char *)pgm_read_ptr(&(compareerr_table[str2Index])));
384384
break;
385385

386386
default:
387387
case CMP_TABLE:
388-
strcpy_P(str2, (char *)pgm_read_dword(&(compare_table[str2Index])));
388+
strcpy_P(str2, (char *)pgm_read_ptr(&(compare_table[str2Index])));
389389
}
390390

391391
return memcmp(str1, str2, min(strlen(str1), strlen(str2)));
@@ -603,7 +603,7 @@ ttn_response_code_t TheThingsNetwork::getLastError(){
603603
void TheThingsNetwork::debugPrintIndex(uint8_t index, const char *value)
604604
{
605605
char message[100];
606-
strcpy_P(message, (char *)pgm_read_dword(&(show_table[index])));
606+
strcpy_P(message, (char *)pgm_read_ptr(&(show_table[index])));
607607
debugPrint(message);
608608
if (value)
609609
{
@@ -617,10 +617,10 @@ void TheThingsNetwork::debugPrintMessage(uint8_t type, uint8_t index, const char
617617
switch (type)
618618
{
619619
case ERR_MESSAGE:
620-
strcpy_P(message, (char *)pgm_read_dword(&(error_msg[index])));
620+
strcpy_P(message, (char *)pgm_read_ptr(&(error_msg[index])));
621621
break;
622622
case SUCCESS_MESSAGE:
623-
strcpy_P(message, (char *)pgm_read_dword(&(success_msg[index])));
623+
strcpy_P(message, (char *)pgm_read_ptr(&(success_msg[index])));
624624
break;
625625
}
626626
debugPrint(message);
@@ -1459,28 +1459,28 @@ void TheThingsNetwork::sendCommand(uint8_t table, uint8_t index, bool appendSpac
14591459
switch (table)
14601460
{
14611461
case MAC_TABLE:
1462-
strcpy_P(command, (char *)pgm_read_dword(&(mac_table[index])));
1462+
strcpy_P(command, (char *)pgm_read_ptr(&(mac_table[index])));
14631463
break;
14641464
case MAC_GET_SET_TABLE:
1465-
strcpy_P(command, (char *)pgm_read_dword(&(mac_options[index])));
1465+
strcpy_P(command, (char *)pgm_read_ptr(&(mac_options[index])));
14661466
break;
14671467
case MAC_JOIN_TABLE:
1468-
strcpy_P(command, (char *)pgm_read_dword(&(mac_join_mode[index])));
1468+
strcpy_P(command, (char *)pgm_read_ptr(&(mac_join_mode[index])));
14691469
break;
14701470
case MAC_CH_TABLE:
1471-
strcpy_P(command, (char *)pgm_read_dword(&(mac_ch_options[index])));
1471+
strcpy_P(command, (char *)pgm_read_ptr(&(mac_ch_options[index])));
14721472
break;
14731473
case MAC_TX_TABLE:
1474-
strcpy_P(command, (char *)pgm_read_dword(&(mac_tx_table[index])));
1474+
strcpy_P(command, (char *)pgm_read_ptr(&(mac_tx_table[index])));
14751475
break;
14761476
case SYS_TABLE:
1477-
strcpy_P(command, (char *)pgm_read_dword(&(sys_table[index])));
1477+
strcpy_P(command, (char *)pgm_read_ptr(&(sys_table[index])));
14781478
break;
14791479
case RADIO_TABLE:
1480-
strcpy_P(command, (char *)pgm_read_dword(&(radio_table[index])));
1480+
strcpy_P(command, (char *)pgm_read_ptr(&(radio_table[index])));
14811481
break;
14821482
case MAC_RESET_TABLE:
1483-
strcpy_P(command, (char *)pgm_read_dword(&(mac_reset_table[index])));
1483+
strcpy_P(command, (char *)pgm_read_ptr(&(mac_reset_table[index])));
14841484
break;
14851485
default:
14861486
return;

0 commit comments

Comments
 (0)