kopia lustrzana https://github.com/PiInTheSky/lora-gateway
Add JSON OziMux UDP Output.
rodzic
e5467db92a
commit
0323056d96
|
@ -6,6 +6,7 @@ The LoRa Gateway provides some socket interfaces, configurable in gateway.txt:
|
||||||
- DataPort - TCP/IP server socket, allowing a single client. Sends raw telemetry packets (e.g. $$...).
|
- DataPort - TCP/IP server socket, allowing a single client. Sends raw telemetry packets (e.g. $$...).
|
||||||
- UDPPort - UDP client broadcast socket, sending raw telemetry.
|
- UDPPort - UDP client broadcast socket, sending raw telemetry.
|
||||||
- OziPlotterPort - UDP client broadcast socket, sending basic telemetry reformatted as OziPlotter CSV format.
|
- OziPlotterPort - UDP client broadcast socket, sending basic telemetry reformatted as OziPlotter CSV format.
|
||||||
|
- OziMuxPort - UDP client broadcast socket, sending basic telemetry reformatted as OziMux JSON format.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
10
gateway.c
10
gateway.c
|
@ -979,6 +979,14 @@ void ProcessLineHABpack(int Channel, received_t *Received)
|
||||||
Config.Payloads[PayloadIndex].Altitude);
|
Config.Payloads[PayloadIndex].Altitude);
|
||||||
UDPSend(OziSentence, Config.OziPlotterPort);
|
UDPSend(OziSentence, Config.OziPlotterPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Send out to any OziMux clients
|
||||||
|
if (Config.OziMuxPort > 0)
|
||||||
|
{
|
||||||
|
char OziSentence[512];
|
||||||
|
Habpack_Telem_JSON(Received, OziSentence, 511);
|
||||||
|
UDPSend(OziSentence, Config.OziMuxPort);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1697,9 +1705,11 @@ void LoadConfigFile(void)
|
||||||
RegisterConfigInteger(MainSection, -1, "DataPort", &Config.DataPort, NULL); // Raw data server
|
RegisterConfigInteger(MainSection, -1, "DataPort", &Config.DataPort, NULL); // Raw data server
|
||||||
RegisterConfigInteger(MainSection, -1, "UDPPort", &Config.UDPPort, NULL); // UDP Broadcast socket (raw data)
|
RegisterConfigInteger(MainSection, -1, "UDPPort", &Config.UDPPort, NULL); // UDP Broadcast socket (raw data)
|
||||||
RegisterConfigInteger(MainSection, -1, "OziPlotterPort", &Config.OziPlotterPort, NULL); // UDP Broadcast socket (OziPlotter format)
|
RegisterConfigInteger(MainSection, -1, "OziPlotterPort", &Config.OziPlotterPort, NULL); // UDP Broadcast socket (OziPlotter format)
|
||||||
|
RegisterConfigInteger(MainSection, -1, "OziMuxPort", &Config.OziMuxPort, NULL); // UDP Broadcast socket (OziMux format)
|
||||||
|
|
||||||
if (Config.UDPPort > 0) LogMessage("UDP Broadcast of raw packets on port %d\n", Config.UDPPort);
|
if (Config.UDPPort > 0) LogMessage("UDP Broadcast of raw packets on port %d\n", Config.UDPPort);
|
||||||
if (Config.OziPlotterPort > 0) LogMessage("UDP Broadcast of OziPlotter packets on port %d\n", Config.OziPlotterPort);
|
if (Config.OziPlotterPort > 0) LogMessage("UDP Broadcast of OziPlotter packets on port %d\n", Config.OziPlotterPort);
|
||||||
|
if (Config.OziMuxPort > 0) LogMessage("UDP Broadcast of OziMux packets on port %d\n", Config.OziMuxPort);
|
||||||
|
|
||||||
// Timeout for HAB Telnet uplink
|
// Timeout for HAB Telnet uplink
|
||||||
Config.HABTimeout = 4000;
|
Config.HABTimeout = 4000;
|
||||||
|
|
1
global.h
1
global.h
|
@ -117,6 +117,7 @@ struct TConfig
|
||||||
int ServerPort; // JSON port for telemetry, settings
|
int ServerPort; // JSON port for telemetry, settings
|
||||||
int UDPPort; // UDP Broadcast port for raw received data packets
|
int UDPPort; // UDP Broadcast port for raw received data packets
|
||||||
int OziPlotterPort; // UDP Broadcast port for OziPlotter formatted packets
|
int OziPlotterPort; // UDP Broadcast port for OziPlotter formatted packets
|
||||||
|
int OziMuxPort; // UDP Broadcast port for OziMux formatted packets
|
||||||
int HABPort; // Telnet style port for comms with HAB
|
int HABPort; // Telnet style port for comms with HAB
|
||||||
int HABTimeout; // Timeout in ms for telnet uplink
|
int HABTimeout; // Timeout in ms for telnet uplink
|
||||||
int HABChannel; // LoRa Channel for uplink
|
int HABChannel; // LoRa Channel for uplink
|
||||||
|
|
59
habpack.c
59
habpack.c
|
@ -301,6 +301,65 @@ void Habpack_Telem_UKHAS_String(received_t *Received, char *ukhas_string, uint32
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Habpack_Telem_JSON(received_t *Received, char *json_string, uint32_t max_length)
|
||||||
|
{
|
||||||
|
uint32_t str_index;
|
||||||
|
habpack_telem_linklist_entry_t *walk_ptr;
|
||||||
|
|
||||||
|
str_index = snprintf(
|
||||||
|
json_string,
|
||||||
|
max_length,
|
||||||
|
"{\"type\":\"PAYLOAD_TELEMETRY\""
|
||||||
|
);
|
||||||
|
|
||||||
|
/* All other fields */
|
||||||
|
walk_ptr = Received->Telemetry.habpack_extra;
|
||||||
|
while(walk_ptr != NULL)
|
||||||
|
{
|
||||||
|
str_index += snprintf(
|
||||||
|
&json_string[str_index],
|
||||||
|
(max_length - str_index),
|
||||||
|
",\"%s\":",
|
||||||
|
walk_ptr->name
|
||||||
|
);
|
||||||
|
if(walk_ptr->value_type == HB_VALUE_INTEGER)
|
||||||
|
{
|
||||||
|
str_index += snprintf(
|
||||||
|
&json_string[str_index],
|
||||||
|
(max_length - str_index),
|
||||||
|
"%"PRId64,
|
||||||
|
walk_ptr->value.integer
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if(walk_ptr->value_type == HB_VALUE_REAL)
|
||||||
|
{
|
||||||
|
str_index += snprintf(
|
||||||
|
&json_string[str_index],
|
||||||
|
(max_length - str_index),
|
||||||
|
"%f",
|
||||||
|
walk_ptr->value.real
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if(walk_ptr->value_type == HB_VALUE_STRING)
|
||||||
|
{
|
||||||
|
str_index += snprintf(
|
||||||
|
&json_string[str_index],
|
||||||
|
(max_length - str_index),
|
||||||
|
"\"%s\"",
|
||||||
|
walk_ptr->value.string
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
walk_ptr = walk_ptr->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
str_index += snprintf(
|
||||||
|
&json_string[str_index],
|
||||||
|
(max_length - str_index),
|
||||||
|
"}"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
void Habpack_Telem_Destroy(received_t *Received)
|
void Habpack_Telem_Destroy(received_t *Received)
|
||||||
{
|
{
|
||||||
habpack_telem_linklist_entry_t *walk_ptr, *last_ptr;
|
habpack_telem_linklist_entry_t *walk_ptr, *last_ptr;
|
||||||
|
|
|
@ -45,4 +45,6 @@
|
||||||
int Habpack_Process_Message(received_t *Received);
|
int Habpack_Process_Message(received_t *Received);
|
||||||
void Habpack_Telem_Destroy(received_t *Received);
|
void Habpack_Telem_Destroy(received_t *Received);
|
||||||
|
|
||||||
|
void Habpack_Telem_JSON(received_t *Received, char *json_string, uint32_t max_length);
|
||||||
|
|
||||||
#endif /* __HABPACK_H__ */
|
#endif /* __HABPACK_H__ */
|
Ładowanie…
Reference in New Issue