Skip to content

Commit

Permalink
Add AT command for fPort setting
Browse files Browse the repository at this point in the history
  • Loading branch information
beegee-tokyo committed Apr 30, 2023
1 parent 8241958 commit 7e9b972
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Arduino library for RAKWireless WisBlock Core modules that takes all the LoRaWAN

# Release Notes

## 2.0.4 Add AT command
- Add AT command to change fPort when using LoRaWAN. Thanks to @xoseperez

## 2.0.3 Fix value overflow
- Fix value overflow in AT command AT+MASK
## 2.0.2 Fix P2P bandwidths
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1175,6 +1175,8 @@ AT Command functions: Taylor Lee ([email protected])
----
# Changelog
[Code releases](CHANGELOG.md)
- 2023-04-30
- Added option to set the LoRaWAN port using the AT command set. Thanks to @xoseperez
- 2023-04-07
- Fix value overflow in AT command AT+MASK
- 2023-03-18
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "WisBlock-API-V2",
"version": "2.0.3",
"version": "2.0.4",
"keywords": [
"lora",
"Semtech",
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=WisBlock-API-V2
version=2.0.3
version=2.0.4
author=Bernd Giesecke <[email protected]>
maintainer=Bernd Giesecke <[email protected]>
sentence=API for WisBlock Core module
Expand Down
41 changes: 40 additions & 1 deletion src/at_cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1507,6 +1507,44 @@ static int at_exec_adr(char *str)
return AT_SUCCESS;
}

/**
* @brief AT+PORT=? Get current port
*
* @return int
*/
static int at_query_port(void)
{
snprintf(g_at_query_buf, ATQUERY_SIZE, "%d", g_lorawan_settings.app_port);
return AT_SUCCESS;
}

/**
* @brief AT+PORT=X Set port
*
* @param str 1 to 224
* @return int 0 if correct parameter
*/
static int at_exec_port(char *str)
{
if (!g_lorawan_settings.lorawan_enable)
{
return AT_ERRNO_NOALLOW;
}
uint8_t port;

port = strtol(str, NULL, 0);

if ((port < 1) || (port > 223))
{
return AT_ERRNO_PARA_VAL;
}

g_lorawan_settings.app_port = port;
save_settings();

return AT_SUCCESS;
}

/**
* @brief AT+TXP=? Get current TX power setting
*
Expand Down Expand Up @@ -2176,6 +2214,7 @@ static atcmd_t g_at_cmd_list[] = {
// Custom AT commands
{"+STATUS", "Status, Show LoRaWAN status", at_query_status, NULL, NULL, "R"},
{"+SENDINT", "Send interval, Get or Set the automatic send interval", at_query_sendint, at_exec_sendint, NULL, "RW"},
{"+PORT", "Get or Set the Port=[1..223]", at_query_port, at_exec_port, NULL},
};
/**
Expand Down Expand Up @@ -2204,7 +2243,7 @@ static int at_exec_list_all(void)

for (unsigned int idx = 1; idx < sizeof(g_at_cmd_list) / sizeof(atcmd_t); idx++)
{
if ((strcmp(g_at_cmd_list[idx].cmd_name, (char *)"+STATUS") == 0) || (strcmp(g_at_cmd_list[idx].cmd_name, (char *)"+SENDINT") == 0))
if ((strcmp(g_at_cmd_list[idx].cmd_name, (char *)"+STATUS") == 0) || (strcmp(g_at_cmd_list[idx].cmd_name, (char *)"+SENDINT") == 0) || (strcmp(g_at_cmd_list[idx].cmd_name, (char *)"+PORT") == 0))
{
AT_PRINTF("ATC%s,%s: %s", g_at_cmd_list[idx].cmd_name, g_at_cmd_list[idx].permission, g_at_cmd_list[idx].cmd_desc);
}
Expand Down

0 comments on commit 7e9b972

Please sign in to comment.