I have a custom gateway built with a Raspberry Pi CM3+ module and a RAK2245 Concentrator. This gateway has a cellular modem and wifi module connected over USB. I got everything up and running great on WiFi. I have a script that connects to AWS to upload data and get commands for the gateway.
In the field, this gateway will connect to AWS over cell, and my problems begin when I disconnect the WiFi. When I do this, I can no longer use the Rest API to add anything. Here is the functioning output of my script working over WiFi:
Logging in to Chirpstack API: http://localhost:8080/api/internal/login
{
“password”: “admin”,
“username”: “admin”
}
<Response [200]>
Received message 1 from topic ‘Network/Down/GW0000010103’: {“14”:“1003005,1,Test2,2659339aff8342cdbf5cba1f30392a9a”}
{‘14’: ‘1003005,1,Test2,2659339aff8342cdbf5cba1f30392a9a’}
Add new device command received. GUID: 1003005, Type: 1, Name: Test2, Key: 2659339aff8342cdbf5cba1f30392a9a
77828478000f4dfd
Checking if device exists: http://localhost:8080/api/devices/77828478000f4dfd
<Response [404]>
{‘error’: ‘object does not exist’, ‘code’: 5, ‘message’: ‘object does not exist’, ‘details’: []}
Device does not exist. Adding device.
First getting application and device profile IDs.
Getting Application ID: http://localhost:8080/api/applications?limit=1000
Application name: PI-Data-Server id: 1
Getting Device Profile ID: http://localhost:8080/api/device-profiles?limit=1000
Device profile name: Position Indicator id: bb464183-94f4-49e3-a257-919f14cadb91
{
“device”:{“applicationID”: “1”, “devEUI”: “77828478000f4dfd”, “deviceProfileID”: “bb464183-94f4-49e3-a257-919f14cadb91”, “name”: “Test2”}
}
Creating device http://localhost:8080/api/devices
<Response [200]>
{}
Setting device keys http://localhost:8080/api/devices/77828478000f4dfd/keys
<Response [200]>
{}
Verifying Device Profile…http://localhost:8080/api/devices/77828478000f4dfd
<Response [200]>
{‘device’: {‘devEUI’: ‘77828478000f4dfd’, ‘name’: ‘Test2’, ‘applicationID’: ‘1’, ‘description’: ‘’, ‘deviceProfileID’: ‘bb464183-94f4-49e3-a257-919f14cadb91’, ‘skipFCntCheck’: False, ‘referenceAltitude’: 0, ‘variables’: {}, ‘tags’: {}}, ‘lastSeenAt’: None, ‘deviceStatusBattery’: 256, ‘deviceStatusMargin’: 256, ‘location’: None}
{‘devEUI’: ‘77828478000f4dfd’, ‘name’: ‘Test2’, ‘applicationID’: ‘1’, ‘description’: ‘’, ‘deviceProfileID’: ‘bb464183-94f4-49e3-a257-919f14cadb91’, ‘skipFCntCheck’: False, ‘referenceAltitude’: 0, ‘variables’: {}, ‘tags’: {}}
When I unplug the WiFi I can still access the api directly by running a python script from the command line. Adding a device works the same as above. I can bring up my cellular ppp0 interface and everything works fine.
When I reboot without WiFi plugged in to test conditions as they will be in the field. I can not add a device with the same python script. My output looks like this:
Logging in to Chirpstack API: http://localhost:8080/api/internal/login
{
“password”: “admin”,
“username”: “admin”
}
<Response [200]>
77828478000fa0e7
Checking if device exists: http://localhost:8080/api/devices/77828478000fa0e7
<Response [404]>
{‘error’: ‘object does not exist’, ‘code’: 5, ‘message’: ‘object does not exist’, ‘details’: []}
Device does not exist. Adding device.
First getting application and device profile IDs.
Getting Application ID: http://localhost:8080/api/applications?limit=1000
Application name: PI-Data-Server id: 1
Getting Device Profile ID: http://localhost:8080/api/device-profiles?limit=1000
Device profile name: Position Indicator id: bb464183-94f4-49e3-a257-919f14cadb91
{
“device”:{“applicationID”: “1”, “devEUI”: “77828478000fa0e7”, “deviceProfileID”: “bb464183-94f4-49e3-a257-919f14cadb91”, “name”: “afq”}
}
Creating device http://localhost:8080/api/devices
<Response [500]>
{‘error’: ‘context deadline exceeded’, ‘code’: 2, ‘message’: ‘context deadline exceeded’, ‘details’: []}
Setting device keys http://localhost:8080/api/devices/77828478000fa0e7/keys
<Response [404]>
{‘error’: ‘object does not exist’, ‘code’: 5, ‘message’: ‘object does not exist’, ‘details’: []}
Verifying Device Profile…http://localhost:8080/api/devices/77828478000fa0e7
<Response [404]>
{‘error’: ‘object does not exist’, ‘code’: 5, ‘message’: ‘object does not exist’, ‘details’: []}
So I can login and get data with the API, but I can not create a device. The error response “{‘error’: ‘context deadline exceeded’, ‘code’: 2, ‘message’: ‘context deadline exceeded’, ‘details’: []}”
Does not give me any clues. Bringing up the ppp0 interface does not help either.
I’m lost. Any ideas?