Azure / iotedge-lorawan-starterkit

Sample implementation of LoRaWAN components to connect LoRaWAN antenna gateway running IoT Edge directly with Azure IoT.
https://azure.github.io/iotedge-lorawan-starterkit/2.2.1
Other
183 stars 61 forks source link

Question: Upgrading from 1.0.7 to the 2.2.2 - need advice #2131

Open gerfen opened 1 week ago

gerfen commented 1 week ago

Hi,

I have been a long-time user of the starter kit and have been on version 1.0.7 for many years. I am now in a position to upgrade to the new 2.x version but I'm finding the documentation to be a little bit sparse from an upgrade perspective. For example, the upgrade documentation mentions Release 2.0.0-alpha (not released yet) but the current release is 2.2.2.

In my current deployments, I have the network server and packet forwarder co-located on the same piece of hardware. I can see the benefit of splitting out the Basics Station and Network Server to different implementations, but the upgrade documentation doesn't provide clear instructions for manually upgrading from previous deployments.

I have many questions:

  1. If I have a single network server, do I need to deploy the LNS discovery web app? I assume I do not, but the documentation does not make this clear. Is it a best practice to have a fallback network server or is a single network server sufficient?

  2. Can I collocate the network server with a basics station as I have been in my current 1.0.7 deployments? if so, what are the pros and cons? What should the configuration look like from the basics station perspective?

  3. For the basics station deployments, where should the configuration for the packetforwarder live? In the device twin? As part of the environment variables?

  4. The documentation now references US902 frequencies when in the past it was US915? Is this a mistake? The center frequency is still 915 Mhz so this choice is very confusing.

  5. I've noticed that the engagement on this project has declined pretty severely since the last major release in 11/23. Is the project still alive and viable? I've asked a couple of questions over the past 6 months which have received zero feedback, I appreciate that people are busy but getting no replies is a bit disheartening.

If I can get some assistance to get my system upgraded to the latest bits, I am more than willing to help out with making the documentation more approachable from an upgrade and over all understanding of the new architecture perspective.

Hope to hear back from a team member soon!

Thanks!

--Michael

gerfen commented 1 week ago

I've been making progress with setting up a new system. I now have a gateway set up which has both a BasicsStation and an LNS configured on a single piece of hardware. When a join request is received the BasicsStation forwards the data to the LNS but I get the following error in the LNS:

Request starting HTTP/1.1 GET http://172.17.0.1:5000/router-data/E45F01FFFE3E84C5 - -
1 candidate(s) found for the request path '/router-data/E45F01FFFE3E84C5'
Endpoint '/router-data/{routerId:required} HTTP: GET' with route pattern '/router-data/{routerId:required}' is valid for the request path '/router-data/E45F01FFFE3E84C5'
Request matched endpoint '/router-data/{routerId:required} HTTP: GET'
Executing endpoint '/router-data/{routerId:required} HTTP: GET'
WebSocket connection from 172.18.0.1 established
E45F01FFFE3E84C5 Received 'version' message for station '2.0.6(corecell/std)' with package ''.
E45F01FFFE3E84C5 Station did not report any 'package' field. Skipping reported property update.
An exception occurred while processing requests: System.Text.Json.JsonException: Exception of type 'System.Text.Json.JsonException' was thrown.
   at LoRaTools.JsonReader.<>c.<UInt32>b__23_0(Utf8JsonReader& reader) in /build/LoRaEngine/modules/LoRaWanNetworkSrvModule/LoraTools/JsonReader.g.cs:line 35
   at LoRaTools.JsonReader.<>c__DisplayClass17_0`2.<Select>b__0(Utf8JsonReader& rdr) in /build/LoRaEngine/modules/LoRaWanNetworkSrvModule/LoraTools/JsonReader.cs:line 317
   at LoRaTools.JsonReader.<>c__DisplayClass17_0`2.<Select>b__0(Utf8JsonReader& rdr) in /build/LoRaEngine/modules/LoRaWanNetworkSrvModule/LoraTools/JsonReader.cs:line 317
   at LoRaTools.JsonReader.<>c__DisplayClass9_0`1.<Either>b__0(Utf8JsonReader& reader) in /build/LoRaEngine/modules/LoRaWanNetworkSrvModule/LoraTools/JsonReader.cs:line 112
   at LoRaTools.JsonReader.<>c__DisplayClass15_0`3.<Tuple>b__0(Utf8JsonReader& reader) in /build/LoRaEngine/modules/LoRaWanNetworkSrvModule/LoraTools/JsonReader.cs:line 290
   at LoRaTools.JsonReader.<>c__DisplayClass17_0`2.<Select>b__0(Utf8JsonReader& rdr) in /build/LoRaEngine/modules/LoRaWanNetworkSrvModule/LoraTools/JsonReader.cs:line 317
   at LoRaTools.JsonReader.<>c__DisplayClass17_0`2.<Select>b__0(Utf8JsonReader& rdr) in /build/LoRaEngine/modules/LoRaWanNetworkSrvModule/LoraTools/JsonReader.cs:line 317
   at LoRaTools.JsonReader.<>c__DisplayClass16_0`1.<Array>b__0(Utf8JsonReader& reader) in /build/LoRaEngine/modules/LoRaWanNetworkSrvModule/LoraTools/JsonReader.cs:line 309
   at LoRaTools.JsonReader.<Object>g__ReadPropertyValue|14_1[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,TResult,TValue](IJsonProperty`1 property, Utf8JsonReader& reader, ValueTuple`2& value) in /build/LoRaEngine/modules/LoRaWanNetworkSrvModule/LoraTools/JsonReader.cs:line 232
   at LoRaTools.JsonReader.<>c__DisplayClass14_0`17.<Object>b__0(Utf8JsonReader& reader) in /build/LoRaEngine/modules/LoRaWanNetworkSrvModule/LoraTools/JsonReader.cs:line 177
Executed endpoint '/router-data/{routerId:required} HTTP: GET'
   at LoRaTools.JsonReader.Read[T](IJsonReader`1 reader, ReadOnlySpan`1 utf8JsonTextBytes) in /build/LoRaEngine/modules/LoRaWanNetworkSrvModule/LoraTools/JsonReader.cs:line 35
   at LoRaWan.NetworkServer.BasicsStation.BasicsStationConfigurationService.GetRouterConfigMessageAsync(StationEui stationEui, CancellationToken cancellationToken) in /build/LoRaEngine/modules/LoRaWanNetworkSrvModule/LoRaWan.NetworkServer/BasicsStation/BasicsStationConfigurationService.cs:line 86
   at LoRaWan.NetworkServer.BasicsStation.Processors.LnsProtocolMessageProcessor.HandleDataMessageAsync(StationEui stationEui, IWebSocketWriterHandle`1 socket, String json, CancellationToken cancellationToken) in /build/LoRaEngine/modules/LoRaWanNetworkSrvModule/LoRaWan.NetworkServer/BasicsStation/Processors/LnsProtocolMessageProcessor.cs:line 216
   at LoRaWan.NetworkServer.BasicsStation.Processors.LnsProtocolMessageProcessor.InternalHandleDataAsync(RouteValueDictionary routeValues, WebSocket socket, CancellationToken cancellationToken) in /build/LoRaEngine/modules/LoRaWanNetworkSrvModule/LoRaWan.NetworkServer/BasicsStation/Processors/LnsProtocolMessageProcessor.cs:line 108
   at LoRaWan.NetworkServer.BasicsStation.Processors.LnsProtocolMessageProcessor.InternalHandleDataAsync(RouteValueDictionary routeValues, WebSocket socket, CancellationToken cancellationToken) in /build/LoRaEngine/modules/LoRaWanNetworkSrvModule/LoRaWan.NetworkServer/BasicsStation/Processors/LnsProtocolMessageProcessor.cs:line 119
   at LoRaTools.WebSocketConnection.HandleAsync(Func`4 handler, CancellationToken cancellationToken) in /build/LoRaEngine/modules/LoRaWanNetworkSrvModule/LoraTools/WebSocketConnection.cs:line 54
   at LoRaWan.NetworkServer.BasicsStation.Processors.LnsProtocolMessageProcessor.<>c__DisplayClass14_0.<<HandleDataAsync>b__0>d.MoveNext() in /build/LoRaEngine/modules/LoRaWanNetworkSrvModule/LoRaWan.NetworkServer/BasicsStation/Processors/LnsProtocolMessageProcessor.cs:line 86
--- End of stack trace from previous location ---
   at LoRaWan.NetworkServer.BasicsStation.Processors.LnsProtocolMessageProcessor.ExecuteWithExceptionHandlingAsync[T](Func`1 action) in /build/LoRaEngine/modules/LoRaWanNetworkSrvModule/LoRaWan.NetworkServer/BasicsStation/Processors/LnsProtocolMessageProcessor.cs:line 229.
Request finished HTTP/1.1 GET http://172.17.0.1:5000/router-data/E45F01FFFE3E84C5 - - - 101 - - 10.6242ms

I'm not really sure how to go about debugging this issue. Any insight from the team would be greatly appreciated.

gerfen commented 3 days ago

With the assistance of @Mandur I was able to get around this error. There is a bug in the US902 default rouer config file shipped with the LoRaWan.Tool.Cli project. The JSON should look like this:

  "NetID": [1],
  "JoinEui": [["0000000000000000", "FFFFFFFFFFFFFFFF"]],
  "region": "US902",
  "hwspec": "sx1301/1",
  "freq_range": [902000000, 928000000],
  "DRs": [
    [10, 125, 0],
    [9, 125, 0],
    [8, 125, 0],
    [7, 125, 0],
    [8, 500, 0],
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
    [12, 500, 1],
    [11, 500, 1],
    [10, 500, 1],
    [9, 500, 1],
    [8, 500, 1],
    [7, 500, 1]
  ],
  "sx1301_conf": [
    {
      "radio_0": { "enable": true, "freq": 902700000 },
      "radio_1": { "enable": true, "freq": 903400000 },
      "chan_FSK": { "enable": true, "radio": 1, "if": 300000 },
      "chan_Lora_std": {
        "enable": true,
        "radio": 0,
        "if": 300000,
        "bandwidth": 500000,
        "spread_factor": 8
      },
      "chan_multiSF_0": { "enable": true, "radio": 0, "if": -400000 },
      "chan_multiSF_1": { "enable": true, "radio": 0, "if": -200000 },
      "chan_multiSF_2": { "enable": true, "radio": 0, "if": 0 },
      "chan_multiSF_3": { "enable": true, "radio": 0, "if": 200000 },
      "chan_multiSF_4": { "enable": true, "radio": 1, "if": -300000 },
      "chan_multiSF_5": { "enable": true, "radio": 1, "if": -100000 },
      "chan_multiSF_6": { "enable": true, "radio": 1, "if": 100000 },
      "chan_multiSF_7": { "enable": true, "radio": 1, "if": 300000 }
    }
  ],
  "nocca": true,
  "nodc": true,
  "nodwell": true
}

I will submit a PR for this issue shortly.