Verified Telemetry
nx_verified_telemetry.h
Go to the documentation of this file.
1 /* Copyright (c) Microsoft Corporation.
2  Licensed under the MIT License. */
3 
6 #ifndef NX_VERIFIED_TELEMETRY_H
7 #define NX_VERIFIED_TELEMETRY_H
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 #include "nx_azure_iot_json_reader.h"
14 #include "nx_azure_iot_json_writer.h"
15 #include "nx_azure_iot_pnp_client.h"
16 
17 /* Verified Telemetry Components */
20 
21 #define VT_SIGNATURE_TYPE_FALLCURVE 0x01
22 #define VT_SIGNATURE_TYPE_CURRENTSENSE 0x02
23 
24 #define VT_MINIMUM_BUFFER_SIZE_BYTES sizeof(VT_CURRENTSENSE_RAW_SIGNATURES_READER)
25 
27 
28  /* FallCurve Component */
30 
31  /* CurrentSense Component */
33 };
34 
35 typedef struct NX_VT_OBJECT_TAG
36 {
37  /* Signature Object Union */
39 
40  /* Signature Type */
41  UINT signature_type;
42 
43  /* Pointer to next component */
44  void* next_component;
45 
46 } NX_VT_OBJECT;
47 
49 {
50  /* Name of this component */
51  UCHAR component_name_ptr[VT_COMPONENT_NAME_MAX_LENGTH];
52 
53  UINT component_name_length;
54 
55  /* Pointer to first component */
56  void* first_component;
57 
58  /* Pointer to last component */
59  void* last_component;
60 
61  /* Number of component*/
62  UINT components_num;
63 
64  /* Device specific implementations*/
65  VT_DEVICE_DRIVER* device_driver;
66 
67  /* Enable Verified Telemetry*/
68  bool enable_verified_telemetry;
69 
70  /* Device Status*/
71  bool device_status;
72 
73  /* Device Status Property Sent*/
74  bool device_status_property_sent;
75 
76  /* Pointer to byte buffer passed from application layer, used for fingerprint calculation/storage */
77  CHAR* scratch_buffer;
78 
79  /* Length of byte buffer passed from application layer, used for fingerprint calculation/storage */
80  UINT scratch_buffer_length;
81 
83 
97 UINT nx_vt_init(NX_VERIFIED_TELEMETRY_DB* verified_telemetry_DB,
98  UCHAR* component_name_ptr,
99  bool enable_verified_telemetry,
100  VT_DEVICE_DRIVER* device_driver,
101  CHAR* scratch_buffer,
102  UINT scratch_buffer_length);
103 
120 UINT nx_vt_signature_init(NX_VERIFIED_TELEMETRY_DB* verified_telemetry_DB,
121  NX_VT_OBJECT* handle,
122  UCHAR* component_name_ptr,
123  UINT signature_type,
124  UCHAR* associated_telemetry,
125  bool telemetry_status_auto_update,
126  VT_SENSOR_HANDLE* sensor_handle);
127 
143 UINT nx_vt_process_command(NX_VERIFIED_TELEMETRY_DB* verified_telemetry_DB,
144  NX_AZURE_IOT_PNP_CLIENT* iotpnp_client_ptr,
145  UCHAR* component_name_ptr,
146  UINT component_name_length,
147  UCHAR* pnp_command_name_ptr,
148  UINT pnp_command_name_length,
149  NX_AZURE_IOT_JSON_READER* json_reader_ptr,
150  NX_AZURE_IOT_JSON_WRITER* json_response_ptr,
151  UINT* status_code);
152 
165 UINT nx_vt_process_property_update(NX_VERIFIED_TELEMETRY_DB* verified_telemetry_DB,
166  NX_AZURE_IOT_PNP_CLIENT* iotpnp_client_ptr,
167  const UCHAR* component_name_ptr,
168  UINT component_name_length,
169  NX_AZURE_IOT_JSON_READER* name_value_reader_ptr,
170  UINT version);
171 
180 UINT nx_vt_properties(NX_VERIFIED_TELEMETRY_DB* verified_telemetry_DB, NX_AZURE_IOT_PNP_CLIENT* iotpnp_client_ptr);
181 
193  NX_VERIFIED_TELEMETRY_DB* verified_telemetry_DB, NX_AZURE_IOT_PNP_CLIENT* iotpnp_client_ptr, UINT message_type);
194 
208  NX_AZURE_IOT_PNP_CLIENT* iotpnp_client_ptr,
209  const UCHAR* component_name_ptr,
210  UINT component_name_length,
211  NX_AZURE_IOT_JSON_READER* name_value_reader_ptr,
212  UINT version);
213 
228  NX_AZURE_IOT_PNP_CLIENT* pnp_client_ptr,
229  const UCHAR* component_name_ptr,
230  UINT component_name_length,
231  UINT wait_option,
232  const UCHAR* telemetry_data,
233  UINT data_size);
234 
243 
253  NX_VERIFIED_TELEMETRY_DB* verified_telemetry_DB, NX_AZURE_IOT_PNP_CLIENT* pnp_client_ptr);
254 
265  NX_VERIFIED_TELEMETRY_DB* verified_telemetry_DB, UCHAR* associated_telemetry, UINT associated_telemetry_length,UINT mode);
266 
277  NX_VERIFIED_TELEMETRY_DB* verified_telemetry_DB, UCHAR* associated_telemetry, UINT associated_telemetry_length);
278 
279 #ifdef __cplusplus
280 }
281 #endif
282 
283 #endif /* NX_VERIFIED_TELEMETRY_H */
nx_vt_azure_iot_pnp_client_component_add
UINT nx_vt_azure_iot_pnp_client_component_add(NX_VERIFIED_TELEMETRY_DB *verified_telemetry_DB, NX_AZURE_IOT_PNP_CLIENT *pnp_client_ptr)
Adds VT Information Interfaces that are initialized to the nx_pnp_client object.
nx_vt_verified_telemetry_message_create_send
UINT nx_vt_verified_telemetry_message_create_send(NX_VERIFIED_TELEMETRY_DB *verified_telemetry_DB, NX_AZURE_IOT_PNP_CLIENT *pnp_client_ptr, const UCHAR *component_name_ptr, UINT component_name_length, UINT wait_option, const UCHAR *telemetry_data, UINT data_size)
Creates and sends telemetry JSON with message properties containing telemetry status.
nx_vt_compute_evaluate_fingerprint_all_sensors
UINT nx_vt_compute_evaluate_fingerprint_all_sensors(NX_VERIFIED_TELEMETRY_DB *verified_telemetry_DB)
Computes status of all telemetries which have been initialized to provide Verified Telemetry.
nx_vt_send_desired_property_after_boot
UINT nx_vt_send_desired_property_after_boot(NX_VERIFIED_TELEMETRY_DB *verified_telemetry_DB, NX_AZURE_IOT_PNP_CLIENT *iotpnp_client_ptr, UINT message_type)
Updates Digital Twin with default desired property values when device is booted for the first time.
nx_vt_currentsense_component.h
nx_vt_process_command
UINT nx_vt_process_command(NX_VERIFIED_TELEMETRY_DB *verified_telemetry_DB, NX_AZURE_IOT_PNP_CLIENT *iotpnp_client_ptr, UCHAR *component_name_ptr, UINT component_name_length, UCHAR *pnp_command_name_ptr, UINT pnp_command_name_length, NX_AZURE_IOT_JSON_READER *json_reader_ptr, NX_AZURE_IOT_JSON_WRITER *json_response_ptr, UINT *status_code)
Processes all commands supported by VT Middleware.
NX_VT_SIGNATURE_COMPONENT_UNION_TAG
Definition: nx_verified_telemetry.h:26
nx_vt_init
UINT nx_vt_init(NX_VERIFIED_TELEMETRY_DB *verified_telemetry_DB, UCHAR *component_name_ptr, bool enable_verified_telemetry, VT_DEVICE_DRIVER *device_driver, CHAR *scratch_buffer, UINT scratch_buffer_length)
Initializes Global Verified Telemetry using platform specific device drivers.
NX_VERIFIED_TELEMETRY_DB_TAG
Definition: nx_verified_telemetry.h:48
NX_VT_OBJECT_TAG
Definition: nx_verified_telemetry.h:35
nx_vt_fallcurve_component.h
nx_vt_properties
UINT nx_vt_properties(NX_VERIFIED_TELEMETRY_DB *verified_telemetry_DB, NX_AZURE_IOT_PNP_CLIENT *iotpnp_client_ptr)
Creates payloads and sends all reported properties supported by VT Middleware.
nx_vt_process_property_update
UINT nx_vt_process_property_update(NX_VERIFIED_TELEMETRY_DB *verified_telemetry_DB, NX_AZURE_IOT_PNP_CLIENT *iotpnp_client_ptr, const UCHAR *component_name_ptr, UINT component_name_length, NX_AZURE_IOT_JSON_READER *name_value_reader_ptr, UINT version)
Processes all desired property updates supported by vT Middleware.
nx_vt_signature_process
UINT nx_vt_signature_process(NX_VERIFIED_TELEMETRY_DB *verified_telemetry_DB, UCHAR *associated_telemetry, UINT associated_telemetry_length)
Processes the collected VT signatures for the sensor mapped to the telemetry string passed.
nx_vt_signature_init
UINT nx_vt_signature_init(NX_VERIFIED_TELEMETRY_DB *verified_telemetry_DB, NX_VT_OBJECT *handle, UCHAR *component_name_ptr, UINT signature_type, UCHAR *associated_telemetry, bool telemetry_status_auto_update, VT_SENSOR_HANDLE *sensor_handle)
Initializes Verified Telemetry for a particular sensor data stream.
NX_VT_CURRENTSENSE_COMPONENT_TAG
Definition: nx_vt_currentsense_component.h:19
nx_vt_process_reported_property_sync
UINT nx_vt_process_reported_property_sync(NX_VERIFIED_TELEMETRY_DB *verified_telemetry_DB, NX_AZURE_IOT_PNP_CLIENT *iotpnp_client_ptr, const UCHAR *component_name_ptr, UINT component_name_length, NX_AZURE_IOT_JSON_READER *name_value_reader_ptr, UINT version)
Synchronizes VT Settings stored in digital Twin as reported properties at startup.
nx_vt_signature_read
UINT nx_vt_signature_read(NX_VERIFIED_TELEMETRY_DB *verified_telemetry_DB, UCHAR *associated_telemetry, UINT associated_telemetry_length, UINT mode)
Starts reading VT signatures for the sensor mapped to the telemetry string passed.
NX_VT_FALLCURVE_COMPONENT_TAG
Definition: nx_vt_fallcurve_component.h:19