@@ -256,8 +256,8 @@ void SensorMesh::sendAlert(const ClientInfo* c, Trigger* t) {
256256 mesh::Utils::sha256 ((uint8_t *)&t->expected_acks [t->attempt ], 4 , data, 5 + text_len, self_id.pub_key , PUB_KEY_SIZE );
257257 t->attempt ++;
258258
259- bool use_v2 = c->supports_chacha ;
260- auto pkt = createDatagram (PAYLOAD_TYPE_TXT_MSG , c->id , c->shared_secret , data, 5 + text_len, use_v2 );
259+ bool use_chacha = c->supports_chacha ;
260+ auto pkt = createDatagram (PAYLOAD_TYPE_TXT_MSG , c->id , c->shared_secret , data, 5 + text_len, use_chacha );
261261 if (pkt) {
262262 if (c->out_path_len >= 0 ) { // we have an out_path, so send DIRECT
263263 sendDirect (pkt, c->out_path , c->out_path_len );
@@ -465,14 +465,14 @@ void SensorMesh::onAnonDataRecv(mesh::Packet* packet, const uint8_t* secret, con
465465
466466 if (reply_len == 0 ) return ; // invalid request
467467
468- bool use_v2 = (packet-> getPayloadVer () == PAYLOAD_VER_2 );
468+ bool use_chacha = peerSupportsCHACHA (sender );
469469 if (packet->isRouteFlood ()) {
470470 // let this sender know path TO here, so they can use sendDirect(), and ALSO encode the response
471471 mesh::Packet* path = createPathReturn (sender, secret, packet->path , packet->path_len ,
472- PAYLOAD_TYPE_RESPONSE , reply_data, reply_len, use_v2 );
472+ PAYLOAD_TYPE_RESPONSE , reply_data, reply_len, use_chacha );
473473 if (path) sendFlood (path, SERVER_RESPONSE_DELAY );
474474 } else {
475- mesh::Packet* reply = createDatagram (PAYLOAD_TYPE_RESPONSE , sender, secret, reply_data, reply_len, use_v2 );
475+ mesh::Packet* reply = createDatagram (PAYLOAD_TYPE_RESPONSE , sender, secret, reply_data, reply_len, use_chacha );
476476 if (reply) sendFlood (reply, SERVER_RESPONSE_DELAY );
477477 }
478478 }
@@ -559,14 +559,14 @@ void SensorMesh::onPeerDataRecv(mesh::Packet* packet, uint8_t type, int sender_i
559559 from->last_timestamp = timestamp;
560560 from->last_activity = getRTCClock ()->getCurrentTime ();
561561
562- bool use_v2 = (packet-> getPayloadVer () == PAYLOAD_VER_2 ) ;
562+ bool use_chacha = from-> supports_chacha ;
563563 if (packet->isRouteFlood ()) {
564564 // let this sender know path TO here, so they can use sendDirect(), and ALSO encode the response
565565 mesh::Packet* path = createPathReturn (from->id , secret, packet->path , packet->path_len ,
566- PAYLOAD_TYPE_RESPONSE , reply_data, reply_len, use_v2 );
566+ PAYLOAD_TYPE_RESPONSE , reply_data, reply_len, use_chacha );
567567 if (path) sendFlood (path, SERVER_RESPONSE_DELAY );
568568 } else {
569- mesh::Packet* reply = createDatagram (PAYLOAD_TYPE_RESPONSE , from->id , secret, reply_data, reply_len, use_v2 );
569+ mesh::Packet* reply = createDatagram (PAYLOAD_TYPE_RESPONSE , from->id , secret, reply_data, reply_len, use_chacha );
570570 if (reply) {
571571 if (from->out_path_len >= 0 ) { // we have an out_path, so send DIRECT
572572 sendDirect (reply, from->out_path , from->out_path_len , SERVER_RESPONSE_DELAY );
@@ -592,9 +592,9 @@ void SensorMesh::onPeerDataRecv(mesh::Packet* packet, uint8_t type, int sender_i
592592
593593 if (packet->isRouteFlood ()) {
594594 // let this sender know path TO here, so they can use sendDirect(), and ALSO encode the ACK
595- bool use_v2 = (packet-> getPayloadVer () == PAYLOAD_VER_2 ) ;
595+ bool use_chacha = from-> supports_chacha ;
596596 mesh::Packet* path = createPathReturn (from->id , secret, packet->path , packet->path_len ,
597- PAYLOAD_TYPE_ACK , (uint8_t *) &ack_hash, 4 , use_v2 );
597+ PAYLOAD_TYPE_ACK , (uint8_t *) &ack_hash, 4 , use_chacha );
598598 if (path) sendFlood (path, TXT_ACK_DELAY );
599599 } else {
600600 sendAckTo (*from, ack_hash);
@@ -622,8 +622,8 @@ void SensorMesh::onPeerDataRecv(mesh::Packet* packet, uint8_t type, int sender_i
622622 memcpy (temp, ×tamp, 4 ); // mostly an extra blob to help make packet_hash unique
623623 temp[4 ] = (TXT_TYPE_CLI_DATA << 2 );
624624
625- bool use_v2 = (packet-> getPayloadVer () == PAYLOAD_VER_2 ) ;
626- auto reply = createDatagram (PAYLOAD_TYPE_TXT_MSG , from->id , secret, temp, 5 + text_len, use_v2 );
625+ bool use_chacha = from-> supports_chacha ;
626+ auto reply = createDatagram (PAYLOAD_TYPE_TXT_MSG , from->id , secret, temp, 5 + text_len, use_chacha );
627627 if (reply) {
628628 if (from->out_path_len < 0 ) {
629629 sendFlood (reply, CLI_REPLY_DELAY_MILLIS );
0 commit comments