This commit is contained in:
2026-06-26 00:30:13 +02:00
commit b27cd76ca8
122 changed files with 37290 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
#include "ack.h"
#include "lib/cifra/sha2.h"
#include "lib/config.h"
#include "meshcore/meshframing.h"
#include <string.h>
#define TAG "Ack"
void sendDiscreteAck (uint8_t *data, const uint8_t len, uint8_t *senderPubKey) {
FrameStruct frame;
frame.path.pathLen = 0;
memset (&frame, 0, sizeof (frame));
// 1. Header
frame.header =
ROUTE_TYPE_FLOOD | // currently flood
PAYLOAD_TYPE_ACK |
PAYLOAD_VERSION_0;
// Buffer for the digest
uint8_t hash[CF_SHA256_HASHSZ];
// Context
cf_sha256_context ctx;
// 1. Initialize
cf_sha256_init (&ctx);
// 2. Feed in your data
cf_sha256_update (&ctx, data, len);
cf_sha256_update (&ctx, senderPubKey, sizeof (persistent.pubkey));
// 3. Compute digest
cf_sha256_digest (&ctx, hash);
memcpy (frame.payload, hash, 4);
// 5. Finalize
frame.payloadLen = 4;
LoRaTransmit (&frame);
}