This example device service watches files on the local system and uploads their content each time they are modified. The example illustrates the use of the devsdk_post_readings function to deliver events asynchronously.
The environment variable CSDK_DIR should be set to a directory containing the C SDK include files and libraries.
Set LD_LIBRARY_PATH to $CSDK_DIR/lib:/opt/iotech/iot/1.5/lib
gcc -I$CSDK_DIR/include -I/opt/iotech/iot/1.5/include -L$CSDK_DIR/lib -L/opt/iotech/iot/1.5/lib -o device-file device-file.c -lcsdk -liot
A device profile for the file devices is provided in the res
directory. This will be uploaded to core-metadata by the device service on first run. The profile sets the MIME type of the files to text/plain, additional profiles could be constructed to specify files of other types.
The supplied configuration file res/configuration.yaml
includes a definition for a single file device. The only protocol property required to address the device is its filename.
An EdgeX system containing at least a database and the core-data and core-metadata services must be running. The configuration file must be edited to reflect the locations of the core-data and core-metadata services.
./device-file -cp=keeper.http://localhost:59890
To trigger a file upload:
echo "Bump!" >> ./res/lorem.txt