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