refactor: mqtt data model.
This commit is contained in:
+735
-345
File diff suppressed because it is too large
Load Diff
+118
-31
@@ -5,22 +5,37 @@ package whgw_hr;
|
||||
option go_package = "hr_receiver/proto;whgw_hrpb";
|
||||
|
||||
enum HrConfidence {
|
||||
// [0,25)
|
||||
ZERO = 0;
|
||||
// [25,50)
|
||||
LOW = 1;
|
||||
// [50,75]
|
||||
MEDIUM = 2;
|
||||
// (75,100]
|
||||
HIGH = 3;
|
||||
}
|
||||
|
||||
enum LoRaBW {
|
||||
// nobody is using 7.8 kHz bandwidth
|
||||
// so to satisfy protobuf, we use NONE for zero value
|
||||
BW_NONE = 0;
|
||||
// 10.4 kHz
|
||||
BW_10_4 = 0x08;
|
||||
// 15.6 kHz
|
||||
BW_15_6 = 0x01;
|
||||
// 20.8 kHz
|
||||
BW_20_8 = 0x09;
|
||||
// 31.25 kHz
|
||||
BW_31_25 = 0x02;
|
||||
// 41.7 kHz
|
||||
BW_41_7 = 0x0A;
|
||||
// 62.5 kHz
|
||||
BW_62_5 = 0x03;
|
||||
// 125.0 kHz
|
||||
BW_125_0 = 0x04;
|
||||
// 250.0 kHz
|
||||
BW_250_0 = 0x05;
|
||||
// 500.0 kHz
|
||||
BW_500_0 = 0x06;
|
||||
}
|
||||
|
||||
@@ -32,11 +47,12 @@ message LoRaParameters {
|
||||
|
||||
message StatusFlag {
|
||||
HrConfidence hr_confidence = 1;
|
||||
bool is_active = 2;
|
||||
bool is_on_skin = 3;
|
||||
uint32 battery = 4;
|
||||
bool is_active = 2;
|
||||
bool is_on_skin = 3;
|
||||
uint32 battery = 4;
|
||||
}
|
||||
|
||||
|
||||
message HrPacket {
|
||||
StatusFlag status = 1;
|
||||
uint32 id = 2;
|
||||
@@ -51,27 +67,51 @@ message StepCountPacket {
|
||||
}
|
||||
|
||||
message RawPacketStatus {
|
||||
// Estimation of RSSI of the LoRa signal (after despreading) on last packet received.
|
||||
// to get the actual RSSI in dBm, divide by 2 and negate
|
||||
uint32 signal_rssi_x2_neg = 1;
|
||||
int32 snr_pkt_x4 = 2;
|
||||
// Estimation of RSSI of the LoRa signal (after despreading) on last packet received.
|
||||
// to get the actual SNR in dB, divide by 4
|
||||
int32 snr_pkt_x4 = 2;
|
||||
}
|
||||
|
||||
message PacketStatus {
|
||||
// Estimation of RSSI of the LoRa signal (after despreading) on last packet received.
|
||||
float signal_rssi_neg = 1;
|
||||
// Estimation of RSSI of the LoRa signal (after despreading) on last packet received.
|
||||
float snr_pkt = 2;
|
||||
}
|
||||
|
||||
message HubInfo {
|
||||
uint32 bus_id = 1;
|
||||
uint32 sub_dev_id = 2;
|
||||
uint32 bus_id = 1;
|
||||
uint32 sub_dev_id = 2;
|
||||
/** optional **/
|
||||
LoRaParameters radio_parameters = 3;
|
||||
}
|
||||
|
||||
message RadioData {
|
||||
HubInfo hub_info = 1;
|
||||
HubInfo hub_info = 1;
|
||||
RawPacketStatus raw_packet_status = 2;
|
||||
bytes data = 3;
|
||||
bytes data = 3;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
NOTIFY (NTF): MISO, unack
|
||||
SIGNAL (SIG): MOSI, unack
|
||||
|
||||
INDICATE (INF): MISO, needs MOSI CONFIRM
|
||||
CONFIRM (CNF): MOSI, confirms MISO INDICATE
|
||||
|
||||
REQUEST (REQ): MOSI, needs MISO RESPONSE
|
||||
RESPONSE (RSP): MISO, responds to MOSI REQUEST
|
||||
|
||||
note that frame type is only about its direction and acknowledge behavior,
|
||||
the actual semantics are dependent on the payload
|
||||
|
||||
*
|
||||
**/
|
||||
|
||||
enum PacketKind {
|
||||
NTF = 0;
|
||||
SIG = 1;
|
||||
@@ -81,27 +121,57 @@ enum PacketKind {
|
||||
RSP = 5;
|
||||
}
|
||||
|
||||
message GatewayStateReport {
|
||||
bool network_has_connection = 1;
|
||||
bool network_has_ip = 2;
|
||||
bool network_has_mqtt_connection = 3;
|
||||
bool bluetooth_has_connect = 4;
|
||||
uint32 error_code = 5;
|
||||
enum NetworkUplinkKind {
|
||||
NETWORK_UPLINK_UNKNOWN = 0;
|
||||
NETWORK_UPLINK_WIFI = 1;
|
||||
NETWORK_UPLINK_CELLULAR = 2;
|
||||
}
|
||||
|
||||
message CellularModemInfo {
|
||||
string imei = 1;
|
||||
int32 rssi = 2;
|
||||
int32 ber = 3;
|
||||
}
|
||||
|
||||
message GatewayInfoExtra {
|
||||
uint32 schema_version = 1;
|
||||
NetworkUplinkKind active_uplink = 2;
|
||||
CellularModemInfo cellular_modem = 3;
|
||||
}
|
||||
|
||||
message GatewayStateReportExtra {
|
||||
uint32 schema_version = 1;
|
||||
NetworkUplinkKind selected_uplink = 2;
|
||||
NetworkUplinkKind active_uplink = 3;
|
||||
bool cellular_modem_present = 4;
|
||||
}
|
||||
|
||||
message GatewayStateReport {
|
||||
bool network_has_connection = 1;
|
||||
bool network_has_ip = 2;
|
||||
bool network_has_mqtt_connection = 3;
|
||||
bool bluetooth_has_connect = 4;
|
||||
uint32 error_code = 5;
|
||||
GatewayStateReportExtra extra = 6;
|
||||
}
|
||||
|
||||
/*** Hub (S) to Gateway (M) ***/
|
||||
message HubSlaveOutGatewayMasterInMsg {
|
||||
oneof choice {
|
||||
RadioData ntf_radio_data = 1;
|
||||
RadioData ntf_radio_data = 1;
|
||||
BatteryInfo ntf_battery_info = 2;
|
||||
}
|
||||
}
|
||||
|
||||
/*** Gateway (M) to Hub (S) ***/
|
||||
message GatewayMasterOutHubSlaveInMsg {
|
||||
oneof choice {
|
||||
GatewayStateReport sig_gateway_state_report = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*** Gateway to MQTT ***/
|
||||
message GatewaySlaveOutCloudMasterInMsg {
|
||||
oneof choice {
|
||||
HrMeasurement ntf_hr_measurement = 1;
|
||||
@@ -110,6 +180,8 @@ message GatewaySlaveOutCloudMasterInMsg {
|
||||
}
|
||||
}
|
||||
|
||||
/** note that the endpoint should be v2 **/
|
||||
|
||||
message BatteryInfo {
|
||||
uint32 voltage_mv = 1;
|
||||
uint32 soc_percentage = 2;
|
||||
@@ -118,52 +190,64 @@ message BatteryInfo {
|
||||
|
||||
message GatewayInfo {
|
||||
uint32 region_id = 1;
|
||||
bytes gateway_mac = 2;
|
||||
bytes gateway_mac = 2;
|
||||
GatewayInfoExtra extra = 3;
|
||||
}
|
||||
|
||||
message IPacketStatus {
|
||||
oneof choice {
|
||||
RawPacketStatus raw = 1;
|
||||
PacketStatus parsed = 2;
|
||||
PacketStatus parsed = 2;
|
||||
}
|
||||
}
|
||||
|
||||
message HrMeasurement {
|
||||
HrPacket hr_packet = 1;
|
||||
HrPacket hr_packet = 1;
|
||||
IPacketStatus packet_status = 2;
|
||||
GatewayInfo gateway_info = 3;
|
||||
HubInfo hub_info = 4;
|
||||
GatewayInfo gateway_info = 3;
|
||||
HubInfo hub_info = 4;
|
||||
}
|
||||
|
||||
message StepCountMeasurement {
|
||||
StepCountPacket step_count_packet = 1;
|
||||
IPacketStatus packet_status = 2;
|
||||
GatewayInfo gateway_info = 3;
|
||||
HubInfo hub_info = 4;
|
||||
IPacketStatus packet_status = 2;
|
||||
GatewayInfo gateway_info = 3;
|
||||
HubInfo hub_info = 4;
|
||||
}
|
||||
|
||||
message GatewayStatistic {
|
||||
uint32 boot_count = 1;
|
||||
uint32 uptime_ms = 2;
|
||||
uint32 duration_ms_since_last_packet = 3;
|
||||
uint32 rx_count = 4;
|
||||
// Number of times the gateway has booted in history
|
||||
uint32 boot_count = 1;
|
||||
// Uptime of the device (in ms)
|
||||
uint32 uptime_ms = 2;
|
||||
// Duration (in ms) since last packet received
|
||||
// would be the duration since boot if no packets received yet
|
||||
uint32 duration_ms_since_last_packet = 3;
|
||||
// Total number of packets received since boot
|
||||
uint32 rx_count = 4;
|
||||
// optional, battery info
|
||||
BatteryInfo battery_info = 5;
|
||||
}
|
||||
|
||||
message GatewayStatus {
|
||||
GatewayInfo info = 1;
|
||||
GatewayInfo info = 1;
|
||||
GatewayStatistic stat = 2;
|
||||
}
|
||||
|
||||
message Status {
|
||||
int32 code = 1;
|
||||
int32 code = 1;
|
||||
string message = 2;
|
||||
}
|
||||
|
||||
/** Gateway Configuration Messages **/
|
||||
/** Master is Gateway; Slave is config client (bluetooth central, phone etc.) **/
|
||||
|
||||
enum GatewayConfigEntryKind {
|
||||
REGION_ID = 0;
|
||||
WIFI_SSID = 1;
|
||||
WIFI_PASSWORD = 2;
|
||||
NETWORK_UPLINK = 3;
|
||||
CELLULAR_APN = 4;
|
||||
}
|
||||
|
||||
message GatewayConfigEntry {
|
||||
@@ -171,14 +255,16 @@ message GatewayConfigEntry {
|
||||
uint32 region_id = 1;
|
||||
string wifi_ssid = 2;
|
||||
string wifi_password = 3;
|
||||
NetworkUplinkKind network_uplink = 4;
|
||||
string cellular_apn = 5;
|
||||
}
|
||||
}
|
||||
|
||||
message GatewayConfigMasterOutSlaveInMsg {
|
||||
oneof choice {
|
||||
GatewayConfigEntry cnf_get_entry = 1;
|
||||
Status cnf_get_failure = 2;
|
||||
Status cnf_set_entry = 3;
|
||||
Status cnf_get_failure = 2;
|
||||
Status cnf_set_entry = 3;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,3 +274,4 @@ message GatewayConfigMasterInSlaveOutMsg {
|
||||
GatewayConfigEntry inf_set_entry = 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user