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 TypeMethodDescriptionvoid
Connect()
Connect the devicevoid
Connect the devicevoid
Disconnect device.void
com.microsoft.azure.sdk.iot.device.DeviceClient
Returns the model Idcom.microsoft.azure.sdk.iot.device.IotHubClientProtocol
boolean
void
on(IOTC_EVENTS event, IoTCCallback callback)
void
SendProperty(Object payload)
void
SendProperty(String payload)
void
SendTelemetry(Object payload)
void
SendTelemetry(Object payload, Object properties)
void
SendTelemetry(Object payload, String properties)
void
SendTelemetry(String payload)
void
SendTelemetry(String payload, Object properties)
void
SendTelemetry(String payload, String properties)
void
SetConnectionState(boolean state)
void
SetGlobalEndpoint(String endpoint)
Set global endpoint for DPS provisioningvoid
SetLogging(IOTC_LOGGING logLevel)
void
SetModelId(String modelId)
Set the model Idvoid
SetProtocol(IOTC_PROTOCOL transport)
boolean
UploadFile(String fileName, File file)
boolean
UploadFile(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:
SetModelId
in interfaceIIoTCClient
- Parameters:
modelId
- IoT Central model Id for automatic approval process
-
SetLogging
- Specified by:
SetLogging
in interfaceIIoTCClient
- Parameters:
logLevel
- the logger to set
-
SetProtocol
- Specified by:
SetProtocol
in interfaceIIoTCClient
-
SetGlobalEndpoint
Description copied from interface:IIoTCClient
Set global endpoint for DPS provisioning- Specified by:
SetGlobalEndpoint
in interfaceIIoTCClient
- Parameters:
endpoint
- hostname without protocol
-
Disconnect
Description copied from interface:IIoTCClient
Disconnect device. Client cannot be reused after disconnect!!!- Specified by:
Disconnect
in interfaceIIoTCClient
- Throws:
IoTCentralException
- If disconnection fails
-
Connect
Description copied from interface:IIoTCClient
Connect the device- Specified by:
Connect
in interfaceIIoTCClient
- Throws:
IoTCentralException
- If connection fails
-
Connect
Description copied from interface:IIoTCClient
Connect the device- Specified by:
Connect
in interfaceIIoTCClient
- Parameters:
timeout
- Timeout in seconds before forcing connection stop- Throws:
IoTCentralException
- If connection fails
-
SendTelemetry
- Specified by:
SendTelemetry
in 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:
SendTelemetry
in 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:
SendTelemetry
in 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:
SendTelemetry
in 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:
SendTelemetry
in 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:
SendTelemetry
in 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:
SendProperty
in 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:
SendProperty
in 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:
on
in 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:
IsConnected
in interfaceIIoTCClient
-
SetConnectionState
public void SetConnectionState(boolean state) -
FetchTwin
- Specified by:
FetchTwin
in interfaceIIoTCClient
- Throws:
IoTCentralException
-
UploadFile
- Specified by:
UploadFile
in interfaceIIoTCClient
- Throws:
IoTCentralException
-
UploadFile
- Specified by:
UploadFile
in interfaceIIoTCClient
- Throws:
IoTCentralException
-