Vergil Cola
/
MQTTGatewayK64
Fork of my MQTTGateway
XbeeMonitor/XBeeLib/Frames/AtCmdFrame.h@0:f1d3878b8dd9, 2017-04-08 (annotated)
- Committer:
- vpcola
- Date:
- Sat Apr 08 14:45:51 2017 +0000
- Revision:
- 0:f1d3878b8dd9
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
vpcola | 0:f1d3878b8dd9 | 1 | /** |
vpcola | 0:f1d3878b8dd9 | 2 | * Copyright (c) 2015 Digi International Inc., |
vpcola | 0:f1d3878b8dd9 | 3 | * All rights not expressly granted are reserved. |
vpcola | 0:f1d3878b8dd9 | 4 | * |
vpcola | 0:f1d3878b8dd9 | 5 | * This Source Code Form is subject to the terms of the Mozilla Public |
vpcola | 0:f1d3878b8dd9 | 6 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
vpcola | 0:f1d3878b8dd9 | 7 | * You can obtain one at http://mozilla.org/MPL/2.0/. |
vpcola | 0:f1d3878b8dd9 | 8 | * |
vpcola | 0:f1d3878b8dd9 | 9 | * Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343 |
vpcola | 0:f1d3878b8dd9 | 10 | * ======================================================================= |
vpcola | 0:f1d3878b8dd9 | 11 | */ |
vpcola | 0:f1d3878b8dd9 | 12 | |
vpcola | 0:f1d3878b8dd9 | 13 | #if !defined(__AT_CMD_FRAME_H_) |
vpcola | 0:f1d3878b8dd9 | 14 | #define __AT_CMD_FRAME_H_ |
vpcola | 0:f1d3878b8dd9 | 15 | |
vpcola | 0:f1d3878b8dd9 | 16 | #include "ApiFrame.h" |
vpcola | 0:f1d3878b8dd9 | 17 | |
vpcola | 0:f1d3878b8dd9 | 18 | #define REM_AT_CMD_RESP_FRM_ID_OFFSET 0 |
vpcola | 0:f1d3878b8dd9 | 19 | #define REM_AT_CMD_RESP_STATUS_OFFSET 13 |
vpcola | 0:f1d3878b8dd9 | 20 | #define REM_AT_CMD_RESP_CMD_DATA_OFFSET 14 |
vpcola | 0:f1d3878b8dd9 | 21 | #define REM_AT_CMD_RESP_OVERHEAD 14 /* ID + ADDR64 + ADDR16 + CMD + status */ |
vpcola | 0:f1d3878b8dd9 | 22 | |
vpcola | 0:f1d3878b8dd9 | 23 | #define ATCMD_RESP_FRAME_ID_OFFSET 0 |
vpcola | 0:f1d3878b8dd9 | 24 | #define ATCMD_RESP_CMD_LOW_OFFSET 1 |
vpcola | 0:f1d3878b8dd9 | 25 | #define ATCMD_RESP_CMD_HIGH_OFFSET 2 |
vpcola | 0:f1d3878b8dd9 | 26 | #define ATCMD_RESP_STATUS_OFFSET 3 |
vpcola | 0:f1d3878b8dd9 | 27 | #define ATCMD_RESP_DATA_OFFSET 4 |
vpcola | 0:f1d3878b8dd9 | 28 | #define ATCMD_RESP_NW_ADDR_H_OFFSET 4 |
vpcola | 0:f1d3878b8dd9 | 29 | #define ATCMD_RESP_NW_ADDR_L_OFFSET 5 |
vpcola | 0:f1d3878b8dd9 | 30 | #define ATCMD_RESP_SH_ADDR_L_OFFSET 6 |
vpcola | 0:f1d3878b8dd9 | 31 | #define ATCMD_RESP_SH_ADDR_H_OFFSET 10 |
vpcola | 0:f1d3878b8dd9 | 32 | #define ATCMD_RESP_NI_OFFSET 14 |
vpcola | 0:f1d3878b8dd9 | 33 | |
vpcola | 0:f1d3878b8dd9 | 34 | #define ATCMD_RESP_OVERHEAD 4 /* ID + CMD + status */ |
vpcola | 0:f1d3878b8dd9 | 35 | |
vpcola | 0:f1d3878b8dd9 | 36 | #define ATCMD_802_RESP_SIGN_STR_OFFSET 14 |
vpcola | 0:f1d3878b8dd9 | 37 | #define ATCMD_802_RESP_NI_OFFSET 15 |
vpcola | 0:f1d3878b8dd9 | 38 | |
vpcola | 0:f1d3878b8dd9 | 39 | #define MAX_NI_PARAM_LEN 20 |
vpcola | 0:f1d3878b8dd9 | 40 | |
vpcola | 0:f1d3878b8dd9 | 41 | /** Class for the AT command api frames. Derived from ApiFrame */ |
vpcola | 0:f1d3878b8dd9 | 42 | class AtCmdFrame : public ApiFrame |
vpcola | 0:f1d3878b8dd9 | 43 | { |
vpcola | 0:f1d3878b8dd9 | 44 | public: |
vpcola | 0:f1d3878b8dd9 | 45 | |
vpcola | 0:f1d3878b8dd9 | 46 | /** |
vpcola | 0:f1d3878b8dd9 | 47 | * AtCmdResp |
vpcola | 0:f1d3878b8dd9 | 48 | */ |
vpcola | 0:f1d3878b8dd9 | 49 | enum AtCmdResp { |
vpcola | 0:f1d3878b8dd9 | 50 | AtCmdRespOk = 0, /**< Ok */ |
vpcola | 0:f1d3878b8dd9 | 51 | AtCmdRespError = 1, /**< Error */ |
vpcola | 0:f1d3878b8dd9 | 52 | AtCmdRespInvalidCmd = 2, /**< Invalid Command */ |
vpcola | 0:f1d3878b8dd9 | 53 | AtCmdRespInvalidParam = 3, /**< Invalid Parameter */ |
vpcola | 0:f1d3878b8dd9 | 54 | AtCmdRespTxFailure = 4, /**< Tx Failure */ |
vpcola | 0:f1d3878b8dd9 | 55 | AtCmdRespLenMismatch = 0xfd, /**< Length Mismatch (Error generated by the library) */ |
vpcola | 0:f1d3878b8dd9 | 56 | AtCmdRespInvalidAddr = 0xfe, /**< Invalid Address (Error generated by the library) */ |
vpcola | 0:f1d3878b8dd9 | 57 | AtCmdRespTimeout = 0xff, /**< Timeout (Error generated by the library) */ |
vpcola | 0:f1d3878b8dd9 | 58 | }; |
vpcola | 0:f1d3878b8dd9 | 59 | |
vpcola | 0:f1d3878b8dd9 | 60 | /** |
vpcola | 0:f1d3878b8dd9 | 61 | * ModemStatus |
vpcola | 0:f1d3878b8dd9 | 62 | */ |
vpcola | 0:f1d3878b8dd9 | 63 | enum ModemStatus { |
vpcola | 0:f1d3878b8dd9 | 64 | HwReset = 0, /**< Hardware reset */ |
vpcola | 0:f1d3878b8dd9 | 65 | WdReset = 1, /**< Watchdog timer reset */ |
vpcola | 0:f1d3878b8dd9 | 66 | JoinedNW = 2, /**< Joined network (routers and end devices) */ |
vpcola | 0:f1d3878b8dd9 | 67 | Disassociated = 3, /**< Disassociated */ |
vpcola | 0:f1d3878b8dd9 | 68 | SyncLost = 4, /**< Synchronization Lost */ |
vpcola | 0:f1d3878b8dd9 | 69 | CoordRealign = 5, /**< Coordinator realignment */ |
vpcola | 0:f1d3878b8dd9 | 70 | CoordStarted = 6, /**< Coordinator started */ |
vpcola | 0:f1d3878b8dd9 | 71 | NwSecKeyUpdated = 7, /**< Network security key was updated */ |
vpcola | 0:f1d3878b8dd9 | 72 | NwWokeUp = 0x0B, /**< NwWokeUp */ |
vpcola | 0:f1d3878b8dd9 | 73 | NwToSleep = 0x0C, /**< NwToSleep */ |
vpcola | 0:f1d3878b8dd9 | 74 | VccExceeded = 0x0D, /**< VccExceeded: PRO S2B only? */ |
vpcola | 0:f1d3878b8dd9 | 75 | ModConfChangeJoinInProg = 0x11, /**< Modem configuration changed while join in progress */ |
vpcola | 0:f1d3878b8dd9 | 76 | }; |
vpcola | 0:f1d3878b8dd9 | 77 | |
vpcola | 0:f1d3878b8dd9 | 78 | /** Class constructor |
vpcola | 0:f1d3878b8dd9 | 79 | * |
vpcola | 0:f1d3878b8dd9 | 80 | * @param cmd at command of the frame |
vpcola | 0:f1d3878b8dd9 | 81 | * @param cmd_param command parameter |
vpcola | 0:f1d3878b8dd9 | 82 | * @param param_len length of the command param |
vpcola | 0:f1d3878b8dd9 | 83 | */ |
vpcola | 0:f1d3878b8dd9 | 84 | AtCmdFrame(const char * const cmd, const uint32_t cmd_param); |
vpcola | 0:f1d3878b8dd9 | 85 | |
vpcola | 0:f1d3878b8dd9 | 86 | /** Class constructor |
vpcola | 0:f1d3878b8dd9 | 87 | * |
vpcola | 0:f1d3878b8dd9 | 88 | * @param cmd at command of the frame |
vpcola | 0:f1d3878b8dd9 | 89 | * @param cmd_param pointer to command parameter |
vpcola | 0:f1d3878b8dd9 | 90 | * @param param_len length of the command param |
vpcola | 0:f1d3878b8dd9 | 91 | */ |
vpcola | 0:f1d3878b8dd9 | 92 | AtCmdFrame(const char * const cmd, const uint8_t * cmd_param = NULL, uint16_t param_len = 0); |
vpcola | 0:f1d3878b8dd9 | 93 | |
vpcola | 0:f1d3878b8dd9 | 94 | /** Class constructor |
vpcola | 0:f1d3878b8dd9 | 95 | * |
vpcola | 0:f1d3878b8dd9 | 96 | * @param remote 64 bit address of the remote device where we want to run the command |
vpcola | 0:f1d3878b8dd9 | 97 | * @param cmd at command of the frame |
vpcola | 0:f1d3878b8dd9 | 98 | * @param cmd_param command parameter |
vpcola | 0:f1d3878b8dd9 | 99 | */ |
vpcola | 0:f1d3878b8dd9 | 100 | AtCmdFrame(uint64_t remote, const char * const cmd, uint32_t cmd_param); |
vpcola | 0:f1d3878b8dd9 | 101 | |
vpcola | 0:f1d3878b8dd9 | 102 | /** Class constructor |
vpcola | 0:f1d3878b8dd9 | 103 | * |
vpcola | 0:f1d3878b8dd9 | 104 | * @param remote 64 bit address of the remote device where we want to run the command |
vpcola | 0:f1d3878b8dd9 | 105 | * @param cmd at command of the frame |
vpcola | 0:f1d3878b8dd9 | 106 | * @param cmd_param pointer to command parameter |
vpcola | 0:f1d3878b8dd9 | 107 | * @param param_len length of the command param |
vpcola | 0:f1d3878b8dd9 | 108 | */ |
vpcola | 0:f1d3878b8dd9 | 109 | AtCmdFrame(uint64_t remote, const char * const cmd, const uint8_t * cmd_param = NULL, uint16_t param_len = 0); |
vpcola | 0:f1d3878b8dd9 | 110 | |
vpcola | 0:f1d3878b8dd9 | 111 | /** Class constructor |
vpcola | 0:f1d3878b8dd9 | 112 | * |
vpcola | 0:f1d3878b8dd9 | 113 | * @param remote 16 bit address of the remote device where we want to run the command |
vpcola | 0:f1d3878b8dd9 | 114 | * @param cmd at command of the frame |
vpcola | 0:f1d3878b8dd9 | 115 | * @param cmd_param command parameter |
vpcola | 0:f1d3878b8dd9 | 116 | */ |
vpcola | 0:f1d3878b8dd9 | 117 | AtCmdFrame(uint16_t remote, const char * const cmd, uint32_t cmd_param); |
vpcola | 0:f1d3878b8dd9 | 118 | |
vpcola | 0:f1d3878b8dd9 | 119 | /** Class constructor |
vpcola | 0:f1d3878b8dd9 | 120 | * |
vpcola | 0:f1d3878b8dd9 | 121 | * @param remote 16 bit address of the remote device where we want to run the command |
vpcola | 0:f1d3878b8dd9 | 122 | * @param cmd at command of the frame |
vpcola | 0:f1d3878b8dd9 | 123 | * @param cmd_param pointer to command parameter |
vpcola | 0:f1d3878b8dd9 | 124 | * @param param_len length of the command param |
vpcola | 0:f1d3878b8dd9 | 125 | */ |
vpcola | 0:f1d3878b8dd9 | 126 | AtCmdFrame(uint16_t remote, const char * const cmd, const uint8_t * cmd_param = NULL, uint16_t param_len = 0); |
vpcola | 0:f1d3878b8dd9 | 127 | |
vpcola | 0:f1d3878b8dd9 | 128 | /** Class constructor |
vpcola | 0:f1d3878b8dd9 | 129 | * |
vpcola | 0:f1d3878b8dd9 | 130 | * @param remote 64 bit address of the remote device where we want to run the command |
vpcola | 0:f1d3878b8dd9 | 131 | * @param remote 16 bit address of the remote device where we want to run the command |
vpcola | 0:f1d3878b8dd9 | 132 | * @param cmd at command of the frame |
vpcola | 0:f1d3878b8dd9 | 133 | * @param cmd_param command parameter |
vpcola | 0:f1d3878b8dd9 | 134 | */ |
vpcola | 0:f1d3878b8dd9 | 135 | AtCmdFrame(uint64_t remote64, uint16_t remote16, const char * const cmd, uint32_t cmd_param); |
vpcola | 0:f1d3878b8dd9 | 136 | |
vpcola | 0:f1d3878b8dd9 | 137 | /** Class constructor |
vpcola | 0:f1d3878b8dd9 | 138 | * |
vpcola | 0:f1d3878b8dd9 | 139 | * @param remote 64 bit address of the remote device where we want to run the command |
vpcola | 0:f1d3878b8dd9 | 140 | * @param remote 16 bit address of the remote device where we want to run the command |
vpcola | 0:f1d3878b8dd9 | 141 | * @param cmd at command of the frame |
vpcola | 0:f1d3878b8dd9 | 142 | * @param cmd_param pointer to command parameter |
vpcola | 0:f1d3878b8dd9 | 143 | * @param param_len length of the command param |
vpcola | 0:f1d3878b8dd9 | 144 | */ |
vpcola | 0:f1d3878b8dd9 | 145 | AtCmdFrame(uint64_t remote64, uint16_t remote16, const char * const cmd, const uint8_t * cmd_param = NULL, uint16_t param_len = 0); |
vpcola | 0:f1d3878b8dd9 | 146 | |
vpcola | 0:f1d3878b8dd9 | 147 | protected: |
vpcola | 0:f1d3878b8dd9 | 148 | /** build_at_cmd_frame method used by the constructors to create the at command frame |
vpcola | 0:f1d3878b8dd9 | 149 | * |
vpcola | 0:f1d3878b8dd9 | 150 | * @param cmd at command of the frame |
vpcola | 0:f1d3878b8dd9 | 151 | * @param cmd_params pointer to command parameter |
vpcola | 0:f1d3878b8dd9 | 152 | * @param param_len length of the command param |
vpcola | 0:f1d3878b8dd9 | 153 | */ |
vpcola | 0:f1d3878b8dd9 | 154 | void build_at_cmd_frame(const char *cmd, const uint8_t *cmd_params, uint8_t payload_len, bool reverse = true); |
vpcola | 0:f1d3878b8dd9 | 155 | |
vpcola | 0:f1d3878b8dd9 | 156 | /** build_at_cmd_remote_frame method used by the constructors to create the at command frame |
vpcola | 0:f1d3878b8dd9 | 157 | * |
vpcola | 0:f1d3878b8dd9 | 158 | * @param remote64 64 bit address of the remote device where we want to run the command |
vpcola | 0:f1d3878b8dd9 | 159 | * @param remote16 16 bit address of the remote device where we want to run the command |
vpcola | 0:f1d3878b8dd9 | 160 | * @param cmd at command of the frame |
vpcola | 0:f1d3878b8dd9 | 161 | * @param cmd_params pointer to command parameter |
vpcola | 0:f1d3878b8dd9 | 162 | * @param param_len length of the command param |
vpcola | 0:f1d3878b8dd9 | 163 | */ |
vpcola | 0:f1d3878b8dd9 | 164 | void build_at_cmd_remote_frame(uint64_t remote64, uint16_t remote16, |
vpcola | 0:f1d3878b8dd9 | 165 | const char *const cmd, const uint8_t *const cmd_params, uint8_t payload_len, bool reverse = true); |
vpcola | 0:f1d3878b8dd9 | 166 | }; |
vpcola | 0:f1d3878b8dd9 | 167 | |
vpcola | 0:f1d3878b8dd9 | 168 | #endif /* __AT_CMD_FRAME_H_ */ |