42 lines
1000 B
C
42 lines
1000 B
C
#ifndef BLE_H
|
|
#define BLE_H
|
|
|
|
#include "eis.h"
|
|
|
|
/* Commands: Cue → ESP32 (0x1x) */
|
|
#define CMD_SET_SWEEP 0x10
|
|
#define CMD_SET_RTIA 0x11
|
|
#define CMD_SET_RCAL 0x12
|
|
#define CMD_START_SWEEP 0x13
|
|
#define CMD_GET_CONFIG 0x14
|
|
|
|
/* Responses: ESP32 → Cue (0x0x) */
|
|
#define RSP_SWEEP_START 0x01
|
|
#define RSP_DATA_POINT 0x02
|
|
#define RSP_SWEEP_END 0x03
|
|
#define RSP_CONFIG 0x04
|
|
|
|
typedef struct {
|
|
uint8_t type;
|
|
union {
|
|
struct { float freq_start, freq_stop; uint16_t ppd; } sweep;
|
|
uint8_t rtia;
|
|
uint8_t rcal;
|
|
};
|
|
} BleCommand;
|
|
|
|
int ble_init(void);
|
|
int ble_is_connected(void);
|
|
void ble_wait_for_connection(void);
|
|
|
|
/* blocking receive from command queue */
|
|
int ble_recv_command(BleCommand *cmd, uint32_t timeout_ms);
|
|
|
|
/* outbound data */
|
|
int ble_send_sweep_start(uint32_t num_points, float freq_start, float freq_stop);
|
|
int ble_send_eis_point(uint16_t index, const EISPoint *pt);
|
|
int ble_send_sweep_end(void);
|
|
int ble_send_config(const EISConfig *cfg);
|
|
|
|
#endif
|