kopia lustrzana https://github.com/PiInTheSky/lora-gateway
Merge pull request #52 from philcrump/fix-json-outputs
Rename CSV OziMux to OziPlotter, Add JSON OziMux.pull/55/head
commit
9dfd8976f2
|
@ -5,7 +5,8 @@ The LoRa Gateway provides some socket interfaces, configurable in gateway.txt:
|
|||
- ServerPort - TCP/IP server socket, allowing a single client. Sends status and packet information in JSON format. Also allows for gateway settings (e.g. frequency) to be polled or changed.
|
||||
- DataPort - TCP/IP server socket, allowing a single client. Sends raw telemetry packets (e.g. $$...).
|
||||
- UDPPort - UDP client broadcast socket, sending raw telemetry.
|
||||
- OziPort - UDP client broadcast socket, sending basic telemetry reformatted as OziMux 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.
|
||||
|
||||
|
||||
|
||||
|
|
46
gateway.c
46
gateway.c
|
@ -921,8 +921,8 @@ void ProcessLineUKHAS(int Channel, char *Line)
|
|||
Config.Payloads[PayloadIndex].Longitude,
|
||||
Config.Payloads[PayloadIndex].Altitude);
|
||||
|
||||
// Send out to any OziMux clients
|
||||
if (Config.OziPort > 0)
|
||||
// Send out to any OziPlotter clients
|
||||
if (Config.OziPlotterPort > 0)
|
||||
{
|
||||
char OziSentence[200];
|
||||
sprintf(OziSentence, "TELEMETRY,%s,%lf,%lf,%d\n",
|
||||
|
@ -930,7 +930,27 @@ void ProcessLineUKHAS(int Channel, char *Line)
|
|||
Config.Payloads[PayloadIndex].Latitude,
|
||||
Config.Payloads[PayloadIndex].Longitude,
|
||||
Config.Payloads[PayloadIndex].Altitude);
|
||||
UDPSend(OziSentence, Config.OziPort);
|
||||
UDPSend(OziSentence, Config.OziPlotterPort);
|
||||
}
|
||||
|
||||
// Send out to any OziMux clients
|
||||
if (Config.OziMuxPort > 0)
|
||||
{
|
||||
char OziSentence[512];
|
||||
snprintf(OziSentence, 511,
|
||||
"{\"type\":\"PAYLOAD_TELEMETRY\""
|
||||
",\"callsign\":\"%s\""
|
||||
",\"time_string\":\"%s\""
|
||||
",\"latitude\":\"%lf\""
|
||||
",\"longitude\":\"%lf\""
|
||||
",\"altitude\":\"%d\"}",
|
||||
Config.Payloads[PayloadIndex].Payload,
|
||||
Config.Payloads[PayloadIndex].Time,
|
||||
Config.Payloads[PayloadIndex].Latitude,
|
||||
Config.Payloads[PayloadIndex].Longitude,
|
||||
Config.Payloads[PayloadIndex].Altitude
|
||||
);
|
||||
UDPSend(OziSentence, Config.OziMuxPort);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -968,8 +988,8 @@ void ProcessLineHABpack(int Channel, received_t *Received)
|
|||
Config.Payloads[PayloadIndex].Longitude,
|
||||
Config.Payloads[PayloadIndex].Altitude);
|
||||
|
||||
// Send out to any OziMux clients
|
||||
if (Config.OziPort > 0)
|
||||
// Send out to any OziPlotter clients
|
||||
if (Config.OziPlotterPort > 0)
|
||||
{
|
||||
char OziSentence[200];
|
||||
sprintf(OziSentence, "TELEMETRY,%s,%lf,%lf,%d\n",
|
||||
|
@ -977,7 +997,15 @@ void ProcessLineHABpack(int Channel, received_t *Received)
|
|||
Config.Payloads[PayloadIndex].Latitude,
|
||||
Config.Payloads[PayloadIndex].Longitude,
|
||||
Config.Payloads[PayloadIndex].Altitude);
|
||||
UDPSend(OziSentence, Config.OziPort);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1696,10 +1724,12 @@ void LoadConfigFile(void)
|
|||
RegisterConfigInteger(MainSection, -1, "HABPort", &Config.HABPort, NULL); // Telnet 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, "OziPort", &Config.OziPort, NULL); // UDP Broadcast socket (OziMux 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.OziPort > 0) LogMessage("UDP Broadcast of OziMux packets on port %d\n", Config.OziPort);
|
||||
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
|
||||
Config.HABTimeout = 4000;
|
||||
|
|
3
global.h
3
global.h
|
@ -116,7 +116,8 @@ struct TConfig
|
|||
int InternetLED;
|
||||
int ServerPort; // JSON port for telemetry, settings
|
||||
int UDPPort; // UDP Broadcast port for raw received data packets
|
||||
int OziPort; // UDP Broadcast port for OziMux 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 HABTimeout; // Timeout in ms for telnet 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)
|
||||
{
|
||||
habpack_telem_linklist_entry_t *walk_ptr, *last_ptr;
|
||||
|
|
|
@ -45,4 +45,6 @@
|
|||
int Habpack_Process_Message(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__ */
|
Ładowanie…
Reference in New Issue