|
|
|
@ -336,22 +336,22 @@ void MyMesh::onAnonDataRecv(mesh::Packet *packet, const uint8_t *secret, const m |
|
|
|
memcpy(reply_data, &now, 4); // response packets always prefixed with timestamp
|
|
|
|
// TODO: maybe reply with count of messages waiting to be synced for THIS client?
|
|
|
|
reply_data[4] = RESP_SERVER_LOGIN_OK; |
|
|
|
reply_data[5] = FIRMWARE_VER_LEVEL; // Legacy: was recommended keep-alive interval (secs / 16)
|
|
|
|
reply_data[5] = 0; // Legacy: was recommended keep-alive interval (secs / 16)
|
|
|
|
reply_data[6] = (client->isAdmin() ? 1 : (client->permissions == 0 ? 2 : 0)); |
|
|
|
// LEGACY: reply_data[7] = getUnsyncedCount(client);
|
|
|
|
reply_data[7] = client->permissions; // NEW
|
|
|
|
getRNG()->random(&reply_data[8], 4); // random blob to help packet-hash uniqueness
|
|
|
|
// LEGACY: memcpy(&reply_data[8], "OK", 2);
|
|
|
|
reply_data[12] = FIRMWARE_VER_LEVEL; // New field
|
|
|
|
|
|
|
|
next_push = futureMillis(PUSH_NOTIFY_DELAY_MILLIS); // delay next push, give RESPONSE packet time to arrive first
|
|
|
|
|
|
|
|
if (packet->isRouteFlood()) { |
|
|
|
// let this sender know path TO here, so they can use sendDirect(), and ALSO encode the response
|
|
|
|
mesh::Packet *path = createPathReturn(sender, client->shared_secret, packet->path, packet->path_len, |
|
|
|
PAYLOAD_TYPE_RESPONSE, reply_data, 12); |
|
|
|
PAYLOAD_TYPE_RESPONSE, reply_data, 13); |
|
|
|
if (path) sendFlood(path, SERVER_RESPONSE_DELAY); |
|
|
|
} else { |
|
|
|
mesh::Packet *reply = createDatagram(PAYLOAD_TYPE_RESPONSE, sender, client->shared_secret, reply_data, 12); |
|
|
|
mesh::Packet *reply = createDatagram(PAYLOAD_TYPE_RESPONSE, sender, client->shared_secret, reply_data, 13); |
|
|
|
if (reply) { |
|
|
|
if (client->out_path_len >= 0) { // we have an out_path, so send DIRECT
|
|
|
|
sendDirect(reply, client->out_path, client->out_path_len, SERVER_RESPONSE_DELAY); |
|
|
|
|