Search in sources :

Example 6 with SessionInfoProto

use of org.thingsboard.server.gen.transport.TransportProtos.SessionInfoProto in project thingsboard by thingsboard.

the class DefaultLwM2mUplinkMsgHandler method updateAttrTelemetry.

/**
 * send Attribute and Telemetry to Thingsboard
 * #1 - get AttrName/TelemetryName with value from LwM2MClient:
 * -- resourceId == path from LwM2MClientProfile.postAttributeProfile/postTelemetryProfile/postObserveProfile
 * -- AttrName/TelemetryName == resourceName from ModelObject.objectModel, value from ModelObject.instance.resource(resourceId)
 * #2 - set Attribute/Telemetry
 *
 * @param registration - Registration LwM2M Client
 */
private void updateAttrTelemetry(Registration registration, Set<String> paths) {
    try {
        ResultsAddKeyValueProto results = this.getParametersFromProfile(registration, paths);
        SessionInfoProto sessionInfo = this.getSessionInfoOrCloseSession(registration);
        if (results != null && sessionInfo != null) {
            if (results.getResultAttributes().size() > 0) {
                this.helper.sendParametersOnThingsboardAttribute(results.getResultAttributes(), sessionInfo);
            }
            if (results.getResultTelemetries().size() > 0) {
                this.helper.sendParametersOnThingsboardTelemetry(results.getResultTelemetries(), sessionInfo);
            }
        }
    } catch (Exception e) {
        log.error("UpdateAttrTelemetry", e);
    }
}
Also used : SessionInfoProto(org.thingsboard.server.gen.transport.TransportProtos.SessionInfoProto) ResultsAddKeyValueProto(org.thingsboard.server.transport.lwm2m.server.client.ResultsAddKeyValueProto) LwM2MClientStateException(org.thingsboard.server.transport.lwm2m.server.client.LwM2MClientStateException)

Aggregations

SessionInfoProto (org.thingsboard.server.gen.transport.TransportProtos.SessionInfoProto)6 UUID (java.util.UUID)3 SessionSubscriptionInfoProto (org.thingsboard.server.gen.transport.TransportProtos.SessionSubscriptionInfoProto)3 SubscriptionInfoProto (org.thingsboard.server.gen.transport.TransportProtos.SubscriptionInfoProto)3 LwM2MClientStateException (org.thingsboard.server.transport.lwm2m.server.client.LwM2MClientStateException)3 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)2 ArrayList (java.util.ArrayList)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 FutureCallback (com.google.common.util.concurrent.FutureCallback)1 Futures (com.google.common.util.concurrent.Futures)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 ConcurrentModificationException (java.util.ConcurrentModificationException)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1