|
55 | 55 | #define OT_REST_RESOURCE_PATH_NETWORK_CURRENT "/networks/current" |
56 | 56 | #define OT_REST_RESOURCE_PATH_NETWORK_CURRENT_COMMISSION "/networks/commission" |
57 | 57 | #define OT_REST_RESOURCE_PATH_NETWORK_CURRENT_PREFIX "/networks/current/prefix" |
| 58 | +#define OT_REST_RESOURCE_PATH_NODE_IPADDRESS "/node/ip-address" |
| 59 | +#define OT_REST_RESOURCE_PATH_NODE_IPADDRESS_MLEID "/node/ip-address/mleid" |
58 | 60 |
|
59 | 61 | #define OT_REST_HTTP_STATUS_200 "200 OK" |
60 | 62 | #define OT_REST_HTTP_STATUS_201 "201 Created" |
@@ -148,6 +150,7 @@ Resource::Resource(RcpHost *aHost) |
148 | 150 | mResourceMap.emplace(OT_REST_RESOURCE_PATH_NODE_RLOC, &Resource::Rloc); |
149 | 151 | mResourceMap.emplace(OT_REST_RESOURCE_PATH_NODE_DATASET_ACTIVE, &Resource::DatasetActive); |
150 | 152 | mResourceMap.emplace(OT_REST_RESOURCE_PATH_NODE_DATASET_PENDING, &Resource::DatasetPending); |
| 153 | + mResourceMap.emplace(OT_REST_RESOURCE_PATH_NODE_IPADDRESS_MLEID, &Resource::IpAddrMleid); |
151 | 154 | mResourceMap.emplace(OT_REST_RESOURCE_PATH_NODE_COMMISSIONER_STATE, &Resource::CommissionerState); |
152 | 155 | mResourceMap.emplace(OT_REST_RESOURCE_PATH_NODE_COMMISSIONER_JOINER, &Resource::CommissionerJoiner); |
153 | 156 | mResourceMap.emplace(OT_REST_RESOURCE_PATH_NODE_COPROCESSOR_VERSION, &Resource::CoprocessorVersion); |
@@ -1086,6 +1089,34 @@ void Resource::CoprocessorVersion(const Request &aRequest, Response &aResponse) |
1086 | 1089 | } |
1087 | 1090 | } |
1088 | 1091 |
|
| 1092 | +void Resource::GetIpAddrMleid(Response &aResponse) const |
| 1093 | +{ |
| 1094 | + std::string errorCode; |
| 1095 | + std::string mleidJsonString; |
| 1096 | + const otIp6Address *mleid; |
| 1097 | + |
| 1098 | + mleid = otThreadGetMeshLocalEid(mInstance); |
| 1099 | + |
| 1100 | + mleidJsonString = Json::IpAddr2JsonString(*mleid); |
| 1101 | + aResponse.SetBody(mleidJsonString); |
| 1102 | + errorCode = GetHttpStatus(HttpStatusCode::kStatusOk); |
| 1103 | + aResponse.SetResponsCode(errorCode); |
| 1104 | +} |
| 1105 | + |
| 1106 | +void Resource::IpAddrMleid(const Request &aRequest, Response &aResponse) const |
| 1107 | +{ |
| 1108 | + std::string errorCode; |
| 1109 | + |
| 1110 | + if (aRequest.GetMethod() == HttpMethod::kGet) |
| 1111 | + { |
| 1112 | + GetIpAddrMleid(aResponse); |
| 1113 | + } |
| 1114 | + else |
| 1115 | + { |
| 1116 | + ErrorHandler(aResponse, HttpStatusCode::kStatusMethodNotAllowed); |
| 1117 | + } |
| 1118 | +} |
| 1119 | + |
1089 | 1120 | void Resource::DeleteOutDatedDiagnostic(void) |
1090 | 1121 | { |
1091 | 1122 | auto eraseIt = mDiagSet.begin(); |
|
0 commit comments