diff --git a/README.md b/README.md index ac890d4..23c8aad 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ devices: * Digi XBee 3 Global LTE Cat 1 (firmware 41519 and later) * Digi XBee 3 North America LTE Cat 1 (firmware 11519 and later) * Digi XBee BLU (firmware 4000 and later) +* Digi XBee Wi-SUN (firmware version B000 and later) Organization @@ -91,7 +92,7 @@ document. License ------- -This software is open-source software. Copyright Digi International, 2018-2024. +This software is open-source software. Copyright Digi International, 2018-2025. Samples within `samples/` folder, stub files in `typehints/` folder and most of the source code in the `lib/` directory is covered by the diff --git a/lib/sensor/ds1621/README.md b/lib/sensor/ds1621/README.md index 7532640..0d48fb6 100644 --- a/lib/sensor/ds1621/README.md +++ b/lib/sensor/ds1621/README.md @@ -17,3 +17,4 @@ Supported platforms * Digi XBee 3 Global LTE-M/NB-IoT - minimum firmware version: x18 * Digi XBee 3 Global LTE Cat 1 - minimum firmware version: 11519 * Digi XBee 3 North America LTE Cat 1 - minimum firmware version: 41519 +* Digi XBee Wi-SUN - minimum firmware version: B000 diff --git a/lib/sensor/hdc1080/README.md b/lib/sensor/hdc1080/README.md index bbdcf8d..22ba46f 100644 --- a/lib/sensor/hdc1080/README.md +++ b/lib/sensor/hdc1080/README.md @@ -17,3 +17,4 @@ Supported platforms * Digi XBee 3 Global LTE-M/NB-IoT - minimum firmware version: x18 * Digi XBee 3 Global LTE Cat 1 - minimum firmware version: 11519 * Digi XBee 3 North America LTE Cat 1 - minimum firmware version: 41519 +* Digi XBee Wi-SUN - minimum firmware version: B000 diff --git a/platforms/platforms.xml b/platforms/platforms.xml index bbe1bf3..2184e8d 100644 --- a/platforms/platforms.xml +++ b/platforms/platforms.xml @@ -82,4 +82,12 @@ XBee BLU + + xbee_wisun.png + xbee + + XBee Wi-SUN TH + XBee Wi-SUN + + diff --git a/platforms/xbee_wisun.png b/platforms/xbee_wisun.png new file mode 100644 index 0000000..27f4af5 Binary files /dev/null and b/platforms/xbee_wisun.png differ diff --git a/samples/adc_polling/README.md b/samples/adc_polling/README.md index 5c569c4..5dbca9c 100644 --- a/samples/adc_polling/README.md +++ b/samples/adc_polling/README.md @@ -103,11 +103,12 @@ Supported platforms * Digi XBee 3 Global LTE Cat 1 - minimum firmware version: 11519 * Digi XBee 3 North America LTE Cat 1 - minimum firmware version: 41519 * Digi XBee BLU - minimum firmware version: 4000 +* Digi XBee Wi-SUN - minimum firmware version: B000 License ------- -Copyright (c) 2019-2024, Digi International, Inc. +Copyright (c) 2019-2025, Digi International, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/samples/filesystem/README.md b/samples/filesystem/README.md index 5185fc5..56a183e 100644 --- a/samples/filesystem/README.md +++ b/samples/filesystem/README.md @@ -59,11 +59,12 @@ Supported platforms * Digi XBee 3 Global LTE Cat 1 - minimum firmware version: 11519 * Digi XBee 3 North America LTE Cat 1 - minimum firmware version: 41519 * Digi XBee BLU - minimum firmware version: 4000 +* Digi XBee Wi-SUN - minimum firmware version: B000 License ------- -Copyright (c) 2019-2024, Digi International, Inc. +Copyright (c) 2019-2025, Digi International, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/samples/gpio/blinking_led/README.md b/samples/gpio/blinking_led/README.md index e69194f..f07bb9c 100644 --- a/samples/gpio/blinking_led/README.md +++ b/samples/gpio/blinking_led/README.md @@ -51,11 +51,12 @@ Supported platforms * Digi XBee 3 Global LTE Cat 1 - minimum firmware version: 11519 * Digi XBee 3 North America LTE Cat 1 - minimum firmware version: 41519 * Digi XBee BLU - minimum firmware version: 4000 +* Digi XBee Wi-SUN - minimum firmware version: B000 License ------- -Copyright (c) 2019-2024, Digi International, Inc. +Copyright (c) 2019-2025, Digi International, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/samples/gpio/digital_input/README.md b/samples/gpio/digital_input/README.md index 9e8a03c..1d02eba 100644 --- a/samples/gpio/digital_input/README.md +++ b/samples/gpio/digital_input/README.md @@ -54,11 +54,12 @@ Supported platforms * Digi XBee 3 Global LTE Cat 1 - minimum firmware version: 11519 * Digi XBee 3 North America LTE Cat 1 - minimum firmware version: 41519 * Digi XBee BLU - minimum firmware version: 4000 +* Digi XBee Wi-SUN - minimum firmware version: B000 License ------- -Copyright (c) 2019-2024, Digi International, Inc. +Copyright (c) 2019-2025, Digi International, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/samples/i2c/i2c_ds1621_library/README.md b/samples/i2c/i2c_ds1621_library/README.md index 4c1ff94..416ccba 100644 --- a/samples/i2c/i2c_ds1621_library/README.md +++ b/samples/i2c/i2c_ds1621_library/README.md @@ -82,11 +82,12 @@ Supported platforms * Digi XBee 3 Global LTE-M/NB-IoT - minimum firmware version: x18 * Digi XBee 3 Global LTE Cat 1 - minimum firmware version: 11519 * Digi XBee 3 North America LTE Cat 1 - minimum firmware version: 41519 +* Digi XBee Wi-SUN - minimum firmware version: B000 License ------- -Copyright (c) 2019, Digi International, Inc. +Copyright (c) 2019-2025, Digi International, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/samples/i2c/i2c_eeprom/README.md b/samples/i2c/i2c_eeprom/README.md index 7744039..1d36f55 100644 --- a/samples/i2c/i2c_eeprom/README.md +++ b/samples/i2c/i2c_eeprom/README.md @@ -108,11 +108,12 @@ Supported platforms * Digi XBee 3 Global LTE-M/NB-IoT - minimum firmware version: x18 * Digi XBee 3 Global LTE Cat 1 - minimum firmware version: 11519 * Digi XBee 3 North America LTE Cat 1 - minimum firmware version: 41519 +* Digi XBee Wi-SUN - minimum firmware version: B000 License ------- -Copyright (c) 2019, Digi International, Inc. +Copyright (c) 2019-2025, Digi International, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/samples/i2c/i2c_hdc1080/README.md b/samples/i2c/i2c_hdc1080/README.md index 1a83af4..d409a3f 100644 --- a/samples/i2c/i2c_hdc1080/README.md +++ b/samples/i2c/i2c_hdc1080/README.md @@ -77,11 +77,12 @@ Supported platforms * Digi XBee 3 Global LTE-M/NB-IoT - minimum firmware version: x18 * Digi XBee 3 Global LTE Cat 1 - minimum firmware version: 11519 * Digi XBee 3 North America LTE Cat 1 - minimum firmware version: 41519 +* Digi XBee Wi-SUN - minimum firmware version: B000 License ------- -Copyright (c) 2019, Digi International, Inc. +Copyright (c) 2019-2025, Digi International, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/samples/i2c/i2c_hdc1080_library/README.md b/samples/i2c/i2c_hdc1080_library/README.md index 31fda33..967e22d 100644 --- a/samples/i2c/i2c_hdc1080_library/README.md +++ b/samples/i2c/i2c_hdc1080_library/README.md @@ -86,11 +86,12 @@ Supported platforms * Digi XBee 3 Global LTE-M/NB-IoT - minimum firmware version: x18 * Digi XBee 3 Global LTE Cat 1 - minimum firmware version: 11519 * Digi XBee 3 North America LTE Cat 1 - minimum firmware version: 41519 +* Digi XBee Wi-SUN - minimum firmware version: B000 License ------- -Copyright (c) 2019, Digi International, Inc. +Copyright (c) 2019-2025, Digi International, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/samples/i2c/i2c_scanner/README.md b/samples/i2c/i2c_scanner/README.md index eb55408..6d172f0 100644 --- a/samples/i2c/i2c_scanner/README.md +++ b/samples/i2c/i2c_scanner/README.md @@ -78,11 +78,12 @@ Supported platforms * Digi XBee 3 Global LTE-M/NB-IoT - minimum firmware version: x18 * Digi XBee 3 Global LTE Cat 1 - minimum firmware version: 11519 * Digi XBee 3 North America LTE Cat 1 - minimum firmware version: 41519 +* Digi XBee Wi-SUN - minimum firmware version: B000 License ------- -Copyright (c) 2019, Digi International, Inc. +Copyright (c) 2019-2025, Digi International, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/samples/pwm_duty/README.md b/samples/pwm_duty/README.md index f509623..98b335c 100644 --- a/samples/pwm_duty/README.md +++ b/samples/pwm_duty/README.md @@ -71,11 +71,12 @@ Supported platforms * Digi XBee 3 Global LTE-M/NB-IoT - minimum firmware version: x18 * Digi XBee 3 Global LTE Cat 1 - minimum firmware version: 11519 * Digi XBee 3 North America LTE Cat 1 - minimum firmware version: 41519 +* Digi XBee Wi-SUN - minimum firmware version: B000 License ------- -Copyright (c) 2019, Digi International, Inc. +Copyright (c) 2019-2025, Digi International, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/samples/watchdog/README.md b/samples/watchdog/README.md index e2c732b..04bbe97 100644 --- a/samples/watchdog/README.md +++ b/samples/watchdog/README.md @@ -45,11 +45,12 @@ Supported platforms * Digi XBee3 802.15.4 - minimum firmware version: 200A * Digi XBee3 DigiMesh 2.4 - minimum firmware version: 300A * Digi XBee BLU - minimum firmware version: 4000 +* Digi XBee Wi-SUN - minimum firmware version: B000 License ------- -Copyright (c) 2020-2024, Digi International, Inc. +Copyright (c) 2019-2025, Digi International, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/samples/xbee/at_commands/README.md b/samples/xbee/at_commands/README.md index 176e2b0..6735428 100644 --- a/samples/xbee/at_commands/README.md +++ b/samples/xbee/at_commands/README.md @@ -51,11 +51,12 @@ Supported platforms * Digi XBee 3 Global LTE Cat 1 - minimum firmware version: 11519 * Digi XBee 3 North America LTE Cat 1 - minimum firmware version: 41519 * Digi XBee BLU - minimum firmware version: 4000 +* Digi XBee Wi-SUN - minimum firmware version: B000 License ------- -Copyright (c) 2019-2024, Digi International, Inc. +Copyright (c) 2019-2025, Digi International, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/samples/xbee/communication/receive_data_ipv6/README.md b/samples/xbee/communication/receive_data_ipv6/README.md new file mode 100644 index 0000000..f51b4fb --- /dev/null +++ b/samples/xbee/communication/receive_data_ipv6/README.md @@ -0,0 +1,98 @@ +Receive Data IPv6 Sample Application +==================================== + +This example demonstrates the usage of the socket IPv6 API by giving an example +of how to receive data from other XBee device in the same Wi-SUN network. + +Requirements +------------ + +To run this example you need: + +* Two XBee Wi-SUN modules. +* Two carrier boards for the radio modules (XBIB-U-DEV or XBIB-C board). +* One Wi-SUN border router. +* Digi XBee Studio v1.2.0 or higher (available at www.digi.com/xbee-studio). + +Setup +----- + +The XBee module that runs this sample will act as receiver, while the other +one will act as sender. + +Make sure the hardware is set up correctly: + +1. Plug the XBee radio modules into the XBee adapters and connect them to your + computer's USB ports. +2. Ensure that the sender module is in API mode and both modules are on the + same Wi-SUN network. + +Run +--- + +The example is already configured, so all you need to do is to compile and +launch the application. + +Then, you need to send a data frame to the receiver module from the sender one. +Follow these steps to do so: + +1. Open XBee Studio and wait until the sender XBee module is discovered. +2. In the left menu, go to the **XBee Console** page and open the connection. +3. Create and add an API frame to the **Send data** list with the following + parameters: + + - Frame type: 0x40 - Socket Create + - Frame ID: 01 + - Protocol: UDP [00] + +4. Send this packet by selecting it and clicking the **Send selected packet** + button. Click the received *Socket Create Response* packet and look for the + assigned *Socket ID*. +5. Create another API frame with the following parameters: + + - Frame type: 0x47 - Socket SendTo + - Frame ID: 02 + - Socket ID: Use the ID received in the previous packet + - Dest. address: Use the IPv6 address printed in the REPL console + - Dest. port: 12 34 + - Transmit options: 00 + - Payload: Hello, Wi-SUN module! + +6. Send this packet by selecting it and clicking the **Send selected packet** + button. + +When the data frame is sent, verify that a line with the sender address and the +data included in the **Payload** field is printed out in the REPL console: + + Data received from XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX >> Hello, Wi-SUN module! + +Where *XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX* is the IPv6 address of the +sender module. + +Supported platforms +------------------- + +* Digi XBee Wi-SUN - minimum firmware version: B000 + +License +------- + +Copyright (c) 2025, Digi International, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/samples/xbee/communication/receive_data_ipv6/main.py b/samples/xbee/communication/receive_data_ipv6/main.py new file mode 100644 index 0000000..3dd0584 --- /dev/null +++ b/samples/xbee/communication/receive_data_ipv6/main.py @@ -0,0 +1,55 @@ +# Copyright (c) 2025, Digi International, Inc. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +import socket +import time +import xbee + + +PORT = 0x1234 + + +print(" +-------------------------------------------+") +print(" | XBee MicroPython Receive Data IPv6 Sample |") +print(" +-------------------------------------------+\n") + +print("Waiting for the module to be connected to the network...") + +ai = xbee.atcmd("AI") +while ai != 0: + time.sleep(1) + ai = xbee.atcmd("AI") + +local_addr = xbee.atcmd("MY") +print("Receiver IPv6 address: %s" % local_addr) + +# Create the socket. +s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM) +s.bind((local_addr, PORT)) + +print("Waiting for data...\n") + +try: + while True: + # Receive messages. + data, address = s.recvfrom(1024) + print("Data received from %s >> %s" % (address, data.decode())) +finally: + s.close() diff --git a/samples/xbee/communication/relay_frames/README.md b/samples/xbee/communication/relay_frames/README.md index 9138dcc..3edfbe5 100644 --- a/samples/xbee/communication/relay_frames/README.md +++ b/samples/xbee/communication/relay_frames/README.md @@ -75,11 +75,12 @@ Supported platforms * Digi XBee 3 Global LTE Cat 1 - minimum firmware version: 11519 * Digi XBee 3 North America LTE Cat 1 - minimum firmware version: 41519 * Digi XBee BLU - minimum firmware version: 4000 +* Digi XBee Wi-SUN - minimum firmware version: B000 License ------- -Copyright (c) 2019-2024, Digi International, Inc. +Copyright (c) 2019-2025, Digi International, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/samples/xbee/communication/relay_frames_button/README.md b/samples/xbee/communication/relay_frames_button/README.md index 079748e..6f73138 100644 --- a/samples/xbee/communication/relay_frames_button/README.md +++ b/samples/xbee/communication/relay_frames_button/README.md @@ -64,11 +64,12 @@ Supported platforms * Digi XBee 3 Global LTE Cat 1 - minimum firmware version: 11519 * Digi XBee 3 North America LTE Cat 1 - minimum firmware version: 41519 * Digi XBee BLU - minimum firmware version: 4000 +* Digi XBee Wi-SUN - minimum firmware version: B000 License ------- -Copyright (c) 2019-2024, Digi International, Inc. +Copyright (c) 2019-2025, Digi International, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/samples/xbee/communication/relay_frames_callback/README.md b/samples/xbee/communication/relay_frames_callback/README.md index b60ebe5..8a14788 100644 --- a/samples/xbee/communication/relay_frames_callback/README.md +++ b/samples/xbee/communication/relay_frames_callback/README.md @@ -73,11 +73,12 @@ Supported platforms * Digi XBee3 Zigbee 3 - minimum firmware version: 100B * Digi XBee3 802.15.4 - minimum firmware version: 2008 * Digi XBee BLU - minimum firmware version: 4000 +* Digi XBee Wi-SUN - minimum firmware version: B000 License ------- -Copyright (c) 2020-2024, Digi International, Inc. +Copyright (c) 2020-2025, Digi International, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/samples/xbee/communication/relay_frames_led/README.md b/samples/xbee/communication/relay_frames_led/README.md index b717eeb..9edf562 100644 --- a/samples/xbee/communication/relay_frames_led/README.md +++ b/samples/xbee/communication/relay_frames_led/README.md @@ -78,11 +78,12 @@ Supported platforms * Digi XBee 3 Global LTE Cat 1 - minimum firmware version: 11519 * Digi XBee 3 North America LTE Cat 1 - minimum firmware version: 41519 * Digi XBee BLU - minimum firmware version: 4000 +* Digi XBee Wi-SUN - minimum firmware version: B000 License ------- -Copyright (c) 2019-2024, Digi International, Inc. +Copyright (c) 2019-2025, Digi International, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/samples/xbee/communication/transmit_data_ipv6/README.md b/samples/xbee/communication/transmit_data_ipv6/README.md new file mode 100644 index 0000000..34e7746 --- /dev/null +++ b/samples/xbee/communication/transmit_data_ipv6/README.md @@ -0,0 +1,101 @@ +Transmit Data IPv6 Sample Application +===================================== + +This example demonstrates the usage of the socket IPv6 API by giving an example +of how to transmit data to other XBee device in the same Wi-SUN network. + +Requirements +------------ + +To run this example you need: + +* Two XBee Wi-SUN modules. +* Two carrier boards for the radio modules (XBIB-U-DEV or XBIB-C board). +* One Wi-SUN border router. +* Digi XBee Studio v1.2.0 or higher (available at www.digi.com/xbee-studio). + +Setup +----- + +The XBee module that runs this sample will act as sender, while the other +one will act as receiver. + +Make sure the hardware is set up correctly: + +1. Plug the XBee radio modules into the XBee adapters and connect them to your + computer's USB ports. +2. Ensure that the receiver module is in API mode and both modules are on the + same Wi-SUN network. +3. Find the IPv6 address of the receiver module in XBee Studio. It will be used + later in the example. + +Run +--- + +Before launching the application, you need to set up XBee Studio to see the data +received by the receiver module. Follow these steps to do so: + +1. Launch XBee Studio. +2. Wait until the receiver XBee module is discovered and click on it. +3. In the left menu, go to the **XBee Console** page and open the connection. +4. Create and add an API frame to the **Send data** list with the following + parameters: + + - Frame type: 0x40 - Socket Create + - Frame ID: 01 + - Protocol: UDP [00] + +5. Send this packet by selecting it and clicking the **Send selected packet** + button. Click the received *Socket Create Response* packet and look for the + assigned *Socket ID*. +6. Create another API frame with the following parameters: + + - Frame type: 0x46 - Socket Bind/Listen + - Frame ID: 02 + - Socket ID: Use the ID received in the previous packet + - Source port: 12 34 + +7. Send this packet by selecting it and clicking the **Send selected packet** + button. + +Fill the **TARGET_IPV6_ADDR** constant in the MicroPython application with the +IPv6 address of the receiver module. Finally, compile and launch the MicroPython +application. It prints out the status of the operation in the console: + + Sending data to XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX >> Hello, Wi-SUN module! + Data sent successfully + +Verify that a new **Socket Receive From: IPv6** packet has been received in the +XBee Studio console. Select it and review the details, some of them similar to: + + - Frame type: CB (Socket Receive From: IPv6) + - Source address: The XBee sender's IPv6 address + - Payload data (ASCII): Hello, Wi-SUN module! + +Supported platforms +------------------- + +* Digi XBee Wi-SUN - minimum firmware version: B000 + +License +------- + +Copyright (c) 2025, Digi International, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/samples/xbee/communication/transmit_data_ipv6/main.py b/samples/xbee/communication/transmit_data_ipv6/main.py new file mode 100644 index 0000000..6b7c668 --- /dev/null +++ b/samples/xbee/communication/transmit_data_ipv6/main.py @@ -0,0 +1,55 @@ +# Copyright (c) 2025, Digi International, Inc. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +import socket +import time +import xbee + + +# TODO: replace with the IPv6 address of the other Wi-SUN module. +TARGET_IPV6_ADDR = "0000:0000:0000:0000:0000:0000:0000:0000" +PORT = 0x1234 +MESSAGE = b"Hello, Wi-SUN module!" + + +print(" +--------------------------------------------+") +print(" | XBee MicroPython Transmit Data IPv6 Sample |") +print(" +--------------------------------------------+\n") + +print("Waiting for the module to be connected to the network...") + +ai = xbee.atcmd("AI") +while ai != 0: + time.sleep(1) + ai = xbee.atcmd("AI") + +# Create the socket. +s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM) + +print("Sending data to %s >> %s" % (TARGET_IPV6_ADDR, str(MESSAGE, "utf8"))) + +try: + # Send the message to the module. + s.sendto(MESSAGE, (TARGET_IPV6_ADDR, PORT)) + print("Data sent successfully") +except Exception as e: + print("Transmit failure: %s" % str(e)) +finally: + s.close() diff --git a/samples/xbee/communication/transmit_multicast_data_ipv6/README.md b/samples/xbee/communication/transmit_multicast_data_ipv6/README.md new file mode 100644 index 0000000..276101d --- /dev/null +++ b/samples/xbee/communication/transmit_multicast_data_ipv6/README.md @@ -0,0 +1,99 @@ +Transmit Multicast Data IPv6 Sample Application +=============================================== + +This example demonstrates the usage of the socket API by giving an example of +how to transmit a multicast message to all XBee devices in the same Wi-SUN +network. + +Requirements +------------ + +To run this example you need: + +* Two XBee Wi-SUN modules. +* Two carrier boards for the radio modules (XBIB-U-DEV or XBIB-C board). +* One Wi-SUN border router. +* Digi XBee Studio v1.2.0 or higher (available at www.digi.com/xbee-studio). + +Setup +----- + +The XBee module that runs this sample will act as sender, while the other +one will act as receiver. + +Make sure the hardware is set up correctly: + +1. Plug the XBee radio modules into the XBee adapters and connect them to your + computer's USB ports. +2. Ensure that the receiver module is in API mode and both modules are on the + same Wi-SUN network. + +Run +--- + +Before launching the application, you need to set up XBee Studio to see the data +received by the receiver module. Follow these steps to do so: + +1. Launch XBee Studio. +2. Wait until the receiver XBee module is discovered and click on it. +3. In the left menu, go to the **XBee Console** page and open the connection. +4. Create and add an API frame to the **Send data** list with the following + parameters: + + - Frame type: 0x40 - Socket Create + - Frame ID: 01 + - Protocol: UDP [00] + +5. Send this packet by selecting it and clicking the **Send selected packet** + button. Click the received *Socket Create Response* packet and look for the + assigned *Socket ID*. +6. Create another API frame with the following parameters: + + - Frame type: 0x46 - Socket Bind/Listen + - Frame ID: 02 + - Socket ID: Use the ID received in the previous packet + - Source port: 12 34 + +7. Send this packet by selecting it and clicking the **Send selected packet** + button. + +Finally, compile and launch the MicroPython application. It prints out the +status of the operation in the console: + + Sending multicast data >> Hello, Wi-SUN nodes! + Data sent successfully + +Verify that a new **Socket Receive From: IPv6** packet has been received in the +XBee Studio console. Select it and review the details, some of them similar to: + + - Frame type: CB (Socket Receive From: IPv6) + - Source address: The XBee sender's IPv6 address + - Payload data (ASCII): Hello, Wi-SUN nodes! + +Supported platforms +------------------- + +* Digi XBee Wi-SUN - minimum firmware version: B000 + +License +------- + +Copyright (c) 2025, Digi International, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/samples/xbee/communication/transmit_multicast_data_ipv6/main.py b/samples/xbee/communication/transmit_multicast_data_ipv6/main.py new file mode 100644 index 0000000..90eaaac --- /dev/null +++ b/samples/xbee/communication/transmit_multicast_data_ipv6/main.py @@ -0,0 +1,54 @@ +# Copyright (c) 2025, Digi International, Inc. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +import socket +import time +import xbee + + +MULTICAST_GROUP = "ff02::1" +PORT = 0x1234 +MESSAGE = b"Hello, Wi-SUN nodes!" + + +print(" +------------------------------------------------------+") +print(" | XBee MicroPython Transmit Multicast Data IPv6 Sample |") +print(" +------------------------------------------------------+\n") + +print("Waiting for the module to be connected to the network...") + +ai = xbee.atcmd("AI") +while ai != 0: + time.sleep(1) + ai = xbee.atcmd("AI") + +# Create the socket. +s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM) + +print("Sending multicast data >> %s" % str(MESSAGE, "utf8")) + +try: + # Send the message to all nodes. + s.sendto(MESSAGE, (MULTICAST_GROUP, PORT)) + print("Data sent successfully") +except Exception as e: + print("Transmit failure: %s" % str(e)) +finally: + s.close()