Package com.github.lucadruda.iotc.device
Class IoTCClient
java.lang.Object
com.github.lucadruda.iotc.device.IoTCClient
- All Implemented Interfaces:
IIoTCClient
-
Constructor Summary
ConstructorsConstructorDescriptionIoTCClient(String deviceId, String scopeId, IOTC_CONNECT authenticationType, Object options, ICentralStorage storage)IoTCClient(String deviceId, String scopeId, IOTC_CONNECT authenticationType, Object options, ICentralStorage storage, ILogger logger) -
Method Summary
Modifier and TypeMethodDescriptionvoidConnect()Connect the devicevoidConnect the devicevoidDisconnect device.voidcom.microsoft.azure.sdk.iot.device.DeviceClientReturns the model Idcom.microsoft.azure.sdk.iot.device.IotHubClientProtocolbooleanvoidon(IOTC_EVENTS event, IoTCCallback callback)voidSendProperty(Object payload)voidSendProperty(String payload)voidSendTelemetry(Object payload)voidSendTelemetry(Object payload, Object properties)voidSendTelemetry(Object payload, String properties)voidSendTelemetry(String payload)voidSendTelemetry(String payload, Object properties)voidSendTelemetry(String payload, String properties)voidSetConnectionState(boolean state)voidSetGlobalEndpoint(String endpoint)Set global endpoint for DPS provisioningvoidSetLogging(IOTC_LOGGING logLevel)voidSetModelId(String modelId)Set the model IdvoidSetProtocol(IOTC_PROTOCOL transport)booleanUploadFile(String fileName, File file)booleanUploadFile(String fileName, File file, String encoding)
-
Constructor Details
-
IoTCClient
public IoTCClient(String deviceId, String scopeId, IOTC_CONNECT authenticationType, Object options, ICentralStorage storage, ILogger logger)- Parameters:
deviceId- The device IdscopeId- Scope Id of the applicationauthenticationType- Type of authentication: It can be Group symmetric key, Device SAS key or x.509options- Value for authentication: keys for symmetric and SAS key authentication or x.509 certificatestorage- An ICentralStorage implementation to cache device credentialslogger- A custom logger implementing the ILogger interface
-
IoTCClient
public IoTCClient(String deviceId, String scopeId, IOTC_CONNECT authenticationType, Object options, ICentralStorage storage)
-
-
Method Details
-
getModelId
Returns the model Id- Returns:
- the modelId
-
SetModelId
Set the model Id- Specified by:
SetModelIdin interfaceIIoTCClient- Parameters:
modelId- IoT Central model Id for automatic approval process
-
SetLogging
- Specified by:
SetLoggingin interfaceIIoTCClient- Parameters:
logLevel- the logger to set
-
SetProtocol
- Specified by:
SetProtocolin interfaceIIoTCClient
-
SetGlobalEndpoint
Description copied from interface:IIoTCClientSet global endpoint for DPS provisioning- Specified by:
SetGlobalEndpointin interfaceIIoTCClient- Parameters:
endpoint- hostname without protocol
-
Disconnect
Description copied from interface:IIoTCClientDisconnect device. Client cannot be reused after disconnect!!!- Specified by:
Disconnectin interfaceIIoTCClient- Throws:
IoTCentralException- If disconnection fails
-
Connect
Description copied from interface:IIoTCClientConnect the device- Specified by:
Connectin interfaceIIoTCClient- Throws:
IoTCentralException- If connection fails
-
Connect
Description copied from interface:IIoTCClientConnect the device- Specified by:
Connectin interfaceIIoTCClient- Parameters:
timeout- Timeout in seconds before forcing connection stop- Throws:
IoTCentralException- If connection fails
-
SendTelemetry
- Specified by:
SendTelemetryin interfaceIIoTCClient- Parameters:
payload- Message to send: can be any type (usually json) or a collection of messages- Throws:
IoTCentralException- If telemetry delivery failed
-
SendTelemetry
- Specified by:
SendTelemetryin interfaceIIoTCClient- Parameters:
payload- Message to send: can be any type (usually json) or a collection of messages- Throws:
IoTCentralException- If telemetry delivery failed
-
SendTelemetry
- Specified by:
SendTelemetryin interfaceIIoTCClient- Parameters:
payload- Message to send: can be any type (usually json) or a collection of messagesproperties- Properties to be added to the message (JSON format)- Throws:
IoTCentralException- If telemetry delivery failed
-
SendTelemetry
- Specified by:
SendTelemetryin interfaceIIoTCClient- Parameters:
payload- Message to send: can be any type (usually json) or a collection of messagesproperties- Properties to be added to the message (JSON format)- Throws:
IoTCentralException- If telemetry delivery failed
-
SendTelemetry
- Specified by:
SendTelemetryin interfaceIIoTCClient- Parameters:
payload- Message to send: can be any type (usually json) or a collection of messagesproperties- Properties to be added to the message (JSON format)- Throws:
IoTCentralException- If telemetry delivery failed
-
SendTelemetry
- Specified by:
SendTelemetryin interfaceIIoTCClient- Parameters:
payload- Message to send: can be any type (usually json) or a collection of messagesproperties- Properties to be added to the message (JSON format)- Throws:
IoTCentralException- If telemetry delivery failed
-
SendProperty
- Specified by:
SendPropertyin interfaceIIoTCClient- Parameters:
payload- Property to send: can be any type (usually json) or a collection of properties- Throws:
IoTCentralException- If property delivery fails
-
SendProperty
- Specified by:
SendPropertyin interfaceIIoTCClient- Parameters:
payload- Property to send: can be any type (usually json) or a collection of properties- Throws:
IoTCentralException- If property delivery fails
-
on
- Specified by:
onin interfaceIIoTCClient- Parameters:
event- name of the event to listencallback- function to execute when event triggers
-
getLogger
- Returns:
- the logger
-
getDeviceId
- Returns:
- the id
-
getScopeId
- Returns:
- the scopeId
-
getAuthenticationType
- Returns:
- the authenticationType
-
getSasKey
- Returns:
- the sasKey
-
getCertificate
- Returns:
- the certificate
-
getProtocol
public com.microsoft.azure.sdk.iot.device.IotHubClientProtocol getProtocol()- Returns:
- the protocol
-
getDeviceClient
public com.microsoft.azure.sdk.iot.device.DeviceClient getDeviceClient()- Returns:
- the deviceClient
-
IsConnected
public boolean IsConnected()- Specified by:
IsConnectedin interfaceIIoTCClient
-
SetConnectionState
public void SetConnectionState(boolean state) -
FetchTwin
- Specified by:
FetchTwinin interfaceIIoTCClient- Throws:
IoTCentralException
-
UploadFile
- Specified by:
UploadFilein interfaceIIoTCClient- Throws:
IoTCentralException
-
UploadFile
- Specified by:
UploadFilein interfaceIIoTCClient- Throws:
IoTCentralException
-