Put a bit of order in the src directory, group and name things appropriately

This commit is contained in:
Thomas Göttgens
2022-08-10 11:31:29 +02:00
parent 2c37be58ac
commit 5e842dd735
38 changed files with 1051 additions and 1052 deletions

View File

@@ -0,0 +1,7 @@
#pragma once
#define ARCH_RP2040
#if defined(PRIVATE_HW)
#define HW_VENDOR HardwareModel_PRIVATE_HW
#endif

View File

@@ -0,0 +1,30 @@
#include "configuration.h"
#include <stdio.h>
#include <pico/unique_id.h>
void setBluetoothEnable(bool on)
{
// not needed
}
void cpuDeepSleep(uint64_t msecs)
{
// not needed
}
void updateBatteryLevel(uint8_t level)
{
// not needed
}
void getMacAddr(uint8_t *dmac)
{
pico_unique_board_id_t src;
pico_get_unique_board_id(&src);
dmac[5] = src.id[0];
dmac[4] = src.id[1];
dmac[3] = src.id[2];
dmac[2] = src.id[3];
dmac[1] = src.id[4];
dmac[0] = src.id[5];
}

View File

@@ -0,0 +1,36 @@
#include "configuration.h"
#include "CryptoEngine.h"
#include "aes.hpp"
class RP2040CryptoEngine : public CryptoEngine
{
public:
RP2040CryptoEngine() {}
~RP2040CryptoEngine() {}
/**
* Encrypt a packet
*
* @param bytes is updated in place
*/
virtual void encrypt(uint32_t fromNode, uint64_t packetNum, size_t numBytes, uint8_t *bytes) override
{
if (key.length > 0) {
AES_ctx ctx;
initNonce(fromNode, packetNum);
AES_init_ctx_iv(&ctx, key.bytes, nonce);
AES_CTR_xcrypt_buffer(&ctx, bytes, numBytes);
}
}
virtual void decrypt(uint32_t fromNode, uint64_t packetNum, size_t numBytes, uint8_t *bytes) override
{
// For CTR, the implementation is the same
encrypt(fromNode, packetNum, numBytes, bytes);
}
private:
};
CryptoEngine *crypto = new RP2040CryptoEngine();