Skip to content

Commit

Permalink
Add commands to directly modify channel mask
Browse files Browse the repository at this point in the history
  • Loading branch information
facchinm committed Oct 14, 2020
1 parent c5e3703 commit 735da6d
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ typedef enum eATEerror
#define AT_BTIME "+BTIME"
#define AT_BGW "+BGW"
#define AT_LTIME "+LTIME"
#define AT_CHANMASK "+CHANMASK"
#define AT_CHANDEFMASK "+CHANDEFMASK"

/* Exported functions ------------------------------------------------------- */

/**
Expand Down Expand Up @@ -639,6 +642,34 @@ ATEerror_t at_test_get_lora_config(const char *param);
*/
ATEerror_t at_Certif(const char *param);

/**
* @brief Gets the current region's channel mask, note this is reset when changing regions
* @param String parameter
* @retval AT_OK, or an appropriate AT_xxx error code
*/
ATEerror_t at_ChannelMask_get(const char *param);

/**
* @brief Sets the current region's channel mask, note this is reset when changing regions
* @param String parameter
* @retval AT_OK, or an appropriate AT_xxx error code
*/
ATEerror_t at_ChannelMask_set(const char *param);

/**
* @brief Gets the current region's default mask, note this is reset when changing regions
* @param String parameter
* @retval AT_OK, or an appropriate AT_xxx error code
*/
ATEerror_t at_ChannelDefaultMask_get(const char *param);

/**
* @brief Sets the current region's channel mask, note this is reset when changing regions
* @param String parameter
* @retval AT_OK, or an appropriate AT_xxx error code
*/
ATEerror_t at_ChannelDefaultMask_set(const char *param);

#ifdef __cplusplus
}
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1519,6 +1519,78 @@ ATEerror_t at_test_stop(const char *param)
{
return TST_stop();
}

ATEerror_t at_ChannelMask_get(const char *param)
{
MibRequestConfirm_t mib;
LoRaMacStatus_t status;

mib.Type = MIB_CHANNELS_MASK;
status = LoRaMacMibGetRequestConfirm(&mib);
CHECK_STATUS(status);
AT_PRINTF("%04x%04x%04x%04x%04x%04x\r\n",
mib.Param.ChannelsMask[0], mib.Param.ChannelsMask[1], mib.Param.ChannelsMask[2], mib.Param.ChannelsMask[3],
mib.Param.ChannelsMask[4], mib.Param.ChannelsMask[5]);

return AT_OK;
}

ATEerror_t at_ChannelMask_set(const char *param)
{
MibRequestConfirm_t mib;
LoRaMacStatus_t status;
uint16_t channelsMask[6];
mib.Type = MIB_CHANNELS_MASK;
mib.Param.ChannelsMask = channelsMask;
if (tiny_sscanf(param, "%04hx%04hx%04hx%04hx%04hx%04hx",
&channelsMask[0], &channelsMask[1], &channelsMask[2], &channelsMask[3],
&channelsMask[4], &channelsMask[5]) != 6)
{
return AT_PARAM_ERROR;
}
status = LoRaMacMibSetRequestConfirm(&mib);
CHECK_STATUS(status);

return AT_OK;
}

ATEerror_t at_ChannelDefaultMask_get(const char *param)
{
MibRequestConfirm_t mib;
LoRaMacStatus_t status;

mib.Type = MIB_CHANNELS_DEFAULT_MASK;
status = LoRaMacMibGetRequestConfirm(&mib);
CHECK_STATUS(status);
AT_PRINTF("%04x%04x%04x%04x%04x%04x\r\n",
mib.Param.ChannelsDefaultMask[0], mib.Param.ChannelsDefaultMask[1], mib.Param.ChannelsDefaultMask[2], mib.Param.ChannelsDefaultMask[3],
mib.Param.ChannelsDefaultMask[4], mib.Param.ChannelsDefaultMask[5]);

return AT_OK;
}

ATEerror_t at_ChannelDefaultMask_set(const char *param)
{
MibRequestConfirm_t mib;
LoRaMacStatus_t status;
uint16_t channelDefaultMask[6];
mib.Type = MIB_CHANNELS_DEFAULT_MASK;
mib.Param.ChannelsDefaultMask = channelDefaultMask;
if (tiny_sscanf(param, "%04hx%04hx%04hx%04hx%04hx%04hx",
&channelDefaultMask[0], &channelDefaultMask[1], &channelDefaultMask[2], &channelDefaultMask[3],
&channelDefaultMask[4], &channelDefaultMask[5]) != 6)
{
return AT_PARAM_ERROR;
}

status = LoRaMacMibSetRequestConfirm(&mib);
CHECK_STATUS(status);

return AT_OK;
}



/* Private functions ---------------------------------------------------------*/

static ATEerror_t translate_status(LoRaMacStatus_t status)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,28 @@ static const struct ATCommand_s ATCommand[] =
.run = at_Certif,
},

{
.string = AT_CHANMASK,
.size_string = sizeof(AT_CHANMASK) - 1,
#ifndef NO_HELP
.help_string = "AT"AT_CHANMASK ": Config the region's channel mask for the session\r\n",
#endif
.get = at_ChannelMask_get,
.set = at_ChannelMask_set,
.run = at_return_error,
},

{
.string = AT_CHANDEFMASK,
.size_string = sizeof(AT_CHANDEFMASK) - 1,
#ifndef NO_HELP
.help_string = "AT"AT_CHANDEFMASK ": Config the region's channel default mask for the session\r\n",
#endif
.get = at_ChannelDefaultMask_get,
.set = at_ChannelDefaultMask_set,
.run = at_return_error,
},

#ifdef LORAMAC_CLASSB_ENABLED
{
.string = AT_PGSLOT,
Expand Down

0 comments on commit 735da6d

Please sign in to comment.