Azure IoT Shunya API
#
Azure IoT#
Azure configuration in ShunyaConfig | Description |
---|---|
IoT Hub name | Azure IoT hub name where your device is registered. |
Port | Azure connection port, usually it is 443, 8883 incase 443 is blocked by company proxy. |
Device Id | Azure IoT device ID |
SAS Token | SAS Token for the device generated from the Azure portal. |
Root CA certificate | Azure provides you with the Root CA certificate. Used for secure communication with Azure. |
The configurations need to be set manually by the user before using the API's
For example:
A sample JSON snippet should contain
#
Commonly configured parametersFor example:
A typical configuration will look like this
#
Azure APIAPI | Description | Details |
---|---|---|
newAzure() | Creates a new Azure Instance | Read More |
azureConnectMqtt() | Connects to the Azure IoT Cloud | Read More |
azurePublishMqtt() | Publishes to the given Topic | Read More |
azureSetSubCallbackMqtt() | Set subscribe callback function | Read More |
azureDisconnectMqtt() | Subscribes to the given Topic | Read More |
newAzure()
#
Description : Creates a new Azure Instance
Parameters
name (char *)
- Name of the JSON object.
Return-type : azureObj
Returns : azureObj Instance for Azure
Usage :
For example: Lets say your /etc/shunya/config.json
JSON file looks like
So the usage of the API's will be
azureConnectMqtt()
#
Description : Connects to the Azure IoT Cloud.
Parameters
*obj
(azureObj) - Pointer to the Azure Instance.
Return-type : int32_t
Returns : Azure Status Code on ERROR or SUCCESS
Usage :
azurePublishMqtt()
#
Description : Publishes to the given Topic
Parameters
*obj
(azureObj) - Pointer to the Azure Instance.topic (char *)
- MQTT Topic to publish.msg (char *)
- Message that needs to be published.
Return-type : int32_t
Returns : Azure Status Code on ERROR or SUCCESS
Usage :
azureSetSubCallbackMqtt()
#
Description: Set the subscribe callback function that executes the when the topic subscribed gets a message.
The Callback function arguments need to be in the specified format,
This format is used to pass the message received to the callback function.
Parameters
*obj
(azureObj) - Pointer to the Azure Instance.callback (void *)
- A callback function that will get called when the subscribed topic gets a message
Return-type : int32_t
Returns : Azure Status Code on ERROR or SUCCESS
Usage :
azureDisconnectMqtt()
#
Description: Disconnects the Azure MQTT Broker.
Parameters:
*obj
(azureObj) - Pointer to the Azure Instance.
Return-type : void
Usage :