temp sync broken
This commit is contained in:
106
User/main.c
106
User/main.c
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "ch32v30x_rng.h"
|
||||
#include "meshcore/meshframing.h"
|
||||
#include "meshcore/packets/advert.h"
|
||||
#include "meshcore/packets/control.h"
|
||||
@@ -82,49 +83,6 @@ TaskHandle_t Task2Task_Handler;
|
||||
// uint8_t bufIn[260];
|
||||
|
||||
void task2_task (void *pvParameters) {
|
||||
MESH_LOGD (TAG, "Task2 boot0");
|
||||
RTC_Init();
|
||||
startupTime = RTC_GetCounter();
|
||||
memset (&stats, 0, sizeof (stats));
|
||||
MESH_LOGD (TAG, "Task2 boot1");
|
||||
|
||||
ADC_Function_Init();
|
||||
MESH_LOGD (TAG, "Task2 boot2");
|
||||
// ed25519_create_keypair (persistent.pubkey, persistent.privkey, "vFt0FRugSOeqnkshImMCVfgHM5vBxz4");
|
||||
ed25519_create_keypair (persistent.pubkey, persistent.privkey, "vFt0FRugSOeqnkshImMCVfgHM5vBxz3");
|
||||
MESH_LOGD (TAG, "Task2 boot3");
|
||||
// persistent.nodeType = NODE_TYPE_CHAT_NODE;
|
||||
persistent.nodeType = NODE_TYPE_REPEATER;
|
||||
memset (persistent.password, 0, sizeof (persistent.password));
|
||||
strcpy (persistent.password, "hesielko");
|
||||
strcpy (persistent.nodeName, "BRN RiscVpeater");
|
||||
|
||||
const uint8_t aesKeysDefault[AESKeyCount][17] = {
|
||||
{0x11, 0x8b, 0x33, 0x87, 0xe9, 0xc5,
|
||||
0xcd, 0xea, 0x6a, 0xc9, 0xe5, 0xed,
|
||||
0xba, 0xa1, 0x15, 0xcd, 0x72},
|
||||
|
||||
{0x0a, 0x44, 0x81, 0xda, 0x0e, 0x4e,
|
||||
0x03, 0xc4, 0x9e, 0x84, 0x77, 0x25,
|
||||
0xd8, 0x3a, 0x93, 0xbf, 0x80}
|
||||
};
|
||||
|
||||
memcpy (persistent.aesKeys, aesKeysDefault, sizeof (persistent.aesKeys));
|
||||
|
||||
// sendAdvert();
|
||||
|
||||
DiscoverRequestPayload discReq;
|
||||
discReq.prefixOnly = 0;
|
||||
discReq.since = 0;
|
||||
discReq.tag = RTC_GetCounter();
|
||||
discReq.typeFilter = 0xFF;
|
||||
sendDiscoverRequest (&discReq);
|
||||
|
||||
persistent.latitude = 48190900;
|
||||
persistent.longitude = 17030300;
|
||||
persistent.altitude = 23400;
|
||||
|
||||
|
||||
char x;
|
||||
MESH_LOGD (TAG, "Task2 boot");
|
||||
while (1) {
|
||||
@@ -156,6 +114,19 @@ void task2_task (void *pvParameters) {
|
||||
printf ("Sending a direct message to the first node\n");
|
||||
sendEncryptedTextMessage (&(persistent.contacts[0]), &plainTextMessage);
|
||||
}
|
||||
if (x == 'C') {
|
||||
for (uint8_t i = 0; i < ChannelCount; i++) {
|
||||
Channel *channel = &(persistent.channels[i]);
|
||||
if (strlen (channel->name) == 0) {
|
||||
continue;
|
||||
}
|
||||
if (channel->timestamp == 0) {
|
||||
continue;
|
||||
}
|
||||
printf ("Channel index %d, named %s, timestamp is %d, hash is %d\n", i, channel->name, channel->timestamp, channel->hash);
|
||||
hexdump ("Pubkey", channel->key, sizeof (channel->key));
|
||||
}
|
||||
}
|
||||
}
|
||||
vTaskDelay (pdMS_TO_TICKS (2000));
|
||||
}
|
||||
@@ -163,40 +134,27 @@ void task2_task (void *pvParameters) {
|
||||
|
||||
void task1_task (void *pvParameters) {
|
||||
// loadConfig();
|
||||
populateDefaults();
|
||||
|
||||
LoraApply();
|
||||
|
||||
const int64_t interval_ms = 10; // 10 ms
|
||||
int64_t start_time, end_time, elapsed;
|
||||
|
||||
MESH_LOGW (TAG, "LoraInit");
|
||||
LoRaInit();
|
||||
int8_t txPowerInDbm = 20;
|
||||
uint32_t frequencyInHz = 869554000;
|
||||
uint8_t spreadingFactor = 8;
|
||||
uint8_t bandwidth = SX126X_LORA_BW_62_5;
|
||||
uint8_t codingRate = SX126X_LORA_CR_4_8;
|
||||
uint16_t preambleLength = 16;
|
||||
float tcxoVoltage = 2.2; // ebyte
|
||||
// float tcxoVoltage = 1.8; // heltec
|
||||
ADC_Function_Init();
|
||||
RTC_Init();
|
||||
startupTime = RTC_GetCounter();
|
||||
memset (&stats, 0, sizeof (stats));
|
||||
|
||||
MESH_LOGW (TAG, "Enable TCXO");
|
||||
char useRegulatorLDO = 1;
|
||||
|
||||
LoRaDebugPrint (0);
|
||||
MESH_LOGW (TAG, "Starting lora");
|
||||
uint16_t loraBeginStat = LoRaBegin (frequencyInHz, txPowerInDbm, tcxoVoltage, useRegulatorLDO);
|
||||
if (loraBeginStat != 0) {
|
||||
MESH_LOGE (TAG, "Does not recognize the module");
|
||||
while (1) {
|
||||
vTaskDelay (pdMS_TO_TICKS (1000));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
char crcOn = 1;
|
||||
char invertIrq = 0;
|
||||
|
||||
LoRaConfig (spreadingFactor, bandwidth, codingRate, preambleLength, 0, crcOn,
|
||||
invertIrq);
|
||||
DiscoverRequestPayload discReq;
|
||||
discReq.prefixOnly = 0;
|
||||
discReq.since = 0;
|
||||
discReq.tag = RTC_GetCounter();
|
||||
discReq.typeFilter = 0xFF;
|
||||
sendDiscoverRequest (&discReq);
|
||||
|
||||
sendAdvert (1);
|
||||
|
||||
while (1) {
|
||||
start_time = xTaskGetTickCount();
|
||||
@@ -211,8 +169,10 @@ void task1_task (void *pvParameters) {
|
||||
// frame = decodeFrame (bufIn, rxLen);
|
||||
MESH_LOGD (TAG, "Free stack before processFrame: %u bytes", uxTaskGetStackHighWaterMark (NULL) * 4);
|
||||
processFrame (&frame);
|
||||
MESH_LOGD (TAG, "Free stack before retransmitFrame: %u bytes", uxTaskGetStackHighWaterMark (NULL) * 4);
|
||||
retransmitFrame (&frame);
|
||||
if (persistent.doRepeat) {
|
||||
MESH_LOGD (TAG, "Free stack before retransmitFrame: %u bytes", uxTaskGetStackHighWaterMark (NULL) * 4);
|
||||
retransmitFrame (&frame);
|
||||
}
|
||||
memset (&frame, 0, sizeof (FrameStruct)); // prepare for the next round
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user