The following pages provide a high level usage guide on how to use this system to build your own setup.

Minimal Main

The minimum this file needs to be is an event queue and a loop, that pops from said queue.

#include "../include/tsqueue.hpp"
#include "../include/events.hpp"

int main() {
	TSQueue<Event> eventList;
	
	for (;;) {
		Event e = eventList.pop(); // blocks until an event arrives  
		
		switch (e.type) {
			case EventType::DeploymentTriggered: {
				//do something
			}
		}
	}
}

Events Structure

The structure of events is as follows:

//include/events.hpp

enum class EventType {
    PhotoTaken,  
    TelemetryRequest,
    //......
};

struct Event {
    EventType type;
    EventPayload data;
    uint64_t seq = 0;  // optional: sequence for logging
};

//per event type you have a payload structure
struct EvPhotoTaken {
    std::string path;      // e.g., "/data/imgs/pic_001.jpg"
};

struct EvTelemetryRequest {
    uint16_t correlation_id;
    uint16_t sensor_id;
    uint8_t requester_id;
    uint8_t reply_via;
    std::vector<uint8_t> params;
};
//...

//these are also in a wrapper
using EventPayload = std::variant<
    EvPhotoTaken, 
    EvTelemetryRequest,
    //....
>;

Communications - Setup

Comms manager is the hub for talking to other satellites, a ground station or other modules on the same satellite via CAN. To add this functionality to main, create a comms manager instance and set your address.

#include "../include/comms_manager.hpp"
CommsManager comms(eventList);
comms.set_src(0xEF);

//setup comms channels

comms.start();

//event loop

Addresses for CAN connected devices are 0xF*, that is 1111****, as the CAN protocol uses 4 bit addresses. Any other node, satellite OBCs + ground stations, can use any address in the range 0x01 - 0xEF. The address 0xF0 is reserved for the OBC, no other module on the satellite can use this address. CAN messages to 0xF0 will be picked up by the OBC regardless of the OBCs set address.

Each type of communication has to be registered as a channel. Firstly ensure the required headers are included.

#include "../include/channels/tcp_channel.hpp"
#include "../include/channels/radio_channel.hpp"

Then configure and register the channels.

Examples:

// WiFi / TCP
TcpConfig tcpcfg;
tcpcfg.host = "10.42.0.1";
tcpcfg.port = 5000;
auto tcp = std::make_unique<TcpChannel>(tcpcfg);
comms.register_channel(std::move(tcp));

Current WiFi comms uses a TCP connection, server-client model. This means it is not flexible as radio, where you can talk peer to peer with any node. This will be updated soon to use UDP instead, and act in the same way as radio.