Skip to content

Commit

Permalink
Improve RUI3 AT command compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
beegee-tokyo committed Jan 5, 2025
1 parent d18ba1e commit 25c1700
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1227,8 +1227,9 @@ AT Command functions: Taylor Lee ([email protected])
----
# Changelog
[Code releases](CHANGELOG.md)
- 2025-01-05 RUI3 AT command compatibility
- 2025-01-05 Improve RUI3 AT command compatibility
- Add AT+FIRMWAREVER command
- Add AT+SYNCWORD command
- 2024-10-17 AT command parsing and default fPort changes
- Allow upper and lower case and special characters in AT commands after the "="
- Change LoRaWAN default fPort from 0 to 1
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.21",
"version": "2.0.22",
"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.21
version=2.0.22
author=Bernd Giesecke <[email protected]>
maintainer=Bernd Giesecke <[email protected]>
sentence=API for WisBlock Core module
Expand Down
37 changes: 37 additions & 0 deletions src/at_cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1156,6 +1156,42 @@ static int at_exec_devaddr(char *str)
return AT_SUCCESS;
}

/**
* @brief AT+SYNCWORD=? Get device sync word
*
* @return int AT_SUCCESS if no error, otherwise AT_ERROR
*/
static int at_query_syncword(void)
{
uint16_t syncword = Radio.GetSyncWord();

snprintf(g_at_query_buf, ATQUERY_SIZE, "%04X", syncword);
return AT_SUCCESS;
}

/**
* @brief AT+SYNCWORD=<XXXX> Set device sync word
*
* @return int AT_SUCCESS if no error, otherwise AT_ERRNO_PARA_VAL
*/
static int at_exec_syncword(char *str)
{
uint8_t len;
uint8_t buf[9] = {0};

len = hex2bin(str, buf, 2);
if (len != 2)
{
return AT_ERRNO_PARA_VAL;
}

uint16_t syncword = (uint16_t)(buf[0] << 8) + (uint16_t)(buf[1]);

Radio.SetCustomSyncWord(syncword);

return AT_SUCCESS;
}

/**
* @brief AT+APPSKEY=? Get application session key
*
Expand Down Expand Up @@ -2361,6 +2397,7 @@ static atcmd_t g_at_cmd_list[] = {
{"+APPSKEY", "Get or set the application session key", at_query_appskey, at_exec_appskey, NULL, "RW"},
{"+NWKSKEY", "Get or Set the network session key", at_query_nwkskey, at_exec_nwkskey, NULL, "RW"},
{"+DEVADDR", "Get or set the device address", at_query_devaddr, at_exec_devaddr, NULL, "RW"},
{"+SYNCWORD", "Get or set the LoRaWAN sync word", at_query_syncword, at_exec_syncword, NULL, "RW"},
// Joining and sending data on LoRa network
{"+CFM", "Get or set the confirm mode", at_query_confirm, at_exec_confirm, NULL, "RW"},
{"+JOIN", "Join network", at_query_join, at_exec_join, NULL, "RW"},
Expand Down

0 comments on commit 25c1700

Please sign in to comment.