Search in sources :

Example 1 with EfentoCoapDeviceTypeConfiguration

use of org.thingsboard.server.common.data.device.profile.EfentoCoapDeviceTypeConfiguration in project thingsboard by thingsboard.

the class AbstractCoapIntegrationTest method createCoapDeviceProfile.

protected DeviceProfile createCoapDeviceProfile(TransportPayloadType transportPayloadType, CoapDeviceType coapDeviceType, String provisionSecret, DeviceProfileProvisionType provisionType, String provisionKey, String attributesProtoSchema, String telemetryProtoSchema, String rpcResponseProtoSchema, String rpcRequestProtoSchema) {
    DeviceProfile deviceProfile = new DeviceProfile();
    deviceProfile.setName(transportPayloadType.name());
    deviceProfile.setType(DeviceProfileType.DEFAULT);
    deviceProfile.setProvisionType(provisionType);
    deviceProfile.setProvisionDeviceKey(provisionKey);
    deviceProfile.setDescription(transportPayloadType.name() + " Test");
    DeviceProfileData deviceProfileData = new DeviceProfileData();
    DefaultDeviceProfileConfiguration configuration = new DefaultDeviceProfileConfiguration();
    deviceProfile.setTransportType(DeviceTransportType.COAP);
    CoapDeviceProfileTransportConfiguration coapDeviceProfileTransportConfiguration = new CoapDeviceProfileTransportConfiguration();
    CoapDeviceTypeConfiguration coapDeviceTypeConfiguration;
    if (CoapDeviceType.DEFAULT.equals(coapDeviceType)) {
        DefaultCoapDeviceTypeConfiguration defaultCoapDeviceTypeConfiguration = new DefaultCoapDeviceTypeConfiguration();
        TransportPayloadTypeConfiguration transportPayloadTypeConfiguration;
        if (TransportPayloadType.PROTOBUF.equals(transportPayloadType)) {
            ProtoTransportPayloadConfiguration protoTransportPayloadConfiguration = new ProtoTransportPayloadConfiguration();
            if (StringUtils.isEmpty(telemetryProtoSchema)) {
                telemetryProtoSchema = DEVICE_TELEMETRY_PROTO_SCHEMA;
            }
            if (StringUtils.isEmpty(attributesProtoSchema)) {
                attributesProtoSchema = DEVICE_ATTRIBUTES_PROTO_SCHEMA;
            }
            if (StringUtils.isEmpty(rpcResponseProtoSchema)) {
                rpcResponseProtoSchema = DEVICE_RPC_RESPONSE_PROTO_SCHEMA;
            }
            if (StringUtils.isEmpty(rpcRequestProtoSchema)) {
                rpcRequestProtoSchema = DEVICE_RPC_REQUEST_PROTO_SCHEMA;
            }
            protoTransportPayloadConfiguration.setDeviceTelemetryProtoSchema(telemetryProtoSchema);
            protoTransportPayloadConfiguration.setDeviceAttributesProtoSchema(attributesProtoSchema);
            protoTransportPayloadConfiguration.setDeviceRpcResponseProtoSchema(rpcResponseProtoSchema);
            protoTransportPayloadConfiguration.setDeviceRpcRequestProtoSchema(rpcRequestProtoSchema);
            transportPayloadTypeConfiguration = protoTransportPayloadConfiguration;
        } else {
            transportPayloadTypeConfiguration = new JsonTransportPayloadConfiguration();
        }
        defaultCoapDeviceTypeConfiguration.setTransportPayloadTypeConfiguration(transportPayloadTypeConfiguration);
        coapDeviceTypeConfiguration = defaultCoapDeviceTypeConfiguration;
    } else {
        coapDeviceTypeConfiguration = new EfentoCoapDeviceTypeConfiguration();
    }
    coapDeviceProfileTransportConfiguration.setCoapDeviceTypeConfiguration(coapDeviceTypeConfiguration);
    deviceProfileData.setTransportConfiguration(coapDeviceProfileTransportConfiguration);
    DeviceProfileProvisionConfiguration provisionConfiguration;
    switch(provisionType) {
        case ALLOW_CREATE_NEW_DEVICES:
            provisionConfiguration = new AllowCreateNewDevicesDeviceProfileProvisionConfiguration(provisionSecret);
            break;
        case CHECK_PRE_PROVISIONED_DEVICES:
            provisionConfiguration = new CheckPreProvisionedDevicesDeviceProfileProvisionConfiguration(provisionSecret);
            break;
        case DISABLED:
        default:
            provisionConfiguration = new DisabledDeviceProfileProvisionConfiguration(provisionSecret);
            break;
    }
    deviceProfileData.setProvisionConfiguration(provisionConfiguration);
    deviceProfileData.setConfiguration(configuration);
    deviceProfile.setProfileData(deviceProfileData);
    deviceProfile.setDefault(false);
    deviceProfile.setDefaultRuleChainId(null);
    return deviceProfile;
}
Also used : DefaultCoapDeviceTypeConfiguration(org.thingsboard.server.common.data.device.profile.DefaultCoapDeviceTypeConfiguration) EfentoCoapDeviceTypeConfiguration(org.thingsboard.server.common.data.device.profile.EfentoCoapDeviceTypeConfiguration) CheckPreProvisionedDevicesDeviceProfileProvisionConfiguration(org.thingsboard.server.common.data.device.profile.CheckPreProvisionedDevicesDeviceProfileProvisionConfiguration) JsonTransportPayloadConfiguration(org.thingsboard.server.common.data.device.profile.JsonTransportPayloadConfiguration) CoapDeviceProfileTransportConfiguration(org.thingsboard.server.common.data.device.profile.CoapDeviceProfileTransportConfiguration) DisabledDeviceProfileProvisionConfiguration(org.thingsboard.server.common.data.device.profile.DisabledDeviceProfileProvisionConfiguration) DefaultDeviceProfileConfiguration(org.thingsboard.server.common.data.device.profile.DefaultDeviceProfileConfiguration) DeviceProfile(org.thingsboard.server.common.data.DeviceProfile) CheckPreProvisionedDevicesDeviceProfileProvisionConfiguration(org.thingsboard.server.common.data.device.profile.CheckPreProvisionedDevicesDeviceProfileProvisionConfiguration) AllowCreateNewDevicesDeviceProfileProvisionConfiguration(org.thingsboard.server.common.data.device.profile.AllowCreateNewDevicesDeviceProfileProvisionConfiguration) DisabledDeviceProfileProvisionConfiguration(org.thingsboard.server.common.data.device.profile.DisabledDeviceProfileProvisionConfiguration) DeviceProfileProvisionConfiguration(org.thingsboard.server.common.data.device.profile.DeviceProfileProvisionConfiguration) ProtoTransportPayloadConfiguration(org.thingsboard.server.common.data.device.profile.ProtoTransportPayloadConfiguration) TransportPayloadTypeConfiguration(org.thingsboard.server.common.data.device.profile.TransportPayloadTypeConfiguration) AllowCreateNewDevicesDeviceProfileProvisionConfiguration(org.thingsboard.server.common.data.device.profile.AllowCreateNewDevicesDeviceProfileProvisionConfiguration) EfentoCoapDeviceTypeConfiguration(org.thingsboard.server.common.data.device.profile.EfentoCoapDeviceTypeConfiguration) CoapDeviceTypeConfiguration(org.thingsboard.server.common.data.device.profile.CoapDeviceTypeConfiguration) DefaultCoapDeviceTypeConfiguration(org.thingsboard.server.common.data.device.profile.DefaultCoapDeviceTypeConfiguration) DeviceProfileData(org.thingsboard.server.common.data.device.profile.DeviceProfileData)

Aggregations

DeviceProfile (org.thingsboard.server.common.data.DeviceProfile)1 AllowCreateNewDevicesDeviceProfileProvisionConfiguration (org.thingsboard.server.common.data.device.profile.AllowCreateNewDevicesDeviceProfileProvisionConfiguration)1 CheckPreProvisionedDevicesDeviceProfileProvisionConfiguration (org.thingsboard.server.common.data.device.profile.CheckPreProvisionedDevicesDeviceProfileProvisionConfiguration)1 CoapDeviceProfileTransportConfiguration (org.thingsboard.server.common.data.device.profile.CoapDeviceProfileTransportConfiguration)1 CoapDeviceTypeConfiguration (org.thingsboard.server.common.data.device.profile.CoapDeviceTypeConfiguration)1 DefaultCoapDeviceTypeConfiguration (org.thingsboard.server.common.data.device.profile.DefaultCoapDeviceTypeConfiguration)1 DefaultDeviceProfileConfiguration (org.thingsboard.server.common.data.device.profile.DefaultDeviceProfileConfiguration)1 DeviceProfileData (org.thingsboard.server.common.data.device.profile.DeviceProfileData)1 DeviceProfileProvisionConfiguration (org.thingsboard.server.common.data.device.profile.DeviceProfileProvisionConfiguration)1 DisabledDeviceProfileProvisionConfiguration (org.thingsboard.server.common.data.device.profile.DisabledDeviceProfileProvisionConfiguration)1 EfentoCoapDeviceTypeConfiguration (org.thingsboard.server.common.data.device.profile.EfentoCoapDeviceTypeConfiguration)1 JsonTransportPayloadConfiguration (org.thingsboard.server.common.data.device.profile.JsonTransportPayloadConfiguration)1 ProtoTransportPayloadConfiguration (org.thingsboard.server.common.data.device.profile.ProtoTransportPayloadConfiguration)1 TransportPayloadTypeConfiguration (org.thingsboard.server.common.data.device.profile.TransportPayloadTypeConfiguration)1