Skip to content

Commit

Permalink
Fix missing return value for ATC commands
Browse files Browse the repository at this point in the history
Add option to re-init LoRaWAN stack
  • Loading branch information
beegee-tokyo committed Oct 1, 2023
1 parent 9de41dd commit c237dd1
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Arduino library for RAKWireless WisBlock Core modules that takes all the LoRaWAN

# Release Notes

## 2.0.13 New feature/bug-fix
- Fix missing return value for ATC commands
- Add option to re-init LoRaWAN stack

## 2.0.12 New features & Fix more compatibility problems with latest WisToolBox version
- Give correct ATC+.... return instead of only AT+... for custom AT commands
- Add AT command for force OTA DFU mode on RAK4631
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1228,6 +1228,9 @@ AT Command functions: Taylor Lee ([email protected])
# Changelog
[Code releases](CHANGELOG.md)

- 2023-09-01 New feature/bug-fix
- Fix missing return value for ATC commands
- Add option to re-init LoRaWAN stack
- 2023-08-26 New features
- Add AT command for force OTA DFU mode on RAK4631
- Add re-initialize function for LoRaWAN (fix problem with confirmed msg NAK)
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.12",
"version": "2.0.13",
"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.12
version=2.0.13
author=Bernd Giesecke <[email protected]>
maintainer=Bernd Giesecke <[email protected]>
sentence=API for WisBlock Core module
Expand Down
2 changes: 1 addition & 1 deletion src/WisBlock-API-V2.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ extern String g_pw_sec;

// LoRa
int8_t init_lora(void);
int8_t init_lorawan(void);
int8_t init_lorawan(bool region_change = false);
int8_t re_init_lorawan(void);
bool send_p2p_packet(uint8_t *data, uint8_t size);
lmh_error_status send_lora_packet(uint8_t *data, uint8_t size, uint8_t fport = 0);
Expand Down
12 changes: 7 additions & 5 deletions src/at_cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ static int at_exec_p2p_send(char *str)
* @brief Set P2P RX mode
* 0 => TX mode, RX disabled
* 1 ... 65533 => Enable RX for xxxx milliseconds
* 65534 => Enable continous RX (restarts after TX)
* 65534 => Enable continuous RX (restarts after TX)
* 65535 => Enable RX until a packet was received, no timeout
* @return int AT_SUCCESS if no error, otherwise AT_ERRNO_NOALLOW, AT_ERRNO_PARA_VAL, AT_ERRNO_PARA_NUM
*/
Expand Down Expand Up @@ -669,10 +669,10 @@ static int at_exec_p2p_receive(char *str)
}
else if (rx_time == 65534)
{
// RX continous
// RX continuous
g_lora_p2p_rx_mode = RX_MODE_RX;
g_lora_p2p_rx_time = 0;
// Put Radio into continous RX mode
// Put Radio into continuous RX mode
Radio.Rx(0);
API_LOG("AT", "Set RX_MODE_RX");
}
Expand All @@ -681,7 +681,7 @@ static int at_exec_p2p_receive(char *str)
// RX until packet received
g_lora_p2p_rx_mode = RX_MODE_RX_WAIT;
g_lora_p2p_rx_time = 0;
// Put Radio into continous RX mode
// Put Radio into continuous RX mode
Radio.Rx(0);
API_LOG("AT", "Set RX_MODE_RX_WAIT");
}
Expand All @@ -690,7 +690,7 @@ static int at_exec_p2p_receive(char *str)
// RX for specific time
g_lora_p2p_rx_mode = RX_MODE_RX_TIMED;
g_lora_p2p_rx_time = rx_time;
// Put Radio into continous RX mode
// Put Radio into continuous RX mode
Radio.Rx(rx_time);
API_LOG("AT", "Set RX_MODE_RX_TIMED");
}
Expand Down Expand Up @@ -2634,6 +2634,8 @@ static void at_cmd_handle(void)
ret = g_user_at_cmd_list[j].exec_cmd(rxcmd + strlen(cmd_name) + 1);
if (ret == 0)
{
snprintf(atcmd, ATCMD_SIZE, "\nATC%s=%s",
cmd_name, g_at_query_buf);
snprintf(atcmd, ATCMD_SIZE, "\nOK");
snprintf(cmd_result, ATCMD_SIZE, " ");
}
Expand Down
4 changes: 2 additions & 2 deletions src/lorawan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ uint32_t otaaDevAddr = 0;
* -2 => LoRaWan MAC initialization failure
* -3 => Subband selection failure
*/
int8_t init_lorawan(void)
int8_t init_lorawan(bool region_change)
{
#ifdef ESP32
pinMode(WB_IO2, OUTPUT);
Expand Down Expand Up @@ -124,7 +124,7 @@ int8_t init_lorawan(void)

API_LOG("LORA", "Initialize LoRaWAN for region %s", region_names[g_lorawan_settings.lora_region]);
// Initialize LoRaWan
if (lmh_init(&lora_callbacks, lora_param_init, g_lorawan_settings.otaa_enabled, (eDeviceClass)g_lorawan_settings.lora_class, (LoRaMacRegion_t)g_lorawan_settings.lora_region) != 0)
if (lmh_init(&lora_callbacks, lora_param_init, g_lorawan_settings.otaa_enabled, (eDeviceClass)g_lorawan_settings.lora_class, (LoRaMacRegion_t)g_lorawan_settings.lora_region, region_change) != 0)
{
API_LOG("LORA", "Failed to initialize LoRaWAN");
return -2;
Expand Down

0 comments on commit c237dd1

Please sign in to comment.