You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
968 B

#pragma once
#include <freertos/FreeRTOS.h>
#include <freertos/semphr.h>
#include <freertos/task.h>
#include "messages.pb.h"
#include "sx127x_driver.h"
namespace ugv {
namespace comms {
namespace messages = uas::ugv::messages;
class CommsClass {
public:
CommsClass();
void Init();
void Lock(TickType_t ticks_to_wait = pdMS_TO_TICKS(1000));
void Unlock();
int32_t ReadRssi();
uint8_t ReadLnaGain();
public:
SemaphoreHandle_t mutex;
messages::Location location;
messages::UGV_State ugv_state;
TickType_t last_packet_tick;
int32_t last_packet_rssi;
int8_t last_packet_snr;
private:
sx127x_hndl lora;
TaskHandle_t task_handle;
uint16_t packet_num;
void RunTask();
void HandlePacket(sx127x_rx_packet_t* packet);
void HandleCommand(const messages::GroundCommand& command);
static void CommsTask(void* arg);
};
extern CommsClass Comms;
} // namespace comms
} // namespace ugv