ContractAPIMqtt Class
- java.
lang. Object - ProvisioningDeviceClientContract
- com.
microsoft. azure. sdk. iot. provisioning. device. internal. contract. mqtt. ContractAPIMqtt
- com.
public class ContractAPIMqtt extends ProvisioningDeviceClientContract implements MqttListener
Constructor Summary
Constructor | Description |
---|---|
ContractAPIMqtt(ProvisioningDeviceClientConfig provisioningDeviceClientConfig) |
This constructor creates an instance of Mqtt class and initializes member variables |
Method Summary
Modifier and Type | Method and Description |
---|---|
synchronized void |
authenticateWithProvisioningService(RequestData requestData, ResponseCallback responseCallback, Object callbackContext)
Requests hub to authenticate this connection and start the registration process over MQTT |
synchronized void |
close()
Indicates to close the connection |
void |
connectionLost(Throwable throwable)
Called by PAHO when the connection is lost |
String | getConnectionId() |
String | getHostName() |
synchronized void |
getRegistrationStatus(RequestData requestData, ResponseCallback responseCallback, Object callbackContext)
Gets the registration status over MQTT |
void |
messageReceived(MqttMessage message)
Called when the message gets received by PAHO |
synchronized void |
open(RequestData requestData)
Indicates need to open MQTT connection |
synchronized void |
requestNonceForTPM(RequestData requestData, ResponseCallback responseCallback, Object authorizationCallbackContext)
Requests hub to provide a device key to begin authentication over MQTT (Only for TPM) |
Inherited Members
Constructor Details
ContractAPIMqtt
public ContractAPIMqtt(ProvisioningDeviceClientConfig provisioningDeviceClientConfig)
This constructor creates an instance of Mqtt class and initializes member variables
Parameters:
Config used for provisioning Cannot benull
</code> . </p>
Throws:
ProvisioningDeviceClientException
- is thrown when any of the input parameters are invalid
Method Details
authenticateWithProvisioningService
public synchronized void authenticateWithProvisioningService(RequestData requestData, ResponseCallback responseCallback, Object callbackContext)
Requests hub to authenticate this connection and start the registration process over MQTT
Parameters:
requestData
- A nonnull
</code> value with all the required request data </p>
responseCallback
- A nonnull
</code> value for the callback </p>
callbackContext
- An object for context. Can benull
</code></p>
Throws:
ProvisioningDeviceClientException
- If any of the parameters are invalid (null
</code> or empty) </p>
ProvisioningDeviceTransportException
- If any of the API calls to transport fail
ProvisioningDeviceHubException
- If hub responds back with an invalid status
close
public synchronized void close()
Indicates to close the connection
Throws:
ProvisioningDeviceConnectionException
- thrown if a failure in disconnect
connectionLost
public void connectionLost(Throwable throwable)
Called by PAHO when the connection is lost
Overrides:
ContractAPIMqtt.connectionLost(Throwable throwable)
Parameters:
throwable
- the disconnection reason.
getConnectionId
public String getConnectionId()
getHostName
public String getHostName()
getRegistrationStatus
public synchronized void getRegistrationStatus(RequestData requestData, ResponseCallback responseCallback, Object callbackContext)
Gets the registration status over MQTT
Parameters:
requestData
- A nonnull
</code> value with all the request data </p>
responseCallback
- A nonnull
</code> value for the callback </p>
callbackContext
- An object for context. Can benull
</code></p>
Throws:
ProvisioningDeviceClientException
- If any of the parameters are invalid (null
</code> or empty) </p>
ProvisioningDeviceTransportException
- If any of the API calls to transport fail
ProvisioningDeviceHubException
- If hub responds back with an invalid status
messageReceived
public void messageReceived(MqttMessage message)
Called when the message gets received by PAHO
Overrides:
ContractAPIMqtt.messageReceived(MqttMessage message)
Parameters:
message
- the received Mqtt message
open
public synchronized void open(RequestData requestData)
Indicates need to open MQTT connection
Parameters:
requestData
- Data used for the connection initialization
Throws:
ProvisioningDeviceConnectionException
- is thrown when any of the input parameters are invalid
requestNonceForTPM
public synchronized void requestNonceForTPM(RequestData requestData, ResponseCallback responseCallback, Object authorizationCallbackContext)
Requests hub to provide a device key to begin authentication over MQTT (Only for TPM)
Parameters:
requestData
- the request data to be used while requesting nonce for TPM
responseCallback
- A nonnull
</code> value for the callback </p>
authorizationCallbackContext
- An object for context. Can benull
</code></p>
Throws:
ProvisioningDeviceClientException
- If any of the parameters are invalid (null
</code> or empty) </p>
ProvisioningDeviceTransportException
- If any of the API calls to transport fail
ProvisioningDeviceHubException
- If hub responds back with an invalid status
Applies to
Azure SDK for Java