Azure Verified Telemetry for IoT is a state-of-the-art solution to seamlessly determine the health of the sensor in real-time.
Перейти к файлу
Nishant-Shrivastava e06d303737
Update LICENSE.txt
2021-02-15 19:14:21 +05:30
PnPModel changes to readme 2021-02-15 18:13:07 +05:30
docs chnages to readme 2021-02-14 23:27:39 +05:30
inc Removed standard libraries from vt_database.h 2021-02-01 21:40:35 +05:30
src Shifted Calibration to ResetFingerprint Command 2021-02-15 10:36:34 +05:30
.clang-format Applied Clang 2021-02-01 16:55:53 +05:30
.gitignore Moved reported property parsing to helper function 2021-02-01 21:20:58 +05:30
CMakeLists.txt Moved reported property parsing to helper function 2021-02-01 21:20:58 +05:30
LICENSE.txt Update LICENSE.txt 2021-02-15 19:14:21 +05:30
README.md Changes to readme 2021-02-15 17:17:16 +05:30

README.md

Verified Telemetry Overview

The quality of sensor data is fundamental for driving IoT adoption. Since IoT sensors are made of low-cost components, deployed in-the-wild and in harsh environments, they are prone to failures leading to faulty or dirty data. The effect of bad data will lead to the well-known garbage-in garbage-out process, leading to cascading ill-effects upstream and at times catastrophic decisions.

Verified Telemetry (VT) is a state-of-the-art solution to determine the health of the sensor, i.e., working or faulty, which is consequently used to determine the quality of the sensed data. This is achieved by devising an intelligent “sensor fingerprint”, a set of unique electrical characteristics that differs between working and faulty sensors. The fingerprints can detect faults for a wide variety of off-the-shelf sensors and can be easily implemented with lightweight software code running on the IoT device. This novel approach empowers customers with a reliable and automated way to remotely measure and observe the health of the sensor in real-time alongside the data collected. The data associated with a validated fingerprint results in verified telemetry (as shown below).

VT_Overview

Table of Contents

Architecture

Verified Telemetry Library currently supports Azure RTOS and uses the following components:

  • Azure NetX Duo. Provides a full TCP/IP IPv4 and IPv6 network stack, and networking support integrated with ThreadX.
  • Azure IoT Middleware for Azure RTOS Platform specific library that acts as a binding layer between the Azure RTOS and the Azure SDK for Embedded C.

The architecture of VT library is also shown below: Architecture

File Structure

The VT library has been structured around the following components:

  • Core. This module includes core functions to support verified telemetry, such as functions to collect, validate and evaluate sensor fingerprints.
  • Middleware. This module contains implementations to support interactions with Azure IoT Middleware for Azure RTOS.
  • Platform. This module helps in making the library compatible with several hardware devices and OS kernels.

The structure of the library is as follows:

  • /inc Contains Header files for core, middeware and platform components

  • /src Contains implementations for all the header files in /inc.

  • /PnPModel Contains impementations for sample PnP models to support Verified Telemetry.

  • CmakeLists.txt
    CMake script to generate build files. Verified Telemetry provides several options to customize the library according to the project requirement:

    Option Description Available Values Default Value
    VT_DEVICE` | his option links the correct HAL implementation to the library. | MXCHIP_AZ3166 STM_BL475EIOT01A CUSTOM_DEVICE`| MXCHIP_AZ3166` |

    Note: While selecting CUSTOM_DEVICE option, user must provide implementations for the functions present vt_dsc_custom.c.

Dependencies

Verified Telemetry is dependant on following SDK's:

Samples

We provide multiple device and solution samples to showcase the usage of verified Telemetry. Please follow the Getting Started Guides below to see Verified Telemetry in action.

Device Samples

The device samples shows device developers how to include Verified Telemetry with Azure IoT on Azure RTOS.

Solution Samples

The solution samples showcase how the Verified Telemetry features can be utilised in real world scenarios. This uses InfluxDB, Grafana and the Azure IoT Node.js SDK to communicate with Azure IoT Hub.

Resource Requirements

We except Verified Telemetery code to run on microcontrollers, which have very limited amounts of flash and RAM. Below is our resource requirements to add verified telemetry code:

Flash 46 Kb
RAM 14 Kb

Plug and Play Model

Verified Telemetry Library provides capabilities for interaction using a Plug and Play Model. Details about this model can be found here.

API Documentation

Function Description
pnp_vt_init Initializes Global Verified Telemetry
pnp_fallcurve_init Initializes an instance of Verified Telemetry Information Interface
pnp_vt_process_command Processes all commands supported by VT Middleware
pnp_vt_process_property_update Processes all desired property updates supported by VT Middleware
pnp_vt_process_reported_property_sync Syncronizes VT Settings stored in digital Twin as reported properties at startup
pnp_vt_properties Creates payloads and sends all reported properties supported by VT Middleware

Integration of VT with existing device code

  • Developers can refer to the Device Samples for Verified Telemetry sample code. The following steps showcase how Verified Telemetry Library can be integrated separately with Azure RTOS getting started samples

    NOTE: The following steps demonstrate the integration of Verified Telemetry for the AZ3166 getting started sample. Similar steps can be followed for B-L475E-IOT01A/B-L4S5I-IOT01A device samples.

Step 1: Include Verified Telemetry library

Step 2: Initialize Verified Telemetry

Make the following additions to the /getting-started/blob/master/MXChip/AZ3166/app/nx_client.c file

  • Include headers
    #include "pnp_verified_telemetry.h"
    #include "pnp_fallcurve_component.h"
    
  • Define number of verified Telemetries that the device would be supporting
    #define NUMBER_OF_VT_ENABLED_TELEMETRIES                         N
    
  • Define Verified Telemetry DB which will store configuration and runtime information
    static VERIFIED_TELEMETRY_DB verified_telemetry_DB;
    
  • Define one FallCurve component for each telemetry that will be supporting Verified Telemetry
    static PNP_FALLCURVE_COMPONENT sample_fallcurve_1;
    // static PNP_FALLCURVE_COMPONENT sample_fallcurve_2;
    static PNP_FALLCURVE_COMPONENT sample_fallcurve_N;
    
  • Assign a name to each FallCurve component
    static const CHAR sample_fallcurve_1_component[] = "vTTelemetry1";
    // static const CHAR sample_fallcurve_2_component[] = "vTTelemetry2";
    static const CHAR sample_fallcurve_N_component[] = "vTTelemetryN";
    
  • Register Verified Telemetry components with Azure RTOS Middleware for Azure IoT
    nx_azure_iot_pnp_client_component_add( iotpnp_client_ptr, 
    				       (const UCHAR *)sample_fallcurve_1_component,
           				       sizeof(sample_fallcurve_1_component) - 1));
    // nx_azure_iot_pnp_client_component_add( iotpnp_client_ptr, 
    				        (const UCHAR *)sample_fallcurve_2_component,
           				        sizeof(sample_fallcurve_2_component) - 1));
    nx_azure_iot_pnp_client_component_add( iotpnp_client_ptr, 
    				       (const UCHAR *)sample_fallcurve_N_component,
           				       sizeof(sample_fallcurve_N_component) - 1))				       
    
    
  • Define variables to hold Verified Telemetry configuration information
    static PNP_FALLCURVE_COMPONENT * fallcurve_components[NUMBER_OF_VT_ENABLED_TELEMETRIES] = {NULL};
    static CHAR * connected_sensors[NUMBER_OF_VT_ENABLED_TELEMETRIES] = {NULL};
    
  • Define a Verified Telemetry User Initialization wrapper function which will make calls to necessary initilization function from the vT library
    void * sample_pnp_verified_telemetry_user_init()
    {
        UINT status;
        if ((status = pnp_fallcurve_init(&sample_fallcurve_1, (UCHAR *)"vTTelemetry1", GPIOB,
    					    GPIO_PIN_8, &hadc1, ADC_CHANNEL_1, NULL, fallcurve_components,
    					    connected_sensors, (UCHAR *) "Telemetry1", 
    					    NUMBER_OF_VT_ENABLED_TELEMETRIES)))
        {
    	printf("Failed to initialize vTTelemetry1 component: error code = 0x%08x\r\n", status);
        }
    
    	//  else if ((status = pnp_fallcurve_init(&sample_fallcurve_2, (UCHAR *)"vTTelemetry2", GPIOB,
    	// 					    GPIO_PIN_10, &hadc1, ADC_CHANNEL_3, NULL, fallcurve_components,
    	// 					    connected_sensors, (UCHAR *) "Telemetry2", 
    	// 					    NUMBER_OF_VT_ENABLED_TELEMETRIES)))
    	// {
    	//     printf("Failed to initialize vTTelemetry2 component: error code = 0x%08x\r\n", status);
    	// }
    
        else if ((status = pnp_fallcurve_init(&sample_fallcurve_N, (UCHAR *) "vTTelemetryN", GPIOB,
    					    GPIO_PIN_9, &hadc1, ADC_CHANNEL_2, NULL, fallcurve_components,
    					    connected_sensors, (UCHAR *) "TelemetryN", 
    					    NUMBER_OF_VT_ENABLED_TELEMETRIES )))
        {
    	printf("Failed to initialize vTTelemetryN component: error code = 0x%08x\r\n", status);
        }
        else if ((status = pnp_vt_init(&verified_telemetry_DB, fallcurve_components, NUMBER_OF_VT_ENABLED_TELEMETRIES, 
    						true, 0x080E0000 )))
        {
    	printf("Failed to initialize Verified Telemetry: error code = 0x%08x\r\n", status);
        }
        return (void*)(&verified_telemetry_DB);
    }
    
  • Call the Verified Telemetry User Initialization wrapper function and update verified_telemetry_DB
    rified_telemetry_DB = sample_pnp_verified_telemetry_user_init();
    

Step 3: Add Verified Telemetry functions to existing routines for Property updates and Command Processing

Make the following modifications to the /getting-started/blob/master/MXChip/AZ3166/app/nx_client.c file

  • Invoke Verified Telemetry Property transmission function at regular intervals
    pnp_vt_properties(verified_telemetry_DB, &(context->iotpnp_client));
    
  • Call Verified Telemetry Command Processing when direct methods/ commands are received
    pnp_vt_process_command( verified_telemetry_DB, &(sample_context_ptr->iotpnp_client),
                 		(UCHAR *)component_name_ptr, component_name_length,
                  		(UCHAR *)pnp_command_name_ptr, pnp_command_name_length,
                  		&json_reader, &json_writer, &status_code);