Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of XBeeLib by
AtCmdFrame.h
00001 /** 00002 * Copyright (c) 2015 Digi International Inc., 00003 * All rights not expressly granted are reserved. 00004 * 00005 * This Source Code Form is subject to the terms of the Mozilla Public 00006 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 00007 * You can obtain one at http://mozilla.org/MPL/2.0/. 00008 * 00009 * Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343 00010 * ======================================================================= 00011 */ 00012 00013 #if !defined(__AT_CMD_FRAME_H_) 00014 #define __AT_CMD_FRAME_H_ 00015 00016 #include "ApiFrame.h" 00017 00018 #define REM_AT_CMD_RESP_FRM_ID_OFFSET 0 00019 #define REM_AT_CMD_RESP_STATUS_OFFSET 13 00020 #define REM_AT_CMD_RESP_CMD_DATA_OFFSET 14 00021 #define REM_AT_CMD_RESP_OVERHEAD 14 /* ID + ADDR64 + ADDR16 + CMD + status */ 00022 00023 #define ATCMD_RESP_FRAME_ID_OFFSET 0 00024 #define ATCMD_RESP_CMD_LOW_OFFSET 1 00025 #define ATCMD_RESP_CMD_HIGH_OFFSET 2 00026 #define ATCMD_RESP_STATUS_OFFSET 3 00027 #define ATCMD_RESP_DATA_OFFSET 4 00028 #define ATCMD_RESP_NW_ADDR_H_OFFSET 4 00029 #define ATCMD_RESP_NW_ADDR_L_OFFSET 5 00030 #define ATCMD_RESP_SH_ADDR_L_OFFSET 6 00031 #define ATCMD_RESP_SH_ADDR_H_OFFSET 10 00032 #define ATCMD_RESP_NI_OFFSET 14 00033 00034 #define ATCMD_RESP_OVERHEAD 4 /* ID + CMD + status */ 00035 00036 #define ATCMD_802_RESP_SIGN_STR_OFFSET 14 00037 #define ATCMD_802_RESP_NI_OFFSET 15 00038 00039 #define MAX_NI_PARAM_LEN 20 00040 00041 /** Class for the AT command api frames. Derived from ApiFrame */ 00042 class AtCmdFrame : public ApiFrame 00043 { 00044 public: 00045 00046 /** 00047 * AtCmdResp 00048 */ 00049 enum AtCmdResp { 00050 AtCmdRespOk = 0, /**< Ok */ 00051 AtCmdRespError = 1, /**< Error */ 00052 AtCmdRespInvalidCmd = 2, /**< Invalid Command */ 00053 AtCmdRespInvalidParam = 3, /**< Invalid Parameter */ 00054 AtCmdRespTxFailure = 4, /**< Tx Failure */ 00055 AtCmdRespLenMismatch = 0xfd, /**< Length Mismatch (Error generated by the library) */ 00056 AtCmdRespInvalidAddr = 0xfe, /**< Invalid Address (Error generated by the library) */ 00057 AtCmdRespTimeout = 0xff, /**< Timeout (Error generated by the library) */ 00058 }; 00059 00060 /** 00061 * ModemStatus 00062 */ 00063 enum ModemStatus { 00064 HwReset = 0, /**< Hardware reset */ 00065 WdReset = 1, /**< Watchdog timer reset */ 00066 JoinedNW = 2, /**< Joined network (routers and end devices) */ 00067 Disassociated = 3, /**< Disassociated */ 00068 SyncLost = 4, /**< Synchronization Lost */ 00069 CoordRealign = 5, /**< Coordinator realignment */ 00070 CoordStarted = 6, /**< Coordinator started */ 00071 NwSecKeyUpdated = 7, /**< Network security key was updated */ 00072 NwWokeUp = 0x0B, /**< NwWokeUp */ 00073 NwToSleep = 0x0C, /**< NwToSleep */ 00074 VccExceeded = 0x0D, /**< VccExceeded: PRO S2B only? */ 00075 ModConfChangeJoinInProg = 0x11, /**< Modem configuration changed while join in progress */ 00076 }; 00077 00078 /** Class constructor 00079 * 00080 * @param cmd at command of the frame 00081 * @param cmd_param command parameter 00082 * @param param_len length of the command param 00083 */ 00084 AtCmdFrame(const char * const cmd, const uint32_t cmd_param); 00085 00086 /** Class constructor 00087 * 00088 * @param cmd at command of the frame 00089 * @param cmd_param pointer to command parameter 00090 * @param param_len length of the command param 00091 */ 00092 AtCmdFrame(const char * const cmd, const uint8_t * cmd_param = NULL, uint16_t param_len = 0); 00093 00094 /** Class constructor 00095 * 00096 * @param remote 64 bit address of the remote device where we want to run the command 00097 * @param cmd at command of the frame 00098 * @param cmd_param command parameter 00099 */ 00100 AtCmdFrame(uint64_t remote, const char * const cmd, uint32_t cmd_param); 00101 00102 /** Class constructor 00103 * 00104 * @param remote 64 bit address of the remote device where we want to run the command 00105 * @param cmd at command of the frame 00106 * @param cmd_param pointer to command parameter 00107 * @param param_len length of the command param 00108 */ 00109 AtCmdFrame(uint64_t remote, const char * const cmd, const uint8_t * cmd_param = NULL, uint16_t param_len = 0); 00110 00111 /** Class constructor 00112 * 00113 * @param remote 16 bit address of the remote device where we want to run the command 00114 * @param cmd at command of the frame 00115 * @param cmd_param command parameter 00116 */ 00117 AtCmdFrame(uint16_t remote, const char * const cmd, uint32_t cmd_param); 00118 00119 /** Class constructor 00120 * 00121 * @param remote 16 bit address of the remote device where we want to run the command 00122 * @param cmd at command of the frame 00123 * @param cmd_param pointer to command parameter 00124 * @param param_len length of the command param 00125 */ 00126 AtCmdFrame(uint16_t remote, const char * const cmd, const uint8_t * cmd_param = NULL, uint16_t param_len = 0); 00127 00128 /** Class constructor 00129 * 00130 * @param remote 64 bit address of the remote device where we want to run the command 00131 * @param remote 16 bit address of the remote device where we want to run the command 00132 * @param cmd at command of the frame 00133 * @param cmd_param command parameter 00134 */ 00135 AtCmdFrame(uint64_t remote64, uint16_t remote16, const char * const cmd, uint32_t cmd_param); 00136 00137 /** Class constructor 00138 * 00139 * @param remote 64 bit address of the remote device where we want to run the command 00140 * @param remote 16 bit address of the remote device where we want to run the command 00141 * @param cmd at command of the frame 00142 * @param cmd_param pointer to command parameter 00143 * @param param_len length of the command param 00144 */ 00145 AtCmdFrame(uint64_t remote64, uint16_t remote16, const char * const cmd, const uint8_t * cmd_param = NULL, uint16_t param_len = 0); 00146 00147 protected: 00148 /** build_at_cmd_frame method used by the constructors to create the at command frame 00149 * 00150 * @param cmd at command of the frame 00151 * @param cmd_params pointer to command parameter 00152 * @param param_len length of the command param 00153 */ 00154 void build_at_cmd_frame(const char *cmd, const uint8_t *cmd_params, uint8_t payload_len, bool reverse = true); 00155 00156 /** build_at_cmd_remote_frame method used by the constructors to create the at command frame 00157 * 00158 * @param remote64 64 bit address of the remote device where we want to run the command 00159 * @param remote16 16 bit address of the remote device where we want to run the command 00160 * @param cmd at command of the frame 00161 * @param cmd_params pointer to command parameter 00162 * @param param_len length of the command param 00163 */ 00164 void build_at_cmd_remote_frame(uint64_t remote64, uint16_t remote16, 00165 const char *const cmd, const uint8_t *const cmd_params, uint8_t payload_len, bool reverse = true); 00166 }; 00167 00168 #endif /* __AT_CMD_FRAME_H_ */
Generated on Tue Jul 12 2022 20:40:23 by
