New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Derive InfluxDB database and measurement from dev_id and signal data from all gateways #2
Conversation
Thanks for your contributions, @thiasB. Much appreciated! When looking at the changes, two things come to my mind when operating this piece in a generic / arbitrary TTN environment.
What do you think about this? |
yes, if you want to keep the original generic behavior then make the "hiveeyes scheme" optional. feel free to implement :) Geographical data is really not needed here. Usually they don't change over time. Let's not artificially blow up databases. Instead spreading factor (SF) and bandwidth (BW) could be candidates for consideration. |
ttnlogger/ttn_logger.py
Outdated
|
||
# Convert all numeric values to floats. | ||
data = convert_floats(data) | ||
data = convert_floats(data, integers="gtw_count,sf,bw") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should pass a list here, like integers=["gtw_count", "sf", "bw"]
.
Will do, though it's working. |
Thanks for addressing the generic aspects of |
You're welcome. |
ttnlogger/ttn_logger.py
Outdated
for i in range(num_gtws): | ||
gtw_id = ttn_message.metadata.gateways[i].gtw_id | ||
print('Gateway ' + str(i+1) + ' ID : ' + gtw_id) | ||
key_rssi = 'gw_' + gtw_id + '_rssi' | ||
key_snr = 'gw_' + gtw_id + '_snr' | ||
data[key_rssi] = int(ttn_message.metadata.gateways[i].rssi) | ||
data[key_snr] = float(ttn_message.metadata.gateways[i].snr) | ||
|
||
data['sf'] = int(ttn_message.metadata.data_rate.split('BW')[0][2:]) | ||
data['bw'] = int(ttn_message.metadata.data_rate.split('BW')[1]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't quite see through that yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Messages can be received from several gateways at once and each gateway puts the individual signal quality data (RSSI and SNR) into the final message. Spreading factor (sf) and bandwidth (bw) are determinated by the sending device and thus equals for every receiver.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And, on multiple receiving gateways there's no defined order of appearance in the TTN message. Thus, always picking gw0
will point to random gateways. That's why I'm now looping through and forwarding data from all gateways
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On multiple receiving gateways there's no defined order of appearance in the TTN message.
That's sad. But we are keying by gtw_id
now, right? This contains stable identifiers like eui-3338333018004700
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spreading factor (sf) and bandwidth (bw) are determinated by the sending device and thus equals for every receiver.
So, the last two lines actually decode the
"data_rate": "SF7BW125"
right?
I believe it won't do any harm. Unfortunately, if we don't have it within the database, we can't visualize it. |
55aae7b is yet untested |
if not self.nogeo: | ||
key_lon = 'gw_' + gtw_id + '_lon' | ||
key_alt = 'gw_' + gtw_id + '_alt' | ||
data[key_lat] = float(ttn_message.metadata.gateways[i].latitude) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
key_lat
might be undefined here.
Do you mean I should squash it when merging this pull request? |
Thanks! |
wasn't done testing and will push some more fixes :) |
dev_id
, e.g. when more than one device registered in TTN App