From 104f9abf61b30095fc8a37e3aa990ef7c9dc413a Mon Sep 17 00:00:00 2001 From: L00163331 Date: Mon, 21 Aug 2023 23:34:39 +0100 Subject: [PATCH 1/3] Main --- IoT Plug and Play mobile.json | 409 ++++++++++++++++++++++++++++++++++ iot.dockerfile | 17 ++ 2 files changed, 426 insertions(+) create mode 100644 IoT Plug and Play mobile.json create mode 100644 iot.dockerfile diff --git a/IoT Plug and Play mobile.json b/IoT Plug and Play mobile.json new file mode 100644 index 0000000..adeba9c --- /dev/null +++ b/IoT Plug and Play mobile.json @@ -0,0 +1,409 @@ +[ + { + "@id": "dtmi:azureiot:PhoneAsADevice;2", + "@type": "Interface", + "contents": [ + { + "@type": "Component", + "displayName": { + "en": "Sensors" + }, + "name": "sensors", + "schema": "dtmi:azureiot:PhoneSensors;1" + }, + { + "@type": "Component", + "displayName": { + "en": "Device information" + }, + "name": "device_info", + "schema": "dtmi:azure:DeviceManagement:DeviceInformation;1" + }, + { + "@type": "Command", + "commandType": "synchronous", + "displayName": { + "en": "LightOn" + }, + "name": "lightOn", + "request": { + "@type": [ + "CommandPayload", + "Initialized" + ], + "displayName": { + "en": "Parameters" + }, + "name": "parameters", + "initialValue": { + "duration": 3, + "pulses": 2 + }, + "schema": { + "@type": "Object", + "displayName": { + "en": "Object" + }, + "fields": [ + { + "displayName": { + "en": "Duration" + }, + "name": "duration", + "schema": "integer" + }, + { + "displayName": { + "en": "Pulses interval" + }, + "name": "delay", + "schema": "integer" + }, + { + "displayName": { + "en": "Pulses" + }, + "name": "pulses", + "schema": "integer" + } + ] + } + } + }, + { + "@type": [ + "Property", + "StringValue" + ], + "displayName": { + "en": "Cloud property" + }, + "name": "writeableProp", + "schema": "string", + "writable": true + }, + { + "@type": [ + "Property", + "StringValue" + ], + "displayName": { + "en": "Editable property" + }, + "name": "readOnlyProp", + "schema": "string" + } + ], + "displayName": { + "en": "IoT Plug and Play mobile" + }, + "@context": [ + "dtmi:iotcentral:context;2", + "dtmi:dtdl:context;2" + ] + }, + { + "@context": [ + "dtmi:iotcentral:context;2", + "dtmi:dtdl:context;2" + ], + "@id": "dtmi:azureiot:PhoneSensors;1", + "@type": "Interface", + "contents": [ + { + "@type": "Telemetry", + "comment": "Level percentage", + "displayName": { + "en": "Battery Level" + }, + "name": "battery", + "schema": "integer" + }, + { + "@type": [ + "Telemetry", + "AccelerationVector" + ], + "displayName": { + "en": "Acceleration" + }, + "name": "accelerometer", + "schema": "vector" + }, + { + "@type": "Telemetry", + "displayName": { + "en": "Rotation" + }, + "name": "gyroscope", + "schema": "vector" + }, + { + "@type": "Telemetry", + "displayName": { + "en": "Magnetic induction" + }, + "name": "magnetometer", + "schema": "vector" + }, + { + "@type": [ + "Telemetry", + "Pressure" + ], + "displayName": { + "en": "Pressure" + }, + "name": "barometer", + "schema": "double", + "unit": "kilopascal" + }, + { + "@type": [ + "Telemetry", + "Location" + ], + "displayName": { + "en": "Location" + }, + "name": "geolocation", + "schema": "geopoint" + }, + { + "@type": "Command", + "commandType": "synchronous", + "displayName": { + "en": "Enable Sensors" + }, + "name": "enableSensors", + "request": { + "@type": "CommandPayload", + "displayName": { + "en": "Sensor" + }, + "name": "sensor", + "schema": { + "@type": "Object", + "displayName": { + "en": "Sensor" + }, + "fields": [ + { + "displayName": { + "en": "Sensor" + }, + "name": "sensor", + "schema": "dtmi:azureiot:PhoneSensors:SensorsEnum;1" + }, + { + "displayName": { + "en": "Enable" + }, + "name": "enable", + "schema": "boolean" + } + ] + } + } + }, + { + "@type": "Command", + "commandType": "synchronous", + "displayName": { + "en": "Change Delivery Interval" + }, + "name": "changeInterval", + "request": { + "@type": "CommandPayload", + "displayName": { + "en": "Payload" + }, + "name": "payload", + "schema": { + "@type": "Object", + "displayName": { + "en": "Sensor" + }, + "fields": [ + { + "displayName": { + "en": "Sensor" + }, + "name": "sensor", + "schema": "dtmi:azureiot:PhoneSensors:SensorsEnum;1" + }, + { + "displayName": { + "en": "Interval" + }, + "name": "interval", + "schema": "integer" + } + ] + } + } + } + ], + "displayName": { + "en": "Sensors" + }, + "schemas": [ + { + "@id": "dtmi:azureiot:PhoneSensors:SensorsEnum;1", + "@type": "Enum", + "displayName": { + "en": "Enum" + }, + "enumValues": [ + { + "displayName": { + "en": "Acceleration" + }, + "enumValue": "accelerometer", + "name": "Acceleration" + }, + { + "displayName": { + "en": "Pressure" + }, + "enumValue": "barometer", + "name": "Pressure" + }, + { + "displayName": { + "en": "Rotation" + }, + "enumValue": "gyroscope", + "name": "Rotation" + }, + { + "displayName": { + "en": "Magnetic Induction" + }, + "enumValue": "magnetometer", + "name": "MagneticInduction" + }, + { + "displayName": { + "en": "Location" + }, + "enumValue": "geolocation", + "name": "Location" + }, + { + "displayName": { + "en": "Battery Level" + }, + "enumValue": "battery", + "name": "Battery" + } + ], + "valueSchema": "string" + } + ] + }, + { + "@context": [ + "dtmi:iotcentral:context;2", + "dtmi:dtdl:context;2" + ], + "@id": "dtmi:azure:DeviceManagement:DeviceInformation;1", + "@type": "Interface", + "contents": [ + { + "@type": [ + "Property", + "StringValue" + ], + "description": { + "en": "Company name of the device manufacturer. This could be the same as the name of the original equipment manufacturer (OEM). Ex. Contoso." + }, + "displayName": { + "en": "Device manufacturer" + }, + "name": "manufacturer", + "schema": "string" + }, + { + "@type": "Property", + "description": { + "en": "Device model name or ID. Ex. Surface Book 2." + }, + "displayName": { + "en": "Device model" + }, + "name": "model", + "schema": "string" + }, + { + "@type": "Property", + "description": { + "en": "Version of the software on your device. This could be the version of your firmware. Ex. 1.3.45" + }, + "displayName": { + "en": "Software version" + }, + "name": "swVersion", + "schema": "string" + }, + { + "@type": "Property", + "description": { + "en": "Name of the operating system on the device. Ex. Windows 10 IoT Core." + }, + "displayName": { + "en": "Operating system name" + }, + "name": "osName", + "schema": "string" + }, + { + "@type": "Property", + "description": { + "en": "Architecture of the processor on the device. Ex. x64 or ARM." + }, + "displayName": { + "en": "Processor architecture" + }, + "name": "processorArchitecture", + "schema": "string" + }, + { + "@type": "Property", + "description": { + "en": "Name of the manufacturer of the processor on the device. Ex. Intel." + }, + "displayName": { + "en": "Processor manufacturer" + }, + "name": "processorManufacturer", + "schema": "string" + }, + { + "@type": "Property", + "description": { + "en": "Total available storage on the device in kilobytes. Ex. 2048000 kilobytes." + }, + "displayName": { + "en": "Total storage" + }, + "name": "totalStorage", + "schema": "double" + }, + { + "@type": "Property", + "description": { + "en": "Total available memory on the device in kilobytes. Ex. 256000 kilobytes." + }, + "displayName": { + "en": "Total memory" + }, + "name": "totalMemory", + "schema": "double" + } + ], + "displayName": { + "en": "Device Information" + } + } +] \ No newline at end of file diff --git a/iot.dockerfile b/iot.dockerfile new file mode 100644 index 0000000..d9898b0 --- /dev/null +++ b/iot.dockerfile @@ -0,0 +1,17 @@ +# Use an appropriate base image +FROM node:14 + +# Set the working directory +WORKDIR /usr/src/app + +# Copy package.json and package-lock.json +COPY package*.json ./ + +# Install dependencies +RUN npm install + +# Copy application files +COPY . . + +# Specify the command to run your application +CMD [ "node", "app.js" ] From 171555a833ba2b7b0af4d3e4bca8f5766c33cc6d Mon Sep 17 00:00:00 2001 From: Koushik Hathwar <113892399+KoushikATU@users.noreply.github.com> Date: Tue, 22 Aug 2023 00:34:53 +0100 Subject: [PATCH 2/3] Set up CI with Azure Pipelines [skip ci] --- azure-pipelines.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 azure-pipelines.yml diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 0000000..f53e97b --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,19 @@ +# Starter pipeline +# Start with a minimal pipeline that you can customize to build and deploy your code. +# Add steps that build, run tests, deploy, and more: +# https://aka.ms/yaml + +trigger: +- main + +pool: + vmImage: ubuntu-latest + +steps: +- script: echo Hello, world! + displayName: 'Run a one-line script' + +- script: | + echo Add other tasks to build, test, and deploy your project. + echo See https://aka.ms/yaml + displayName: 'Run a multi-line script' From 96c5bfae1825ef3efc440494cd6be690fd48177d Mon Sep 17 00:00:00 2001 From: Koushik Hathwar <113892399+KoushikATU@users.noreply.github.com> Date: Tue, 22 Aug 2023 00:39:12 +0100 Subject: [PATCH 3/3] Set up CI with Azure Pipelines [skip ci] --- azure-pipelines.yml | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index f53e97b..163127a 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,19 +1,15 @@ -# Starter pipeline -# Start with a minimal pipeline that you can customize to build and deploy your code. -# Add steps that build, run tests, deploy, and more: -# https://aka.ms/yaml - trigger: -- main - -pool: - vmImage: ubuntu-latest - -steps: -- script: echo Hello, world! - displayName: 'Run a one-line script' - -- script: | - echo Add other tasks to build, test, and deploy your project. - echo See https://aka.ms/yaml - displayName: 'Run a multi-line script' +- master + +jobs: +- job: BuildDockerImage + pool: + vmImage: 'ubuntu-latest' + steps: + - task: Docker@2 + inputs: + containerRegistry: 'myregistry' + repository: 'my-iot-app' + command: 'buildAndPush' + Dockerfile: '**/Dockerfile' + tags: 'v1'