Skip to content

Commit be68aae

Browse files
author
Scott Powell
committed
* simple_sensor: new REQ_TYPE_GET_ACCESS_LIST
1 parent 339ee03 commit be68aae

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

examples/simple_sensor/SensorMesh.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#define REQ_TYPE_KEEP_ALIVE 0x02
5252
#define REQ_TYPE_GET_TELEMETRY_DATA 0x03
5353
#define REQ_TYPE_GET_AVG_MIN_MAX 0x04
54+
#define REQ_TYPE_GET_ACCESS_LIST 0x05
5455

5556
#define RESP_SERVER_LOGIN_OK 0 // response to ANON_REQ
5657

@@ -286,6 +287,19 @@ uint8_t SensorMesh::handleRequest(uint16_t perms, uint32_t sender_timestamp, uin
286287
}
287288
return ofs;
288289
}
290+
if (req_type == REQ_TYPE_GET_ACCESS_LIST && (perms & PERM_IS_ADMIN) != 0) {
291+
uint8_t res1 = payload[0]; // reserved for future (extra query params)
292+
uint8_t res2 = payload[1];
293+
if (res1 == 0 && res2 == 0) {
294+
uint8_t ofs = 4;
295+
for (int i = 0; i < num_contacts && ofs + 8 <= sizeof(reply_data) - 4; i++) {
296+
auto c = &contacts[i];
297+
memcpy(&reply_data[ofs], c->id.pub_key, 6); ofs += 6; // just 6-byte pub_key prefix
298+
memcpy(&reply_data[ofs], &c->permissions, 2); ofs += 2;
299+
}
300+
return ofs;
301+
}
302+
}
289303
return 0; // unknown command
290304
}
291305

examples/simple_sensor/SensorMesh.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ struct ContactInfo {
5151

5252
#define FIRMWARE_ROLE "sensor"
5353

54-
#ifndef MAX_CONTACTS
55-
#define MAX_CONTACTS 32
56-
#endif
54+
#define MAX_CONTACTS 20
5755

5856
#define MAX_SEARCH_RESULTS 8
5957
#define MAX_CONCURRENT_ALERTS 4

0 commit comments

Comments
 (0)