Device Provision Functions

When a device provision request is received from the CMS, IDL calls the IDL Driver Instance (IDI) device provision callback function (OnDevProvision) that was registered during the init process. 

The provision request from the CMS may or may not contain args. If present, it is passed to the IDI provision callback as a stringified JSON. In provision, args only contains unid. The IDI must verify it. args is NULL if no verification is required.

When the IDL calls the provision callback function, the IDI must perform protocol specific provisioning.

On completion, the IDI must call IdlDevProvisionResult() with callback_index, pointer to IdlDev, and the appropriate idlError (see Error Codes).

After the IdlDevProvisionResult() API is called with success, if the device is being provisioned for the very first time, the IDL will do a communication check with the provisioned device by issuing a poll request to the first datapoint of that device. If the read is successful, IDL will publish appropriate IAP/MQ status object, etc.  If it fails, IDL publishes an error to the CMS and the device provision action fails.

After the first successful provision (along with the first DP read) for any subsequent provision action, there will be no DP read issued to establish communication. The state will directly be changed to provisioned.

Device Provision Callback Function

OnDevProvision 

IdlErrorCodes OnDevProvision(int callback_index, IdlDev *dev, char *args);

Device Provision Related Functions

IdlDevProvisionCallbackSet 

void IdlDevProvisionCallbackSet(Idl *idl, int (*OnDevProvision)(int, IdlDev *, char *));

Must be called by the IDI prior to calling IdlInit.

IdlDevProvisionResult

void IdlDevProvisionResult(int callbackIndex, IdlDev *dev, int idlError);

Must be called by the IDI at the end of the callback function before exiting.