-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathc_sensor_module.cpp
More file actions
53 lines (40 loc) · 1.84 KB
/
Copy pathc_sensor_module.cpp
File metadata and controls
53 lines (40 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "c_sensor_module.h"
// F-Core Tenant
#include <f_core/messaging/c_msgq_message_port.h>
#include <f_core/os/n_rtos.h>
#include <f_core/os/tenants/c_timed_tenant.h> // TODO: Blast once we have CCpuMonitorTenant inherit this
#include <f_core/utils/n_time_utils.h>
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(sensor_module);
K_MSGQ_DEFINE(broadcastQueue, sizeof(NTypes::SensorData), 10, 4);
static auto broadcastMsgQueue = CMsgqMessagePort<NTypes::SensorData>(broadcastQueue);
K_MSGQ_DEFINE(downlinkQueue, sizeof(NTypes::LoRaBroadcastSensorData), 10, 4);
static auto downlinkMsgQueue = CMsgqMessagePort<NTypes::LoRaBroadcastSensorData>(downlinkQueue);
K_MSGQ_DEFINE(dataLogQueue, sizeof(NTypes::TimestampedSensorData), 512, 4);
static auto dataLogMsgQueue = CMsgqMessagePort<NTypes::TimestampedSensorData>(dataLogQueue);
K_MSGQ_DEFINE(alertQueue, sizeof(NAlerts::AlertPacket), 4, 4);
static auto alertMsgQueue = CMsgqMessagePort<NAlerts::AlertPacket>(alertQueue);
CSensorModule::CSensorModule()
: CProjectConfiguration(), sensorDataBroadcastMessagePort(broadcastMsgQueue), downlinkMessagePort(downlinkMsgQueue),
sensorDataLogMessagePort(dataLogMsgQueue), alertMessagePort(alertMsgQueue), flight_log{"/lfs/flight_log.txt"} {}
void CSensorModule::AddTenantsToTasks() {
// Networking
networkTask.AddTenant(broadcastTenant);
networkTask.AddTenant(downlinkTelemTenant);
networkTask.AddTenant(udpAlertTenant);
// Sensing
sensingTask.AddTenant(sensingTenant);
// Data Logging
dataLogTask.AddTenant(dataLoggerTenant);
}
void CSensorModule::AddTasksToRtos() {
// Networking
NRtos::AddTask(networkTask);
// Sensing
NRtos::AddTask(sensingTask);
// Data Logging
NRtos::AddTask(dataLogTask);
}
void CSensorModule::SetupCallbacks() {
NTimeUtils::SntpSynchronize(rtc, sntpServerAddr, 5, K_MSEC(100));
}