Skip to content

Commit fcd2565

Browse files
committed
v3.1.0
* Updated "Listen-Before-Talk" JSON configuration to match with LBT rework. * Added TX Notch Filter JSON configuration. * Updated Parson library to latest version * Fixed Class-B beacon CRC-16 calculation * Removed JiT time_on_air local function, and use lgw_time_on_air() function
1 parent f31ee2e commit fcd2565

13 files changed

+1561
-484
lines changed

PROTOCOL.TXT

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,8 @@ occured.
331331
0 | protocol version = 2
332332
1-2 | same token as the PULL_RESP packet to acknowledge
333333
3 | TX_ACK identifier 0x05
334-
4-end | [optional] JSON object, starting with {, ending with }, see section 6
334+
4-11 | Gateway unique identifier (MAC address)
335+
12-end | [optional] JSON object, starting with {, ending with }, see section 6
335336

336337
6. Downstream JSON data structure
337338
----------------------------------

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0.0
1+
3.1.0

lora_pkt_fwd/cfg/global_conf.json.PCB_E336.EU868.basic

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
"clksrc": 1, /* radio_1 provides clock to concentrator */
55
"lbt_cfg": {
66
"enable": false,
7-
"rssi_target": 160, /* rssi in dBm = -lbt_rssi_target/2 */
8-
"nb_channel": 1,
9-
"start_freq": 869525000,
10-
"scan_time_us": 5000,
11-
"tx_delay_1ch_us": 4000000,
12-
"tx_delay_2ch_us": 4000000
7+
"rssi_target": -80, /* dBm */
8+
"chan_cfg":[ /* 8 channels maximum */
9+
{ "freq_hz": 867100000, "scan_time_us": 128 },
10+
{ "freq_hz": 867300000, "scan_time_us": 5000 },
11+
{ "freq_hz": 867500000, "scan_time_us": 128 },
12+
{ "freq_hz": 869525000, "scan_time_us": 128 }
13+
],
14+
"sx127x_rssi_offset": -4 /* dB */
1315
},
1416
"antenna_gain": 0, /* antenna gain, in dBi */
1517
"radio_0": {
@@ -18,6 +20,7 @@
1820
"freq": 867500000,
1921
"rssi_offset": -165.0,
2022
"tx_enable": true,
23+
"tx_notch_freq": 129000, /* [126..250] KHz */
2124
"tx_freq_min": 863000000,
2225
"tx_freq_max": 870000000
2326
},

lora_pkt_fwd/cfg/global_conf.json.PCB_E336.EU868.beacon

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
"clksrc": 1, /* radio_1 provides clock to concentrator */
55
"lbt_cfg": {
66
"enable": false,
7-
"rssi_target": 160, /* rssi in dBm = -lbt_rssi_target/2 */
8-
"nb_channel": 1,
9-
"start_freq": 869525000,
10-
"scan_time_us": 5000,
11-
"tx_delay_1ch_us": 4000000,
12-
"tx_delay_2ch_us": 4000000
7+
"rssi_target": -80, /* dBm */
8+
"chan_cfg":[ /* 8 channels maximum */
9+
{ "freq_hz": 867100000, "scan_time_us": 128 },
10+
{ "freq_hz": 867300000, "scan_time_us": 5000 },
11+
{ "freq_hz": 867500000, "scan_time_us": 128 },
12+
{ "freq_hz": 869525000, "scan_time_us": 128 }
13+
],
14+
"sx127x_rssi_offset": -4 /* dB */
1315
},
1416
"antenna_gain": 0, /* antenna gain, in dBi */
1517
"radio_0": {
@@ -18,6 +20,7 @@
1820
"freq": 867500000,
1921
"rssi_offset": -165.0,
2022
"tx_enable": true,
23+
"tx_notch_freq": 129000, /* [126..250] KHz */
2124
"tx_freq_min": 863000000,
2225
"tx_freq_max": 870000000
2326
},

lora_pkt_fwd/cfg/global_conf.json.PCB_E336.EU868.gps

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
"clksrc": 1, /* radio_1 provides clock to concentrator */
55
"lbt_cfg": {
66
"enable": false,
7-
"rssi_target": 160, /* rssi in dBm = -lbt_rssi_target/2 */
8-
"nb_channel": 1,
9-
"start_freq": 869525000,
10-
"scan_time_us": 5000,
11-
"tx_delay_1ch_us": 4000000,
12-
"tx_delay_2ch_us": 4000000
7+
"rssi_target": -80, /* dBm */
8+
"chan_cfg":[ /* 8 channels maximum */
9+
{ "freq_hz": 867100000, "scan_time_us": 128 },
10+
{ "freq_hz": 867300000, "scan_time_us": 5000 },
11+
{ "freq_hz": 867500000, "scan_time_us": 128 },
12+
{ "freq_hz": 869525000, "scan_time_us": 128 }
13+
],
14+
"sx127x_rssi_offset": -4 /* dB */
1315
},
1416
"antenna_gain": 0, /* antenna gain, in dBi */
1517
"radio_0": {
@@ -18,6 +20,7 @@
1820
"freq": 867500000,
1921
"rssi_offset": -165.0,
2022
"tx_enable": true,
23+
"tx_notch_freq": 129000, /* [126..250] KHz */
2124
"tx_freq_min": 863000000,
2225
"tx_freq_max": 870000000
2326
},

lora_pkt_fwd/global_conf.json

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
"clksrc": 1, /* radio_1 provides clock to concentrator */
55
"lbt_cfg": {
66
"enable": false,
7-
"rssi_target": 160, /* rssi in dBm = -lbt_rssi_target/2 */
8-
"nb_channel": 1,
9-
"start_freq": 869525000,
10-
"scan_time_us": 5000,
11-
"tx_delay_1ch_us": 4000000,
12-
"tx_delay_2ch_us": 4000000
7+
"rssi_target": -80, /* dBm */
8+
"chan_cfg":[ /* 8 channels maximum */
9+
{ "freq_hz": 867100000, "scan_time_us": 128 },
10+
{ "freq_hz": 867300000, "scan_time_us": 5000 },
11+
{ "freq_hz": 867500000, "scan_time_us": 128 },
12+
{ "freq_hz": 869525000, "scan_time_us": 128 }
13+
],
14+
"sx127x_rssi_offset": -4 /* dB */
1315
},
1416
"antenna_gain": 0, /* antenna gain, in dBi */
1517
"radio_0": {
@@ -18,6 +20,7 @@
1820
"freq": 867500000,
1921
"rssi_offset": -166.0,
2022
"tx_enable": true,
23+
"tx_notch_freq": 129000, /* [126..250] KHz */
2124
"tx_freq_min": 863000000,
2225
"tx_freq_max": 870000000
2326
},

lora_pkt_fwd/inc/parson.h

Lines changed: 142 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
/*
22
Parson ( http://kgabis.github.com/parson/ )
3-
Copyright (C) 2013 Krzysztof Gabis
4-
3+
Copyright (c) 2012 - 2016 Krzysztof Gabis
4+
55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
77
in the Software without restriction, including without limitation the rights
88
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
99
copies of the Software, and to permit persons to whom the Software is
1010
furnished to do so, subject to the following conditions:
11-
11+
1212
The above copyright notice and this permission notice shall be included in
1313
all copies or substantial portions of the Software.
14-
14+
1515
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1616
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1717
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -27,49 +27,91 @@
2727
#ifdef __cplusplus
2828
extern "C"
2929
{
30-
#endif
31-
32-
#include <stddef.h> /* size_t */
30+
#endif
31+
32+
#include <stddef.h> /* size_t */
3333

34-
#define PARSON_VERSION 20131130
35-
3634
/* Types and enums */
3735
typedef struct json_object_t JSON_Object;
3836
typedef struct json_array_t JSON_Array;
3937
typedef struct json_value_t JSON_Value;
4038

41-
typedef enum json_value_type {
42-
JSONError = 0,
39+
enum json_value_type {
40+
JSONError = -1,
4341
JSONNull = 1,
4442
JSONString = 2,
4543
JSONNumber = 3,
4644
JSONObject = 4,
4745
JSONArray = 5,
4846
JSONBoolean = 6
49-
} JSON_Value_Type;
47+
};
48+
typedef int JSON_Value_Type;
49+
50+
enum json_result_t {
51+
JSONSuccess = 0,
52+
JSONFailure = -1
53+
};
54+
typedef int JSON_Status;
55+
56+
typedef void * (*JSON_Malloc_Function)(size_t);
57+
typedef void (*JSON_Free_Function)(void *);
58+
59+
/* Call only once, before calling any other function from parson API. If not called, malloc and free
60+
from stdlib will be used for all allocations */
61+
void json_set_allocation_functions(JSON_Malloc_Function malloc_fun, JSON_Free_Function free_fun);
5062

51-
5263
/* Parses first JSON value in a file, returns NULL in case of error */
53-
JSON_Value * json_parse_file(const char *filename);
64+
JSON_Value * json_parse_file(const char *filename);
5465

5566
/* Parses first JSON value in a file and ignores comments (/ * * / and //),
5667
returns NULL in case of error */
57-
JSON_Value * json_parse_file_with_comments(const char *filename);
58-
68+
JSON_Value * json_parse_file_with_comments(const char *filename);
69+
5970
/* Parses first JSON value in a string, returns NULL in case of error */
60-
JSON_Value * json_parse_string(const char *string);
71+
JSON_Value * json_parse_string(const char *string);
6172

6273
/* Parses first JSON value in a string and ignores comments (/ * * / and //),
6374
returns NULL in case of error */
64-
JSON_Value * json_parse_string_with_comments(const char *string);
65-
66-
/* JSON Object */
75+
JSON_Value * json_parse_string_with_comments(const char *string);
76+
77+
/* Serialization */
78+
size_t json_serialization_size(const JSON_Value *value); /* returns 0 on fail */
79+
JSON_Status json_serialize_to_buffer(const JSON_Value *value, char *buf, size_t buf_size_in_bytes);
80+
JSON_Status json_serialize_to_file(const JSON_Value *value, const char *filename);
81+
char * json_serialize_to_string(const JSON_Value *value);
82+
83+
/* Pretty serialization */
84+
size_t json_serialization_size_pretty(const JSON_Value *value); /* returns 0 on fail */
85+
JSON_Status json_serialize_to_buffer_pretty(const JSON_Value *value, char *buf, size_t buf_size_in_bytes);
86+
JSON_Status json_serialize_to_file_pretty(const JSON_Value *value, const char *filename);
87+
char * json_serialize_to_string_pretty(const JSON_Value *value);
88+
89+
void json_free_serialized_string(char *string); /* frees string from json_serialize_to_string and json_serialize_to_string_pretty */
90+
91+
/* Comparing */
92+
int json_value_equals(const JSON_Value *a, const JSON_Value *b);
93+
94+
/* Validation
95+
This is *NOT* JSON Schema. It validates json by checking if object have identically
96+
named fields with matching types.
97+
For example schema {"name":"", "age":0} will validate
98+
{"name":"Joe", "age":25} and {"name":"Joe", "age":25, "gender":"m"},
99+
but not {"name":"Joe"} or {"name":"Joe", "age":"Cucumber"}.
100+
In case of arrays, only first value in schema is checked against all values in tested array.
101+
Empty objects ({}) validate all objects, empty arrays ([]) validate all arrays,
102+
null validates values of every type.
103+
*/
104+
JSON_Status json_validate(const JSON_Value *schema, const JSON_Value *value);
105+
106+
/*
107+
* JSON Object
108+
*/
67109
JSON_Value * json_object_get_value (const JSON_Object *object, const char *name);
68110
const char * json_object_get_string (const JSON_Object *object, const char *name);
69111
JSON_Object * json_object_get_object (const JSON_Object *object, const char *name);
70112
JSON_Array * json_object_get_array (const JSON_Object *object, const char *name);
71-
double json_object_get_number (const JSON_Object *object, const char *name);
72-
int json_object_get_boolean(const JSON_Object *object, const char *name);
113+
double json_object_get_number (const JSON_Object *object, const char *name); /* returns 0 on fail */
114+
int json_object_get_boolean(const JSON_Object *object, const char *name); /* returns -1 on fail */
73115

74116
/* dotget functions enable addressing values with dot notation in nested objects,
75117
just like in structs or c++/java/c# objects (e.g. objectA.objectB.value).
@@ -79,31 +121,100 @@ JSON_Value * json_object_dotget_value (const JSON_Object *object, const char *
79121
const char * json_object_dotget_string (const JSON_Object *object, const char *name);
80122
JSON_Object * json_object_dotget_object (const JSON_Object *object, const char *name);
81123
JSON_Array * json_object_dotget_array (const JSON_Object *object, const char *name);
82-
double json_object_dotget_number (const JSON_Object *object, const char *name);
83-
int json_object_dotget_boolean(const JSON_Object *object, const char *name);
124+
double json_object_dotget_number (const JSON_Object *object, const char *name); /* returns 0 on fail */
125+
int json_object_dotget_boolean(const JSON_Object *object, const char *name); /* returns -1 on fail */
84126

85127
/* Functions to get available names */
86128
size_t json_object_get_count(const JSON_Object *object);
87129
const char * json_object_get_name (const JSON_Object *object, size_t index);
88-
89-
/* JSON Array */
130+
131+
/* Creates new name-value pair or frees and replaces old value with a new one.
132+
* json_object_set_value does not copy passed value so it shouldn't be freed afterwards. */
133+
JSON_Status json_object_set_value(JSON_Object *object, const char *name, JSON_Value *value);
134+
JSON_Status json_object_set_string(JSON_Object *object, const char *name, const char *string);
135+
JSON_Status json_object_set_number(JSON_Object *object, const char *name, double number);
136+
JSON_Status json_object_set_boolean(JSON_Object *object, const char *name, int boolean);
137+
JSON_Status json_object_set_null(JSON_Object *object, const char *name);
138+
139+
/* Works like dotget functions, but creates whole hierarchy if necessary.
140+
* json_object_dotset_value does not copy passed value so it shouldn't be freed afterwards. */
141+
JSON_Status json_object_dotset_value(JSON_Object *object, const char *name, JSON_Value *value);
142+
JSON_Status json_object_dotset_string(JSON_Object *object, const char *name, const char *string);
143+
JSON_Status json_object_dotset_number(JSON_Object *object, const char *name, double number);
144+
JSON_Status json_object_dotset_boolean(JSON_Object *object, const char *name, int boolean);
145+
JSON_Status json_object_dotset_null(JSON_Object *object, const char *name);
146+
147+
/* Frees and removes name-value pair */
148+
JSON_Status json_object_remove(JSON_Object *object, const char *name);
149+
150+
/* Works like dotget function, but removes name-value pair only on exact match. */
151+
JSON_Status json_object_dotremove(JSON_Object *object, const char *key);
152+
153+
/* Removes all name-value pairs in object */
154+
JSON_Status json_object_clear(JSON_Object *object);
155+
156+
/*
157+
*JSON Array
158+
*/
90159
JSON_Value * json_array_get_value (const JSON_Array *array, size_t index);
91160
const char * json_array_get_string (const JSON_Array *array, size_t index);
92161
JSON_Object * json_array_get_object (const JSON_Array *array, size_t index);
93162
JSON_Array * json_array_get_array (const JSON_Array *array, size_t index);
94-
double json_array_get_number (const JSON_Array *array, size_t index);
95-
int json_array_get_boolean(const JSON_Array *array, size_t index);
163+
double json_array_get_number (const JSON_Array *array, size_t index); /* returns 0 on fail */
164+
int json_array_get_boolean(const JSON_Array *array, size_t index); /* returns -1 on fail */
96165
size_t json_array_get_count (const JSON_Array *array);
97166

98-
/* JSON Value */
167+
/* Frees and removes value at given index, does nothing and returns JSONFailure if index doesn't exist.
168+
* Order of values in array may change during execution. */
169+
JSON_Status json_array_remove(JSON_Array *array, size_t i);
170+
171+
/* Frees and removes from array value at given index and replaces it with given one.
172+
* Does nothing and returns JSONFailure if index doesn't exist.
173+
* json_array_replace_value does not copy passed value so it shouldn't be freed afterwards. */
174+
JSON_Status json_array_replace_value(JSON_Array *array, size_t i, JSON_Value *value);
175+
JSON_Status json_array_replace_string(JSON_Array *array, size_t i, const char* string);
176+
JSON_Status json_array_replace_number(JSON_Array *array, size_t i, double number);
177+
JSON_Status json_array_replace_boolean(JSON_Array *array, size_t i, int boolean);
178+
JSON_Status json_array_replace_null(JSON_Array *array, size_t i);
179+
180+
/* Frees and removes all values from array */
181+
JSON_Status json_array_clear(JSON_Array *array);
182+
183+
/* Appends new value at the end of array.
184+
* json_array_append_value does not copy passed value so it shouldn't be freed afterwards. */
185+
JSON_Status json_array_append_value(JSON_Array *array, JSON_Value *value);
186+
JSON_Status json_array_append_string(JSON_Array *array, const char *string);
187+
JSON_Status json_array_append_number(JSON_Array *array, double number);
188+
JSON_Status json_array_append_boolean(JSON_Array *array, int boolean);
189+
JSON_Status json_array_append_null(JSON_Array *array);
190+
191+
/*
192+
*JSON Value
193+
*/
194+
JSON_Value * json_value_init_object (void);
195+
JSON_Value * json_value_init_array (void);
196+
JSON_Value * json_value_init_string (const char *string); /* copies passed string */
197+
JSON_Value * json_value_init_number (double number);
198+
JSON_Value * json_value_init_boolean(int boolean);
199+
JSON_Value * json_value_init_null (void);
200+
JSON_Value * json_value_deep_copy (const JSON_Value *value);
201+
void json_value_free (JSON_Value *value);
202+
99203
JSON_Value_Type json_value_get_type (const JSON_Value *value);
100204
JSON_Object * json_value_get_object (const JSON_Value *value);
101205
JSON_Array * json_value_get_array (const JSON_Value *value);
102206
const char * json_value_get_string (const JSON_Value *value);
103207
double json_value_get_number (const JSON_Value *value);
104208
int json_value_get_boolean(const JSON_Value *value);
105-
void json_value_free (JSON_Value *value);
106-
209+
210+
/* Same as above, but shorter */
211+
JSON_Value_Type json_type (const JSON_Value *value);
212+
JSON_Object * json_object (const JSON_Value *value);
213+
JSON_Array * json_array (const JSON_Value *value);
214+
const char * json_string (const JSON_Value *value);
215+
double json_number (const JSON_Value *value);
216+
int json_boolean(const JSON_Value *value);
217+
107218
#ifdef __cplusplus
108219
}
109220
#endif

lora_pkt_fwd/readme.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,8 @@ configured in 2 different ways:
194194
- Real time mode: when GPS is disabled, the value read in sample register is
195195
the actual concentrator counter value.
196196
- PPS mode: when GPS is enabled, the value read in sample register is the
197-
value
198-
that the concentrator counter had when last GPS’s PPS occurred. So this changes
199-
every second only.
197+
value that the concentrator counter had when last GPS’s PPS occurred. So
198+
this changes every second only.
200199
As in our case GPS is enabled (LGW_GPS_EN==1), we need to have a way to get the
201200
actual concentrator current time, at any time.
202201
For this, a new thread has been added to the packet forwarder (thread_timersync)

0 commit comments

Comments
 (0)