Skip to content

Commit eee53ec

Browse files
committed
Add AT+PORT command
1 parent ed493ce commit eee53ec

File tree

4 files changed

+50
-3
lines changed

4 files changed

+50
-3
lines changed

Projects/Multi/Applications/LoRa/AT_Slave/inc/at.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ typedef enum eATEerror
112112
#define AT_RECV "+RECV"
113113
#define AT_UTX "+UTX"
114114
#define AT_CTX "+CTX"
115+
#define AT_PORT "+PORT"
115116
#define AT_VER "+VER"
116117
#define AT_DEV "+DEV"
117118
#define AT_CFM "+CFM"
@@ -531,6 +532,20 @@ ATEerror_t at_Format_get(const char *param);
531532
*/
532533
ATEerror_t at_Format_set(const char *param);
533534

535+
/**
536+
* @brief Get application port in use
537+
* @param String parameter
538+
* @retval AT_OK if OK, or an appropriate AT_xxx error code
539+
*/
540+
ATEerror_t at_Port_get(const char *param);
541+
542+
/**
543+
* @brief Set application port
544+
* @param String parameter
545+
* @retval AT_OK if OK, or an appropriate AT_xxx error code
546+
*/
547+
ATEerror_t at_Port_set(const char *param);
548+
534549
/**
535550
* @brief Print last received data in binary format with hexadecimal value
536551
* @param String parameter

Projects/Multi/Applications/LoRa/AT_Slave/src/at.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,27 @@ ATEerror_t at_SendV2Confirmation(const char *param)
929929
return AT_OK;
930930
}
931931

932+
ATEerror_t at_Port_get(const char *param)
933+
{
934+
AT_PRINTF("+OK=");
935+
print_u(lora_config_application_port_get());
936+
937+
return AT_OK;
938+
}
939+
940+
ATEerror_t at_Port_set(const char *param)
941+
{
942+
uint8_t application_port;
943+
if (tiny_sscanf(param, "%hhu", &application_port) != 1)
944+
{
945+
return AT_PARAM_ERROR;
946+
}
947+
/* set the application port to send to */
948+
lora_config_application_port_set(application_port);
949+
950+
return AT_OK;
951+
}
952+
932953
ATEerror_t at_Format_get(const char *param)
933954
{
934955
AT_PRINTF("+OK=");

Projects/Multi/Applications/LoRa/AT_Slave/src/command.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,17 @@ static const struct ATCommand_s ATCommand[] =
441441
.run = at_Receive,
442442
},
443443

444+
{
445+
.string = AT_PORT,
446+
.size_string = sizeof(AT_PORT) - 1,
447+
#ifndef NO_HELP
448+
.help_string = "AT"AT_PORT ": set application port\r\n",
449+
#endif
450+
.get = at_Port_get,
451+
.set = at_Port_set,
452+
.run = at_return_error,
453+
},
454+
444455
{
445456
.string = AT_CTX,
446457
.size_string = sizeof(AT_CTX) - 1,

Projects/Multi/Applications/LoRa/AT_Slave/src/lora.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,9 @@ LoRaMacStatus_t lora_send(const char *buf, unsigned bufSize, unsigned binary, un
664664
return LORAMAC_STATUS_PARAMETER_INVALID;
665665
}
666666

667+
/* set the application port to send to */
668+
lora_config_application_port_set(appport);
669+
667670
/* skip the application port */
668671
while (('0' <= buf[0]) && (buf[0] <= '9'))
669672
{
@@ -720,9 +723,6 @@ LoRaMacStatus_t lora_send(const char *buf, unsigned bufSize, unsigned binary, un
720723
AppData.BuffSize = bufSize;
721724
}
722725

723-
/* set the application port to send to */
724-
lora_config_application_port_set(appport);
725-
726726
if( NextTx == true )
727727
{
728728
PrepareTxFrame( );

0 commit comments

Comments
 (0)