fingers crossed

This commit is contained in:
Thomas Göttgens 2023-01-07 15:24:46 +01:00
parent 8465467aa8
commit d8b85f9a09
6 changed files with 25 additions and 17 deletions

View File

@ -549,10 +549,10 @@ AdminMessageHandleResult CannedMessageModule::handleAdminMessageForModule(const
void CannedMessageModule::handleGetCannedMessageModuleMessages(const MeshPacket &req, AdminMessage *response)
{
LOG_DEBUG("*** handleGetCannedMessageModuleMessages\n");
assert(req.decoded.want_response);
response->which_payload_variant = AdminMessage_get_canned_message_module_messages_response_tag;
strcpy(response->get_canned_message_module_messages_response, cannedMessageModuleConfig.messages);
if(req.decoded.want_response) {
response->which_payload_variant = AdminMessage_get_canned_message_module_messages_response_tag;
strcpy(response->get_canned_message_module_messages_response, cannedMessageModuleConfig.messages);
} // Don't send anything if not instructed to. Better than asserting.
}

View File

@ -347,10 +347,10 @@ AdminMessageHandleResult ExternalNotificationModule::handleAdminMessageForModule
void ExternalNotificationModule::handleGetRingtone(const MeshPacket &req, AdminMessage *response)
{
LOG_INFO("*** handleGetRingtone\n");
assert(req.decoded.want_response);
response->which_payload_variant = AdminMessage_get_ringtone_response_tag;
strcpy(response->get_ringtone_response, rtttlConfig.ringtone);
if(req.decoded.want_response) {
response->which_payload_variant = AdminMessage_get_ringtone_response_tag;
strcpy(response->get_ringtone_response, rtttlConfig.ringtone);
} // Don't send anything if not instructed to. Better than asserting.
}

View File

@ -392,7 +392,7 @@ bool StoreForwardModule::handleReceivedProtobuf(const MeshPacket &mp, StoreAndFo
break;
default:
assert(0); // unexpected state - FIXME, make an error code and reboot
assert(0); // unexpected state
}
return true; // There's no need for others to look at this message.
}

View File

@ -43,18 +43,21 @@ class ESP32CryptoEngine : public CryptoEngine
{
if (key.length > 0) {
uint8_t stream_block[16];
static uint8_t scratch[MAX_BLOCKSIZE];
size_t nc_off = 0;
LOG_DEBUG("ESP32 crypt fr=%x, num=%x, numBytes=%d!\n", fromNode, (uint32_t) packetId, numBytes);
initNonce(fromNode, packetId);
assert(numBytes <= MAX_BLOCKSIZE);
memcpy(scratch, bytes, numBytes);
memset(scratch + numBytes, 0,
if (numBytes <= MAX_BLOCKSIZE) {
static uint8_t scratch[MAX_BLOCKSIZE];
memcpy(scratch, bytes, numBytes);
memset(scratch + numBytes, 0,
sizeof(scratch) - numBytes); // Fill rest of buffer with zero (in case cypher looks at it)
auto res = mbedtls_aes_crypt_ctr(&aes, numBytes, &nc_off, nonce, stream_block, scratch, bytes);
assert(!res);
auto res = mbedtls_aes_crypt_ctr(&aes, numBytes, &nc_off, nonce, stream_block, scratch, bytes);
assert(!res);
} else {
LOG_ERROR("Packet too large for crypto engine: %d. noop encryption!\n", numBytes);
}
}
}

View File

@ -230,7 +230,12 @@ void SimRadio::handleReceiveInterrupt(MeshPacket *p)
{
LOG_DEBUG("HANDLE RECEIVE INTERRUPT\n");
uint32_t xmitMsec;
assert(isReceiving);
if (!isReceiving) {
LOG_DEBUG("*** WAS_ASSERT *** handleReceiveInterrupt called when not in receive mode\n");
return;
}
isReceiving = false;
// read the number of actually received bytes

View File

@ -163,7 +163,7 @@ static void waitEnterSleep()
}
// Code that still needs to be moved into notifyObservers
Serial.flush(); // send all our characters before we stop cpu clock
console->flush(); // send all our characters before we stop cpu clock
setBluetoothEnable(false); // has to be off before calling light sleep
notifySleep.notifyObservers(NULL);