This repo contains bash scripts to setup a build enviroment to use DeviceBuilder with IoTivity. The build enviroment is taylored to create OCF Server Devices.
The local installation of the Tool Chain can be done with a single curl command:
curl https://openconnectivity.github.io/IOTivity-Lite-setup/install.sh | bash
The curl command sets up the Tool Chain on the (development) machine. The script installs various tools and github repositories that are needed to use the Tool Chain. For windows, visual studio is needed as an extra installation step, see here for Windows Specific additional instructions.
Executing the installation command requires:
Note that installing a git client on Windows also installs a BASH shell script environment.
Use the following command to use the master (latest code) of Iotivity-Lite:
curl https://openconnectivity.github.io/IOTivity-Lite-setup/install-master.sh | bash
The following Tool Chain is created:
Folder structure after everything is installed and code is generated: The installDeviceBuilder script generates scripts in the top level folder (e.g. the folder above this repo). The generated scripts are convienent scripts, e.g. they are short cuts for entering generation, build, excute and reset commands. For more advanced usage, use the commands in the scrips itself, it allows for more flexibility in the development process.
Typical development setup contains the following configuration:
Where:
See here for more information on OTGC.
Note that a Windows (10) PC can be used to run OCFDeviceSpy as OCF Onboarding Tool and Client. Device Spy is a lower level OCF client where the user needs to interact with the device on JSON level.
Website | Repo | Description |
---|---|---|
DeviceBuilder | DeviceBuilder | Tool Chain |
swagger2x | swagger2x | templated code generation |
IoTivity | IoTivity | OCF Secure IP Device Framework |
[OTdataModels | IOTdataModels | website: IOTdataModels |
core | core | OCF core data models |
OCF clients | OCF clients | OCF development clients (prebuild) |
The development flow is based on bash scripts, hence the flow is generalized for Linux based systems. The development flow is depicted the figure below:
These steps needs to be executed in the <>/iot-lite folder, e.g. the folder that gets created by running the curl installation command. The goal is to run an OCF server by creating code, building and running the OCF server application.
The repeat flow is modifying the generated code (without code generation):
If the device needs to be in ready for onboarding (for example after a crash), then run the script reset.sh
Information and Installers about the OCF clients for development support can be found here
Script: edit_input.sh
This script edits the device builder input file with Nano editor. The input file being edited is located at the top of the installed tree: <>/iot-lite/example.json Typical changes on the input file for code generation can be:
Things to check:
Information on available which device types should implement which resources can be found here. Information on the individual resources in OAS2.0 format can be found in here.
Recommendation:
Make sure that before starting to change the generated code, all resources & properties are supported by the generated code.
More information on the Device Builder input file can be found here This link contains the syntax and some examples of input files.
Nano is a small editor that can be used to edit files in windowless system. Nano is supplied on various linux systems like ubuntu and raspberry pi. Please make sure when generating a new version, that a changed file is saved under a different name. The nano beginners guide is available here.
Script: gen.sh
This script runs the Tool Chain with the predefined arguments:
The device type can be change from oic.d.light (default) to something different. The following mechanisms are available to change the device type:
The name can be change to something different. This can be done by giving an input parameter to gen.sh. for example gen.sh “blahblah” will turn the name of the server into “blahblah”. Default the name of the device is “server_lite_<PID>”, the PID is the current process number of the script. Hence the default name scheme creates unique device names.
Running this script generates the device_output folder AND copies the result to the correct executable folder in the iotivity-lite tree structure.
More info of the DeviceBuilder script can be found here.
Note that running gen.sh will overwrite the made code changes!!
script: edit_code.sh
This scripts edits the generated C code device_builder_server.c with Nano. The script loads the Nano editor with the generated code in the iotivity-lite tree. The saved file can be compiled without copy pasting.
Note that running gen.sh will overwrite the made changes!!
Typical changes to be applied on the code:
More info about the structure of the generated code can be found here.
Script: build.sh
Linux Only
This script builds the app device_builder_server.c by means of make.
It starts in the iotivity-lite/port/linux folder the make -f devbuildmake device_builder_server
command.
To build another port (e.g. OS):
To have clean build edit the build.sh file and comment out the line: make clean.
To build a server that is cloud capable, add on the command line the compile directive: CLOUD=1 e.g.: sh build.sh CLOUD=1
Script: run.sh
Linux Only
This script executes the compiled executable in the folder where the executable resides in.
It executes the device_builder_server executable (e.g. the server application) in folder:
<>/iotivity-lite/port/linux/
Note: The executable needs to be started in folder where it recides to avoid issues with reading the security data.
Script: reset.sh
This script deletes the SVR settings in the security folder:
<>/iotivity-lite/port/linux/device_builder_server_creds
The device will go to the ready for onboarding state.
Script: pki.sh
This script creates PKI based certificates and converts them into an header file. The generated certificates are TEST certificates, these certificates are to be used for testing only.
See here for more info on security options.
Instructions to add your own Resource models are available here.
Windows specific instructions (using Visual Studio) are available here.
Please execute the curl command in a folder hierarchy without blanks. Blanks in the folder name causes issues with going back and forth in the created folders.