-
Notifications
You must be signed in to change notification settings - Fork 0
05 Getting started examples
For Windows users, you must clone the project into the WSL2 filesystem. Not the Windows filesystem.
-
Clone the repo
git clone https://github.com/Azure-Sphere-DevX/EdgeDevX.Examples.git
-
Initialize and update the repo submodules
cd EdgeDevX.Examples && git submodule update --init --recursive
- On macOS, build with the Clang compiler.
- On Linux, build with the GCC compiler.
There are six examples in the EdgeDevX.Examples repo:
-
simple_publish:
- Demonstrates simple publish message to Azure IoT Hub or IoT Central.
-
avnet_end_to_end:
- Demonstrates the use of the EdgeDevX library to publishing data, device twins and direct methods to Azure IoT Services.
-
avnet_end_to_end_ext:
- Demonstrates the use of the EdgeDevX library in conjunction with the RemoteX library to publishing data, device twins and direct methods to Azure IoT Services.
- This example uses the RemoteX library to interaction with an Avnet Azure Sphere device across your network to read sensor data.
- Update the RemoteX.cmake file with the IP address of your Azure Sphere.
-
device_twins:
- Simple example demonstarting the use of device twin bindings and binding functions to Azure IoT Services.
-
direct_methods:
- Simple example demonstarting the use of direct method bindings and binding functions with Azure IoT Services.
-
environment_logger:
- RemoteX example demonstrating Azure Sphere remote peripheral access to an 8x8 LED panel, reading sensr data from an Avent Azure Sphere dev board and logging data to mutable storage.
- Update the RemoteX.cmake file with the IP address of your Azure Sphere.
-
GPIO on Linux:
- Demostrates using GPIO on Linux.
-
hello_world:
- Simple example of using the Azure Sphere RemoteX library. Update the RemoteX.cmake file with the IP address of your Azure Sphere.
-
openai_functions:
- Build a conversational intelligent edge device with OpenAI Functions.
-
Altair 8800 Emulator
- This is the EdgeDevX implementation of the Cloud Enabled Altair 8800 on Azure Sphere project. The code base for the EdgeDevX version and the Azure Sphere Altair project is 99% the same.
The following steps assumed you are going to run the avnet_end_to_end example from Visual Studio Code
-
Start Visual Studio Code
-
If you are using a Linux or macOS computer, then open the avnet_end_to_end folder in the EdgeDevX.Examples folder.
-
If you are a Windows user, then you cloned the repo into the WSL filesystem. Open the project with using the VS Code Remote WSL extension.
-
If you cloned the repo to a network connected Linux computer (including a Raspberry Pi), open the project using the VS Code Remote SSL extension.
-
Open the .vscode/launch.json file and update the args property with your IoT DPS or IoT Central config.
"args": [ "-s", "ID_SCOPE", "-d", "DEVICE_ID", "-k", "DERIVED_DEVICE_KEY", "-n", "NETWORK_INTERFACE" ],
The network interface is passed to the dx_azureConnect(&dx_config, dx_config.network_interface, IOT_PLUG_AND_PLAY_MODEL_ID); function in InitPeripheralsAndHandlers function.
The network interface argument is optional and declares the network interface with an active internet connection, for example, eth0, or wlan0. If the network interface is specified then an end to end network connectivity test to www.msftconnecttest.com is performed no more that once every 3 minutes. This is in line with the Networking_GetInterfaceConnectionStatus function.
-
If you plan to extent this application to use AzureSphereRemoteX then refer to Intro to Azure Sphere RemoteX.
-
Press F1, and select CMake: Delete Cache and Reconfigure.
-
Press F5 to start CMake build and run the project with the debugger.
-
Press Shift+F5 to start CMake build and run the project without the debugger.
The following is an example of running an IoT Hub/Central EdgeDevX application from the command line and appsing in the ID Scope, device id and device derived id.
-
Compile the application.
cd avnet_end_to_end && \ mkdir -p build && \ cmake -B build && \ cmake --build build --config release --target all && \ cd ..
Note, you can optismise the cmake build process by pss in the jobs argument with a number that matches the number of CPU cores on your computer. The following example optimises cmake for an 8 core CPU.
cd avnet_end_to_end && \ mkdir -p build && \ cmake -B build && \ time cmake --build build --config release --target all -j 8 && \ cd ..
-
Run the compiled application.
See IoT Hub and IoT Central configuration.
./build/avnet_end_to_end -s "<YOUR_ID_SCOPE>" -d "<YOUR_DEVICE_ID>" -k "<YOUR_DERIVED_DEVICE_KEY>"
-
Specifying the network interface
The network interface argument is optional and declares the network interface with an active internet connection, for example, eth0, or wlan0. If the network interface is specified then an end to end network connectivity test to http://www.msftconnecttest.com is performed no more that once every 3 minutes. This is in line with the Networking_GetInterfaceConnectionStatus function.
The network interface is passed to the dx_azureConnect(&dx_config, dx_config.network_interface, IOT_PLUG_AND_PLAY_MODEL_ID); function in InitPeripheralsAndHandlers function.
The following example specifies eth0 as the active internet connection.
./build/avnet_end_to_end -s "<YOUR_SCOPE_ID>" -d "<YOUR_DEVICE_ID>" -k "<YOUR_DERIVED_DEVICE_KEY>" -n "eth0"
You can list the network interfaces on your computer or linux device using the following tool. This will list all the network interfaces on the computer. Look for the adapter with a valid IP address. If you are using WSL then the network interface is eth0.
ifconfig