Skip to content

Commit 923f3e7

Browse files
committed
samples: add some samples for Cellular Router devices
Signed-off-by: Diego Escalona <[email protected]>
1 parent 76fa4bb commit 923f3e7

File tree

16 files changed

+1170
-0
lines changed

16 files changed

+1170
-0
lines changed
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
Handle SCI Requests Sample Application
2+
======================================
3+
4+
This sample Python application shows how to use the Cellular Router or XBee
5+
Gateway to receive and handle requests from Digi Remote Manager cloud.
6+
7+
The example registers a callback to process device requests with a specific
8+
target ID coming from the cloud and prints their value.
9+
10+
Requirements
11+
------------
12+
To run this example you will need:
13+
14+
* A Digi Cellular router or XBee gateway device.
15+
* A Digi Remote Manager account with your Digi device added to it.
16+
Go to https://myaccount.digi.com/ to create it if you do not have one.
17+
18+
Setup
19+
-----
20+
1. Make sure that the Digi Device is connected to Internet and it is registered
21+
in your Digi Remote Manager account.
22+
23+
Run
24+
---
25+
1. The example is already configured, so all you need to do is to build and
26+
launch the **Handle SCI Requests** application in the Digi device. The
27+
application prints the following message:
28+
29+
- Waiting for Digi Remote Manager requests...
30+
31+
2. In your Digi Remote Manager account, go to **Documentation > API Explorer**.
32+
Then, select the example **Examples > SCI > Data Service > Send Request** to
33+
generate the URL and template of the send request. Complete the request as
34+
follows:
35+
36+
<sci_request version="1.0">
37+
<data_service>
38+
<targets>
39+
<device id="00000000-00000000-XXXXXXXX-XXXXXXXX"/>
40+
</targets>
41+
<requests>
42+
<device_request target_name="myTarget">
43+
Hello from Digi Remote Manager!
44+
</device_request>
45+
</requests>
46+
</data_service>
47+
</sci_request>
48+
49+
where:
50+
51+
- `00000000-00000000-XXXXXXXX-XXXXXXXX` is the device ID of your Cellular
52+
Router or XBee Gateway device.
53+
- `myTarget` is the target name of the Digi Remote Manager requests
54+
handler you configured in the Python script. Both target names (the one
55+
from the Python script and the request one) must be the same. So, if
56+
you modified it in the script, update it in the request too.
57+
- `Hello from Digi Remote Manager!` is the content of the request.
58+
59+
3. Click the **Send** button to send the request to the device.
60+
61+
4. Verify that a new line is printed out in the console with the following
62+
message:
63+
64+
- Received request 'Hello from Digi Remote Manager!' for target 'myTarget'
65+
66+
Verify also that the **Response** tab of the **API Explorer** displays a
67+
response similar to:
68+
69+
<sci_reply version="1.0">
70+
<data_service>
71+
<device id="00000000-00000000-XXXXXXXX-XXXXXXXX">
72+
<requests>
73+
<device_request target_name="myTarget" status="0">OK</device_request>
74+
</requests>
75+
</device>
76+
</data_service>
77+
</sci_reply>
78+
79+
where:
80+
81+
- `00000000-00000000-XXXXXXXX-XXXXXXXX` is the device ID of your Cellular
82+
Router or XBee Gateway device.
83+
- `myTarget` is the target name of the Digi Remote Manager requests
84+
handler you configured in the Python script.
85+
- `OK` is the answer to the request reported by the Python script.
86+
87+
5. Press any key to halt the application execution.
88+
89+
Supported platforms
90+
-------------------
91+
* AnywhereUSBPlus
92+
* ConnectEZMini
93+
* ConnectEZ2
94+
* ConnectEZ4
95+
* ConnectEZ8
96+
* ConnectEZ1632
97+
* ConnectITMini
98+
* ConnectIT4
99+
* ConnectIT1648
100+
* EX12
101+
* EX15
102+
* EX50
103+
* IX10
104+
* IX15
105+
* IX20
106+
* IX30
107+
* LR54
108+
* TX54
109+
* TX64
110+
* TX64Rail
111+
112+
License
113+
-------
114+
Copyright (c) 2023, Digi International, Inc.
115+
116+
Permission is hereby granted, free of charge, to any person obtaining a copy
117+
of this software and associated documentation files (the "Software"), to deal
118+
in the Software without restriction, including without limitation the rights
119+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
120+
copies of the Software, and to permit persons to whom the Software is
121+
furnished to do so, subject to the following conditions:
122+
123+
The above copyright notice and this permission notice shall be included in all
124+
copies or substantial portions of the Software.
125+
126+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
127+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
128+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
129+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
130+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
131+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
132+
SOFTWARE.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Copyright 2023, Digi International Inc.
2+
#
3+
# Permission to use, copy, modify, and/or distribute this software for any
4+
# purpose with or without fee is hereby granted, provided that the above
5+
# copyright notice and this permission notice appear in all copies.
6+
#
7+
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8+
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9+
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10+
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11+
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12+
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13+
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14+
15+
from digidevice import device_request
16+
17+
# TODO: Replace with the target name you prefer.
18+
DRM_TARGET = "myTarget"
19+
20+
21+
def main():
22+
print(" +----------------------------+")
23+
print(" | Handle SCI Requests Sample |")
24+
print(" +----------------------------+\n")
25+
26+
# Define the Digi Remote Manager requests handler.
27+
def handler(target, request):
28+
print("- Received request '%s' for target '%s'" % (request.strip(),
29+
target))
30+
# Send an answer to Digi Remote Manager.
31+
return "OK"
32+
33+
try:
34+
# Register the Digi Remote Manager callback.
35+
device_request.register(DRM_TARGET, handler)
36+
37+
print("- Waiting for Digi Remote Manager requests...\n")
38+
input()
39+
40+
finally:
41+
# Un-register the callback.
42+
device_request.del_data_received_callback(handler)
43+
44+
45+
if __name__ == "__main__":
46+
main()
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
Upload Device Name Sample Application
2+
=====================================
3+
4+
This sample Python application shows how to upload a custom name for your
5+
device to Digi Remote Manager.
6+
7+
The example changes the name of the Digi device in Digi Remote Manager with
8+
the value of the `NEW_DEVICE_NAME` constant.
9+
10+
You should take this considerations into account when changing the name of
11+
your device in Digi Remote Manager:
12+
13+
- If the name is being used by to another device in your Remote Manager
14+
account, the name will be removed from the previous device and added to the
15+
new device.
16+
- If Remote Manager is configured to apply a profile to a device based on the
17+
device name, changing the name of the device may cause Remote Manager to
18+
automatically push a profile onto the device.
19+
20+
Requirements
21+
------------
22+
To run this example you will need:
23+
24+
* A Digi Cellular router or XBee gateway device.
25+
* A Digi Remote Manager account with your Digi device added to it.
26+
Go to https://myaccount.digi.com/ to create it if you do not have one.
27+
28+
Setup
29+
-----
30+
1. Make sure that the Digi Device is connected to Internet and it is registered
31+
in your Digi Remote Manager account.
32+
33+
2. Make sure your account allows remote name updates in Digi Remote Manager.
34+
To enable such feature, access Remote Manager and go to **Documentation >
35+
API Explorer**. There, configure the following elements:
36+
37+
- **Path**: `/ws/v1/settings/inventory/AllowDeviceToSetOwnNameEnabled`
38+
- **HTTP Method**: `PUT`
39+
- **HTTP Message**:
40+
41+
{
42+
"name" : "AllowDeviceToSetOwnNameEnabled",
43+
"value" : "true"
44+
}
45+
46+
Then, click **Send**.
47+
48+
Run
49+
---
50+
1. The example is already configured, so all you need to do is to build and
51+
launch the **Upload Device Name** application in the Digi device. The
52+
application just updates the name of the device in Digi Remote Manager with
53+
the one configured in the `NEW_DEVICE_NAME` constant. To indicate so, it
54+
displays the following message in the console log:
55+
56+
- Updating the device name with 'MY-DEVICE' to Digi Remote Manager
57+
58+
2. In your Digi Remote Manager account, go to **Device Management** tab and
59+
click the **Refresh** button. Then, verify that the **Device Name** column
60+
of the devices table displays the new name for your Digi Device.
61+
62+
Supported platforms
63+
-------------------
64+
* AnywhereUSBPlus
65+
* ConnectEZMini
66+
* ConnectEZ2
67+
* ConnectEZ4
68+
* ConnectEZ8
69+
* ConnectEZ1632
70+
* ConnectITMini
71+
* ConnectIT4
72+
* ConnectIT1648
73+
* EX12
74+
* EX15
75+
* EX50
76+
* IX10
77+
* IX15
78+
* IX20
79+
* IX30
80+
* LR54
81+
* TX54
82+
* TX64
83+
* TX64Rail
84+
85+
License
86+
-------
87+
Copyright (c) 2023, Digi International, Inc.
88+
89+
Permission is hereby granted, free of charge, to any person obtaining a copy
90+
of this software and associated documentation files (the "Software"), to deal
91+
in the Software without restriction, including without limitation the rights
92+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
93+
copies of the Software, and to permit persons to whom the Software is
94+
furnished to do so, subject to the following conditions:
95+
96+
The above copyright notice and this permission notice shall be included in all
97+
copies or substantial portions of the Software.
98+
99+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
100+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
101+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
102+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
103+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
104+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
105+
SOFTWARE.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright 2023, Digi International Inc.
2+
#
3+
# Permission to use, copy, modify, and/or distribute this software for any
4+
# purpose with or without fee is hereby granted, provided that the above
5+
# copyright notice and this permission notice appear in all copies.
6+
#
7+
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8+
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9+
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10+
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11+
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12+
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13+
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14+
15+
from digidevice import name
16+
17+
# TODO: Replace with the name you desire for your device
18+
NEW_DEVICE_NAME = "MY-DEVICE"
19+
20+
21+
def main():
22+
print(" +---------------------------+")
23+
print(" | Upload Device Name Sample |")
24+
print(" +---------------------------+\n")
25+
26+
print("Uploading device name with '%s' to Digi Remote Manager" % NEW_DEVICE_NAME)
27+
name.upload(NEW_DEVICE_NAME)
28+
29+
30+
if __name__ == "__main__":
31+
main()

0 commit comments

Comments
 (0)