m0zah/GB3TX/telemetry.h
2024-09-16 23:48:29 +01:00

65 lines
1.0 KiB
C

#ifndef TELEMENTRY
#define TELEMENTRY
#include "repeater.h"
#include "cw.h"
#define TELE_QUEUE 5
typedef enum {
MORSE,
BEEP,
}tele_t;
typedef struct {
tele_t type;
union {
char* message;
struct {
int pitch;
int t_len;
};
};
}tele_m;
typedef struct {
tele_m tele_msg[TELE_QUEUE];
int _s;
}tele_msg;
int tele_add_cw(tele_msg *msg, tele_t type, char* message, repeater *myrpt) {
if (msg->_s >= TELE_QUEUE)
return 1;
tele_m _m;
if (type == MORSE) {
_m.type = MORSE;
_m.message = message;
} else {
return 1;
}
serial_writer(&myrpt->serial, "ADDING TELEMETRY MORSE MESSAGE");
msg->tele_msg[msg->_s++] = _m;
msg->_s++;
return 0;
}
int tele_run(tele_msg *msg, repeater *myrpt) {
if (msg->_s == 0) {
return 1;
}
for (int i=1; i < msg->_s; i++) {
if (msg->tele_msg[i-1].type == MORSE) {
sendChar(myrpt, msg->tele_msg[i-1].message[0]);
// for now dec count, need to actually remove message from list.
msg->_s--;
}
}
}
#endif