Skip to content

Commit 52cc226

Browse files
committed
Added support for channel mask at cmd
1 parent a7759bb commit 52cc226

File tree

5 files changed

+28
-0
lines changed

5 files changed

+28
-0
lines changed

src/xbee_api_frames.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ typedef enum {
210210
XBEE_API_TYPE_LR_TX_REQUEST = 0x50, ///< Frame for transmitting data in LoRaWAN
211211
XBEE_API_TYPE_LR_RX_PACKET = 0xD0, ///< Frame for receiving data packets in LoRaWAN
212212
XBEE_API_TYPE_LR_EXPLICIT_RX_PACKET = 0xD1, ///< Frame for receiving explicitly addressed packets in LoRaWAN
213+
XBEE_API_TYPE_LR_EXPLICIT_TX_STATUS = 0xD2, ///< Frame for explicit TX status in LoRaWAN
213214

214215
/**< XBee 3 RF Specific API Frames */
215216
XBEE_API_TYPE_3RF_REMOTE_AT_COMMAND = 0x17, ///< Frame for sending remote AT commands (XBee 3 RF)

src/xbee_at_cmds.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ const char* atCommandToString(at_command_t command) {
153153
case AT_XD: return "XD"; ///< LoRaWAN RX2 Data Rate
154154
case AT_XF: return "XF"; ///< LoRaWAN RX2 Frequency
155155
case AT_PO: return "PO"; ///< LoRaWAN Transmit Power
156+
case AT_CM: return "CM"; ///< LoRaWAN Channels Mask
156157

157158
default: return NULL; ///< Unknown command
158159
}

src/xbee_at_cmds.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ typedef enum {
156156
AT_XD, /**< LoRaWAN RX2 Data Rate */
157157
AT_XF, /**< LoRaWAN RX2 Frequency */
158158
AT_PO, /**< LoRaWAN Transmit Power */
159+
AT_CM, /**< LoRaWAN Channels Mask */
159160

160161
// ... (other existing AT commands) ...
161162

src/xbee_lr.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,30 @@ bool XBeeLRGetDevEUI(XBee* self, uint8_t* responseBuffer, uint8_t buffer_size) {
657657
return true;
658658
}
659659

660+
661+
/**
662+
* @brief Sends the AT_CM command to set the LoRaWAN Channels Mask on the XBee LR module.
663+
*
664+
* This function configures the Channels Mask for the LoRaWAN network on the XBee LR module by
665+
* sending the AT_CM command. The Channels Mask specifies the sub-bands that are enabled for
666+
* communication. The function checks the command response to verify if the mask was successfully set.
667+
*
668+
* @param[in] self Pointer to the XBee instance.
669+
* @param[in] value Pointer to a null-terminated string representing the Channels Mask in hexadecimal format.
670+
*
671+
* @return bool Returns true if the Channels Mask was successfully set; otherwise, false.
672+
*/
673+
bool XBeeLRSetChannelsMask(XBee* self, const char* value) {
674+
uint8_t response[33];
675+
uint8_t responseLength;
676+
uint8_t paramLength = (value != NULL) ? strlen(value) : 0;
677+
int status = apiSendAtCommandAndGetResponse(self, AT_CM, value, paramLength, response, &responseLength, 5000);
678+
if(status != API_SEND_SUCCESS){
679+
XBEEDebugPrintEnabled("Failed to set Channels Mask\n");
680+
}
681+
return status;
682+
}
683+
660684
// XBeeLR private functions
661685

662686
/**

src/xbee_lr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ bool XBeeLRSetRX2Delay(XBee* self, const uint32_t value);
8888
bool XBeeLRSetRX2DataRate(XBee* self, const uint8_t value);
8989
bool XBeeLRSetRX2Frequency(XBee* self, const uint32_t value);
9090
bool XBeeLRSetTransmitPower(XBee* self, const uint8_t value);
91+
bool XBeeLRSetChannelsMask(XBee* self, const char* value);
9192

9293
#if defined(__cplusplus)
9394
}

0 commit comments

Comments
 (0)