PIOT-GDA-11-004: Implement the data capture and event triggering logic between the GDA and cloud service #117
Labels
exercise
New feature to implement as an exercise
Milestone
Description
CloudClientConnector
implementation, subscribe to the LED actuation event topic after successful connection. Make sure the cloud service has created the LED actuation event topic prior to the subscribe request. Use a callback handler class to handle any incoming LED actuation events.Objective
Review the README
Estimated effort may vary greatly
Actions
These Updates Span the Cloud Service, GDA, and the CDA
CloudClientConnector
after successful connectionMqttClientConnector
after successful connection: ifuseCloudGatewayConfig
is true, this could be done withinconnectComplete()
DeviceDataManager
after successful connection ofCloudClientConnector
ActuatorData
instance for the CDA, and set the state data to 'ON' or 'OFF' depending on the value received (e.g., 0 == 'ON'; 1 == 'OFF'). Pass theActuatorData
instance OR its JSON conversion toDeviceDataManager
for processing and passing to the CDA.IDataMessageListener
implementation's (DeviceDataManager
)handleIncomingMessage(ResourceNameEnum resourceName, String msg)
callback once the MQTT message is received, and simply update the logic of of thehandleIncomingMessage()
method to parse the data and reconstitute theActuatorData
instance from the JSON.ActuatorData
message inhandleIncomingMessage()
and reconstituting theActuatorData
instance, pass the data onto the CDA's actuator command topic via MQTT or CoAP.ActuatorData
instance and hand it off toActuatorAdapterManager
. This functionality should already be in place, so you shouldn't need to add any logic to the CDA for this lab module.GDA Implementation Notes
NOTE: Here's one approach for implementing the logic needed for the GDA and cloud service to work together. There are many other ways to design your solution. The sample code shown for
CloudClientConnector
was tested with Ubidots as the cloud service provider.Create
IConnectionListener
NOTE: The
IConnectionListener
interface should already be part of thejava-components
source repository.IConnectionListener
: Add theIConnectionListener
interface to theprogrammingtheiot.gda.connection
package. This will be implemented byCloudClientConnector
and used by theMqttClientConnector
to notifyCloudClientConnector
when key connection events complete.Make Sure
MqttClientConnector
is Updated to UseIConnectionListener
NOTE: These updates should already have been implemented as part of PIOT-GDA-11-001.
MqttClientConnector
: WithinMqttClientConnector
, add a class-scoped reference forIConnectionListener
and add thesetConnectionListener(IConnectionListener listener)
method for setting theIConnectionListener
instance.MqttClientConnector
: WithinMqttClientConnector
, add thesetConnectionListener(IConnectionListener listener)
method for setting theIConnectionListener
instance.MqttClientConnector
: WithinMqttClientConnector
'sconnectComplete()
callback method, add a call to theIConnectionListener
instancesonConnect()
method.onConnect()
call.Update
CloudClientConnector
CloudClientConnector
: Implement a callback handler to process incoming LED actuation events from the cloud service withinCloudClientConnector
. This can be implemented as an inner class.IMqttMessageListener
inner classes and subscribe to additional topics with eachIMqttMessageListener
implementation if needed. The example below is provided as a template for consideration.CloudClientConnector
: Implement theIConnectionListener
methods withinCloudClientConnector
- be sure to addimplements IConnectionListener
to theCloudClientConnector
class declaration.CloudClientConnector
: UpdateconnectClient()
to passthis
to theMqttClientConnector
instance as theIConnectionListener
implementation.CloudClientConnector
: For convenience, add in private methods for creating cloud service provider topic names. The examples shown align to Ubidots topic naming conventions, but may work with others as well.Update
DeviceDataManager
DeviceDataManager
: WithinDeviceDataManager
, update thehandleIncomingMessage(ResourceNameEnum resourceName, String msg)
method to process the incoming data (which should be anActuatorData
instance in JSON format).NOTE: With the updates above, your implementation should have most of what it needs to handle VERY BASIC end-to-end edge to cloud data processing. Your implementation specifics may vary from the notional implementation specified above.
Estimate
Tests
CloudClientConnectorTest
test class and add the necessary test case methods to execute a full test cycle of the following:CloudClientConnector
with the appropriate configurationSensorData
sample messageCloudClientConnector
publish methodCloudClientConnector
with the appropriate configurationSensorData
sample messages with relevant threshold crossing(s) to trigger at least one actuation eventCloudClientConnector
publish methodCloudClientConnector
that the message was receivedCloudClientConnector
The text was updated successfully, but these errors were encountered: