mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-23 17:13:38 +00:00
Add meshtastic_Routing_Error_NO_CHANNEL
This commit is contained in:
parent
f3fa8daedf
commit
80fd121d87
@ -54,7 +54,7 @@ meshtastic_MeshPacket *MeshModule::allocAckNak(meshtastic_Routing_Error err, Nod
|
||||
p->to = to;
|
||||
p->decoded.request_id = idFrom;
|
||||
p->channel = chIndex;
|
||||
if (err != meshtastic_Routing_Error_NONE && err != meshtastic_Routing_Error_NONE_PKI)
|
||||
if (err != meshtastic_Routing_Error_NONE)
|
||||
LOG_WARN("Alloc an err=%d,to=0x%x,idFrom=0x%x,id=0x%x\n", err, to, idFrom, p->id);
|
||||
|
||||
return p;
|
||||
|
@ -461,9 +461,6 @@ meshtastic_Routing_Error perhapsEncode(meshtastic_MeshPacket *p)
|
||||
|
||||
ChannelIndex chIndex = p->channel; // keep as a local because we are about to change it
|
||||
auto hash = channels.setActiveByIndex(chIndex);
|
||||
if (hash < 0)
|
||||
// No suitable channel could be found for sending
|
||||
return meshtastic_Routing_Error_NO_CHANNEL;
|
||||
|
||||
// Now that we are encrypting the packet channel should be the hash (no longer the index)
|
||||
p->channel = hash;
|
||||
@ -480,11 +477,28 @@ meshtastic_Routing_Error perhapsEncode(meshtastic_MeshPacket *p)
|
||||
numbytes += 8;
|
||||
memcpy(p->encrypted.bytes, ScratchEncrypted, numbytes);
|
||||
p->channel = 0;
|
||||
p->pki_encrypted = true;
|
||||
} else {
|
||||
if (p->pki_encrypted == true) {
|
||||
// Client specifically requested PKI encryption
|
||||
return meshtastic_Routing_Error_PKI_FAILED;
|
||||
}
|
||||
if (hash < 0) {
|
||||
// No suitable channel could be found for sending
|
||||
return meshtastic_Routing_Error_NO_CHANNEL;
|
||||
}
|
||||
crypto->encryptPacket(getFrom(p), p->id, numbytes, bytes);
|
||||
memcpy(p->encrypted.bytes, bytes, numbytes);
|
||||
}
|
||||
#else
|
||||
if (p->pki_encrypted == true) {
|
||||
// Client specifically requested PKI encryption
|
||||
return meshtastic_Routing_Error_PKI_FAILED;
|
||||
}
|
||||
if (hash < 0) {
|
||||
// No suitable channel could be found for sending
|
||||
return meshtastic_Routing_Error_NO_CHANNEL;
|
||||
}
|
||||
crypto->encryptPacket(getFrom(p), p->id, numbytes, bytes);
|
||||
memcpy(p->encrypted.bytes, bytes, numbytes);
|
||||
#endif
|
||||
|
@ -301,8 +301,8 @@ typedef enum _meshtastic_Routing_Error {
|
||||
/* The application layer service on the remote node received your request, but considered your request not authorized
|
||||
(i.e you did not send the request on the required bound channel) */
|
||||
meshtastic_Routing_Error_NOT_AUTHORIZED = 33,
|
||||
/* This message is not a failure, and indicates that the message was sent via PKI */
|
||||
meshtastic_Routing_Error_NONE_PKI = 34
|
||||
/* The client specified a PKI transport, but the node was unable to send the packet using PKI (and did not send the message at all) */
|
||||
meshtastic_Routing_Error_PKI_FAILED = 34
|
||||
} meshtastic_Routing_Error;
|
||||
|
||||
/* The priority of this message for sending.
|
||||
@ -995,8 +995,8 @@ extern "C" {
|
||||
#define _meshtastic_Position_AltSource_ARRAYSIZE ((meshtastic_Position_AltSource)(meshtastic_Position_AltSource_ALT_BAROMETRIC+1))
|
||||
|
||||
#define _meshtastic_Routing_Error_MIN meshtastic_Routing_Error_NONE
|
||||
#define _meshtastic_Routing_Error_MAX meshtastic_Routing_Error_NONE_PKI
|
||||
#define _meshtastic_Routing_Error_ARRAYSIZE ((meshtastic_Routing_Error)(meshtastic_Routing_Error_NONE_PKI+1))
|
||||
#define _meshtastic_Routing_Error_MAX meshtastic_Routing_Error_PKI_FAILED
|
||||
#define _meshtastic_Routing_Error_ARRAYSIZE ((meshtastic_Routing_Error)(meshtastic_Routing_Error_PKI_FAILED+1))
|
||||
|
||||
#define _meshtastic_MeshPacket_Priority_MIN meshtastic_MeshPacket_Priority_UNSET
|
||||
#define _meshtastic_MeshPacket_Priority_MAX meshtastic_MeshPacket_Priority_MAX
|
||||
|
Loading…
Reference in New Issue
Block a user