35 lines
1.1 KiB
C++
35 lines
1.1 KiB
C++
#include "FlightController.hpp"
|
|
#include "GSON.h"
|
|
#include "RF/BluetoothDispatcher.hpp"
|
|
#include <map>
|
|
|
|
class FlightDispatcher {
|
|
/* Deserialize state and update it in FlightController. */
|
|
public:
|
|
FlightDispatcher(BluetoothDispatcher *bluetoothDispatcher,
|
|
FlightController *flightController, volatile bool loop_on_fail = true);
|
|
~FlightDispatcher();
|
|
void tick();
|
|
private:
|
|
/* Telemetry flow */
|
|
void _sendTelemetry();
|
|
|
|
/* Events handlers */
|
|
void _onNewDeviceConnected(BTAddress device);
|
|
void _onNewMessageReceived(char *package);
|
|
|
|
/* Requests handlers */
|
|
void _changeStatus(const DeviceStatus &newStatus);
|
|
void _pidSettingsOpened();
|
|
|
|
/* Compile time settings */
|
|
static constexpr const char *_tag = "FlightDispatcher";
|
|
static constexpr const int _telemetryTimeIntervalMS = 200;
|
|
static constexpr const uint8_t _jsonMaxDepth = 5;
|
|
|
|
uint32_t _telemetryTimer = millis();
|
|
BluetoothDispatcher *_bluetoothDispatcher;
|
|
FlightController *_flightController;
|
|
|
|
std::map<size_t, std::function<void(gson::Entry)>> _routes;
|
|
}; |