-
Notifications
You must be signed in to change notification settings - Fork 17
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
[DA] Add per-device addressing (DA) to WAN topic/channel decoding strategy #136
Conversation
This aims towards bringing in multi-tenant channel bundle endpoints, for example suitable to accepting TTS/TTN payloads, in order to run a network of multiple devices on a single TTN application conveniently. The feature is called "device addressing" (DA). Examples: - mqttkit-1/d/123e4567-e89b-12d3-a456-426614174000 - mqttkit-1/dt/network-gateway-node It works with both MQTT and HTTP protocols.
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #136 +/- ##
==========================================
+ Coverage 53.02% 53.26% +0.23%
==========================================
Files 100 100
Lines 5267 5291 +24
==========================================
+ Hits 2793 2818 +25
+ Misses 2474 2473 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
test/test_wan_strategy.py
Outdated
@pytest.mark.strategy | ||
def test_wan_strategy_device_dashed_topo_too_many_components_redundant_realm(): | ||
""" | ||
Verify the per-device WAN topology decoding, using a dashed device identifier with too many components. | ||
|
||
This is an edge case where the first addressing component actually equals the realm. | ||
Strictly, it is a misconfiguration, but we pretend to be smart, and ignore that, | ||
effectively not using the redundant information, and ignoring the `myrealm-` prefix | ||
within the device identifier slot altogether. | ||
|
||
Cheers, @thiasB. | ||
""" | ||
strategy = WanBusStrategy() | ||
topology = strategy.topic_to_topology("myrealm/dt/myrealm-acme-area42-eui70b3d57ed005dac6/data.json") | ||
assert topology == SmartMunch( | ||
{ | ||
"realm": "myrealm", | ||
"network": "acme", | ||
"gateway": "area42", | ||
"node": "eui70b3d57ed005dac6", | ||
"slot": "data.json", | ||
} | ||
) |
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.
@thiasB: When looking at 1, your devices are probably configured with device identifiers like device_id=hiveeyes-thias-freiland-hive2
, so they do include the realm redundantly at the first device identifier segment. This test case demonstrates that it will be ignored, so that you do not have to re-program the devices.
Did I get this detail right?
Footnotes
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.
Yes, you are right. However, re-creating the devices in the TTN console wouldn't take much effort. If the solution below is active, I will be happy to not touch device registration. For new devices, I will follow the rule that the realm is not included in the device ID.
Add more details about per-device decoding to the `WanBusStrategy`, and exercise a few topic/channel decodings, including edge cases. Examples: - myrealm/acme/area-42/foo-70b3d57ed005dac6 - myrealm/d/123e4567-e89b-12d3-a456-426614174000 - myrealm/dt/acme-area42-eui70b3d57ed005dac6 - myrealm/dt/eui-70b3d57ed005dac6 - myrealm/dt/acme-area42-eui70b3d57ed005dac6 - myrealm/dt/acme-area42-eui70b3d57ed005dac6-suffix - myrealm/dt/myrealm-acme-area42-eui70b3d57ed005dac6 - mqttkit-1/d - myrealm/dt
91d5392
to
d2151b6
Compare
For the new SensorWAN "direct" addressing scheme, by getting rid of the previous `/d` vs. `/dt` path fragments, and using `/device` vs. `/channel` instead, it reduces confusion about the meaning of those prefixes, and makes usage less error prone.
By defining a `direct_channel_allowed_networks` setting on the application configuration, the direct access to the corresponding channel will be restricted to the specified networks/owners.
d2151b6
to
1fa3ca5
Compare
About
This patch implements the proposal outlined at GH-133, adding a generic per-device topic addressing scheme, not exclusively but also in order to bring in multi-tenant TTN support, see GH-8.
Documentation
... is still missing. But reading the code, specifically the test cases and inline comments, will give you an idea.
Details
Backlog
=> Resolved with 0e60d11.
LanStrategy
, not only atWanBusStrategy
?=>
LanStrategy
will be dissolved in favor of SensorWAN direct device addressing.=> Documentation for multi-tenant TTN acquisition will be added with a subsequent patch.