5252#define RESP_SERVER_LOGIN_OK 0 // response to ANON_REQ
5353
5454#define ANON_REQ_TYPE_REGIONS 0x01
55+ #define ANON_REQ_TYPE_VER_OWNER 0x02
5556
5657#define CLI_REPLY_DELAY_MILLIS 600
5758
@@ -142,7 +143,7 @@ uint8_t MyMesh::handleLoginReq(const mesh::Identity& sender, const uint8_t* secr
142143}
143144
144145uint8_t MyMesh::handleAnonRegionsReq (const mesh::Identity& sender, uint32_t sender_timestamp, const uint8_t * data) {
145- if (regions_limiter .allow (rtc_clock.getCurrentTime ())) {
146+ if (anon_limiter .allow (rtc_clock.getCurrentTime ())) {
146147 // request data has: {reply-path-len}{reply-path}
147148 reply_path_len = *data++ & 0x3F ;
148149 memcpy (reply_path, data, reply_path_len);
@@ -159,6 +160,26 @@ uint8_t MyMesh::handleAnonRegionsReq(const mesh::Identity& sender, uint32_t send
159160 return 0 ;
160161}
161162
163+ uint8_t MyMesh::handleAnonVerOwnerReq (const mesh::Identity& sender, uint32_t sender_timestamp, const uint8_t * data) {
164+ if (anon_limiter.allow (rtc_clock.getCurrentTime ())) {
165+ // request data has: {reply-path-len}{reply-path}
166+ reply_path_len = *data++ & 0x3F ;
167+ memcpy (reply_path, data, reply_path_len);
168+ // data += reply_path_len;
169+ // other params??
170+
171+ memcpy (reply_data, &sender_timestamp, 4 ); // prefix with sender_timestamp, like a tag
172+
173+ uint32_t now = getRTCClock ()->getCurrentTime ();
174+ memcpy (&reply_data[4 ], &now, 4 ); // include our clock (for easy clock sync, if this is a trusted node)
175+
176+ sprintf ((char *) &reply_data[8 ], " %s,%s" , FIRMWARE_VERSION, _prefs.owner_info );
177+
178+ return 8 + strlen ((char *) &reply_data[8 ]); // reply length
179+ }
180+ return 0 ;
181+ }
182+
162183int MyMesh::handleRequest (ClientInfo *sender, uint32_t sender_timestamp, uint8_t *payload, size_t payload_len) {
163184 // uint32_t now = getRTCClock()->getCurrentTimeUnique();
164185 // memcpy(reply_data, &now, 4); // response packets always prefixed with timestamp
@@ -474,6 +495,8 @@ void MyMesh::onAnonDataRecv(mesh::Packet *packet, const uint8_t *secret, const m
474495 reply_len = handleLoginReq (sender, secret, timestamp, &data[4 ], packet->isRouteFlood ());
475496 } else if (data[4 ] == ANON_REQ_TYPE_REGIONS && packet->isRouteDirect ()) {
476497 reply_len = handleAnonRegionsReq (sender, timestamp, &data[5 ]);
498+ } else if (data[4 ] == ANON_REQ_TYPE_VER_OWNER && packet->isRouteDirect ()) {
499+ reply_len = handleAnonVerOwnerReq (sender, timestamp, &data[5 ]);
477500 } else {
478501 reply_len = 0 ; // unknown/invalid request type
479502 }
@@ -694,7 +717,7 @@ MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondCloc
694717 : mesh::Mesh(radio, ms, rng, rtc, *new StaticPoolPacketManager(32 ), tables),
695718 _cli(board, rtc, sensors, &_prefs, this ), telemetry(MAX_PACKET_PAYLOAD - 4 ), region_map(key_store), temp_map(key_store),
696719 discover_limiter(4 , 120 ), // max 4 every 2 minutes
697- regions_limiter (4 , 180 ) // max 4 every 3 minutes
720+ anon_limiter (4 , 180 ) // max 4 every 3 minutes
698721#if defined(WITH_RS232_BRIDGE)
699722 , bridge(&_prefs, WITH_RS232_BRIDGE, _mgr, &rtc)
700723#endif
0 commit comments