Search in sources :

Example 1 with DefaultDeviceProfileConfiguration

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

the class AbstractWebTest method createDeviceProfile.

protected DeviceProfile createDeviceProfile(String name, DeviceProfileTransportConfiguration deviceProfileTransportConfiguration) {
    DeviceProfile deviceProfile = new DeviceProfile();
    deviceProfile.setName(name);
    deviceProfile.setType(DeviceProfileType.DEFAULT);
    deviceProfile.setTransportType(DeviceTransportType.DEFAULT);
    deviceProfile.setDescription(name + " Test");
    DeviceProfileData deviceProfileData = new DeviceProfileData();
    DefaultDeviceProfileConfiguration configuration = new DefaultDeviceProfileConfiguration();
    deviceProfileData.setConfiguration(configuration);
    if (deviceProfileTransportConfiguration != null) {
        deviceProfileData.setTransportConfiguration(deviceProfileTransportConfiguration);
    } else {
        deviceProfileData.setTransportConfiguration(new DefaultDeviceProfileTransportConfiguration());
    }
    deviceProfile.setProfileData(deviceProfileData);
    deviceProfile.setDefault(false);
    deviceProfile.setDefaultRuleChainId(null);
    return deviceProfile;
}
Also used : DefaultDeviceProfileConfiguration(org.thingsboard.server.common.data.device.profile.DefaultDeviceProfileConfiguration) DeviceProfile(org.thingsboard.server.common.data.DeviceProfile) DefaultDeviceProfileTransportConfiguration(org.thingsboard.server.common.data.device.profile.DefaultDeviceProfileTransportConfiguration) DeviceProfileData(org.thingsboard.server.common.data.device.profile.DeviceProfileData)

Example 2 with DefaultDeviceProfileConfiguration

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

the class DeviceBulkImportService method setUpLwM2mDeviceProfile.

private DeviceProfile setUpLwM2mDeviceProfile(TenantId tenantId, Device device) {
    DeviceProfile deviceProfile = deviceProfileService.findDeviceProfileByName(tenantId, device.getType());
    if (deviceProfile != null) {
        if (deviceProfile.getTransportType() != DeviceTransportType.LWM2M) {
            deviceProfile.setTransportType(DeviceTransportType.LWM2M);
            deviceProfile.getProfileData().setTransportConfiguration(new Lwm2mDeviceProfileTransportConfiguration());
            deviceProfile = deviceProfileService.saveDeviceProfile(deviceProfile);
        }
    } else {
        findOrCreateDeviceProfileLock.lock();
        try {
            deviceProfile = deviceProfileService.findDeviceProfileByName(tenantId, device.getType());
            if (deviceProfile == null) {
                deviceProfile = new DeviceProfile();
                deviceProfile.setTenantId(tenantId);
                deviceProfile.setType(DeviceProfileType.DEFAULT);
                deviceProfile.setName(device.getType());
                deviceProfile.setTransportType(DeviceTransportType.LWM2M);
                deviceProfile.setProvisionType(DeviceProfileProvisionType.DISABLED);
                DeviceProfileData deviceProfileData = new DeviceProfileData();
                DefaultDeviceProfileConfiguration configuration = new DefaultDeviceProfileConfiguration();
                DeviceProfileTransportConfiguration transportConfiguration = new Lwm2mDeviceProfileTransportConfiguration();
                DisabledDeviceProfileProvisionConfiguration provisionConfiguration = new DisabledDeviceProfileProvisionConfiguration(null);
                deviceProfileData.setConfiguration(configuration);
                deviceProfileData.setTransportConfiguration(transportConfiguration);
                deviceProfileData.setProvisionConfiguration(provisionConfiguration);
                deviceProfile.setProfileData(deviceProfileData);
                deviceProfile = deviceProfileService.saveDeviceProfile(deviceProfile);
            }
        } finally {
            findOrCreateDeviceProfileLock.unlock();
        }
    }
    return deviceProfile;
}
Also used : DefaultDeviceProfileConfiguration(org.thingsboard.server.common.data.device.profile.DefaultDeviceProfileConfiguration) DeviceProfile(org.thingsboard.server.common.data.DeviceProfile) Lwm2mDeviceProfileTransportConfiguration(org.thingsboard.server.common.data.device.profile.Lwm2mDeviceProfileTransportConfiguration) DeviceProfileTransportConfiguration(org.thingsboard.server.common.data.device.profile.DeviceProfileTransportConfiguration) Lwm2mDeviceProfileTransportConfiguration(org.thingsboard.server.common.data.device.profile.Lwm2mDeviceProfileTransportConfiguration) DeviceProfileData(org.thingsboard.server.common.data.device.profile.DeviceProfileData) DisabledDeviceProfileProvisionConfiguration(org.thingsboard.server.common.data.device.profile.DisabledDeviceProfileProvisionConfiguration)

Example 3 with DefaultDeviceProfileConfiguration

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

the class AbstractMqttIntegrationTest method createMqttDeviceProfile.

protected DeviceProfile createMqttDeviceProfile(TransportPayloadType transportPayloadType, String telemetryTopic, String attributesTopic, String telemetryProtoSchema, String attributesProtoSchema, String rpcResponseProtoSchema, String rpcRequestProtoSchema, String provisionKey, String provisionSecret, DeviceProfileProvisionType provisionType, boolean enableCompatibilityWithJsonPayloadFormat, boolean useJsonPayloadFormatForDefaultDownlinkTopics) {
    DeviceProfile deviceProfile = new DeviceProfile();
    deviceProfile.setName(transportPayloadType.name());
    deviceProfile.setType(DeviceProfileType.DEFAULT);
    deviceProfile.setTransportType(DeviceTransportType.MQTT);
    deviceProfile.setProvisionType(provisionType);
    deviceProfile.setProvisionDeviceKey(provisionKey);
    deviceProfile.setDescription(transportPayloadType.name() + " Test");
    DeviceProfileData deviceProfileData = new DeviceProfileData();
    DefaultDeviceProfileConfiguration configuration = new DefaultDeviceProfileConfiguration();
    MqttDeviceProfileTransportConfiguration mqttDeviceProfileTransportConfiguration = new MqttDeviceProfileTransportConfiguration();
    if (!StringUtils.isEmpty(telemetryTopic)) {
        mqttDeviceProfileTransportConfiguration.setDeviceTelemetryTopic(telemetryTopic);
    }
    if (!StringUtils.isEmpty(attributesTopic)) {
        mqttDeviceProfileTransportConfiguration.setDeviceAttributesTopic(attributesTopic);
    }
    TransportPayloadTypeConfiguration transportPayloadTypeConfiguration;
    if (TransportPayloadType.JSON.equals(transportPayloadType)) {
        transportPayloadTypeConfiguration = new JsonTransportPayloadConfiguration();
    } else {
        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);
        protoTransportPayloadConfiguration.setEnableCompatibilityWithJsonPayloadFormat(enableCompatibilityWithJsonPayloadFormat);
        protoTransportPayloadConfiguration.setUseJsonPayloadFormatForDefaultDownlinkTopics(enableCompatibilityWithJsonPayloadFormat && useJsonPayloadFormatForDefaultDownlinkTopics);
        transportPayloadTypeConfiguration = protoTransportPayloadConfiguration;
    }
    mqttDeviceProfileTransportConfiguration.setTransportPayloadTypeConfiguration(transportPayloadTypeConfiguration);
    deviceProfileData.setTransportConfiguration(mqttDeviceProfileTransportConfiguration);
    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 : 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) MqttDeviceProfileTransportConfiguration(org.thingsboard.server.common.data.device.profile.MqttDeviceProfileTransportConfiguration) 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) CheckPreProvisionedDevicesDeviceProfileProvisionConfiguration(org.thingsboard.server.common.data.device.profile.CheckPreProvisionedDevicesDeviceProfileProvisionConfiguration) DeviceProfileData(org.thingsboard.server.common.data.device.profile.DeviceProfileData) JsonTransportPayloadConfiguration(org.thingsboard.server.common.data.device.profile.JsonTransportPayloadConfiguration) DisabledDeviceProfileProvisionConfiguration(org.thingsboard.server.common.data.device.profile.DisabledDeviceProfileProvisionConfiguration)

Example 4 with DefaultDeviceProfileConfiguration

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

the class AbstractServiceTest method createDeviceProfile.

protected DeviceProfile createDeviceProfile(TenantId tenantId, String name) {
    DeviceProfile deviceProfile = new DeviceProfile();
    deviceProfile.setTenantId(tenantId);
    deviceProfile.setName(name);
    deviceProfile.setType(DeviceProfileType.DEFAULT);
    deviceProfile.setTransportType(DeviceTransportType.DEFAULT);
    deviceProfile.setDescription(name + " Test");
    DeviceProfileData deviceProfileData = new DeviceProfileData();
    DefaultDeviceProfileConfiguration configuration = new DefaultDeviceProfileConfiguration();
    DefaultDeviceProfileTransportConfiguration transportConfiguration = new DefaultDeviceProfileTransportConfiguration();
    deviceProfileData.setConfiguration(configuration);
    deviceProfileData.setTransportConfiguration(transportConfiguration);
    deviceProfile.setProfileData(deviceProfileData);
    deviceProfile.setDefault(false);
    deviceProfile.setDefaultRuleChainId(null);
    return deviceProfile;
}
Also used : DefaultDeviceProfileConfiguration(org.thingsboard.server.common.data.device.profile.DefaultDeviceProfileConfiguration) DeviceProfile(org.thingsboard.server.common.data.DeviceProfile) DefaultDeviceProfileTransportConfiguration(org.thingsboard.server.common.data.device.profile.DefaultDeviceProfileTransportConfiguration) DeviceProfileData(org.thingsboard.server.common.data.device.profile.DeviceProfileData)

Example 5 with DefaultDeviceProfileConfiguration

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

the class AbstractLwM2MIntegrationTest method createDeviceProfile.

protected void createDeviceProfile(Lwm2mDeviceProfileTransportConfiguration transportConfiguration) throws Exception {
    deviceProfile = new DeviceProfile();
    deviceProfile.setName("LwM2M");
    deviceProfile.setType(DeviceProfileType.DEFAULT);
    deviceProfile.setTenantId(tenantId);
    deviceProfile.setTransportType(DeviceTransportType.LWM2M);
    deviceProfile.setProvisionType(DeviceProfileProvisionType.DISABLED);
    deviceProfile.setDescription(deviceProfile.getName());
    DeviceProfileData deviceProfileData = new DeviceProfileData();
    deviceProfileData.setConfiguration(new DefaultDeviceProfileConfiguration());
    deviceProfileData.setProvisionConfiguration(new DisabledDeviceProfileProvisionConfiguration(null));
    deviceProfileData.setTransportConfiguration(transportConfiguration);
    deviceProfile.setProfileData(deviceProfileData);
    deviceProfile = doPost("/api/deviceProfile", deviceProfile, DeviceProfile.class);
    Assert.assertNotNull(deviceProfile);
}
Also used : DefaultDeviceProfileConfiguration(org.thingsboard.server.common.data.device.profile.DefaultDeviceProfileConfiguration) DeviceProfile(org.thingsboard.server.common.data.DeviceProfile) DeviceProfileData(org.thingsboard.server.common.data.device.profile.DeviceProfileData) DisabledDeviceProfileProvisionConfiguration(org.thingsboard.server.common.data.device.profile.DisabledDeviceProfileProvisionConfiguration)

Aggregations

DeviceProfile (org.thingsboard.server.common.data.DeviceProfile)8 DefaultDeviceProfileConfiguration (org.thingsboard.server.common.data.device.profile.DefaultDeviceProfileConfiguration)8 DeviceProfileData (org.thingsboard.server.common.data.device.profile.DeviceProfileData)8 DisabledDeviceProfileProvisionConfiguration (org.thingsboard.server.common.data.device.profile.DisabledDeviceProfileProvisionConfiguration)6 DefaultDeviceProfileTransportConfiguration (org.thingsboard.server.common.data.device.profile.DefaultDeviceProfileTransportConfiguration)4 AllowCreateNewDevicesDeviceProfileProvisionConfiguration (org.thingsboard.server.common.data.device.profile.AllowCreateNewDevicesDeviceProfileProvisionConfiguration)2 CheckPreProvisionedDevicesDeviceProfileProvisionConfiguration (org.thingsboard.server.common.data.device.profile.CheckPreProvisionedDevicesDeviceProfileProvisionConfiguration)2 DeviceProfileProvisionConfiguration (org.thingsboard.server.common.data.device.profile.DeviceProfileProvisionConfiguration)2 JsonTransportPayloadConfiguration (org.thingsboard.server.common.data.device.profile.JsonTransportPayloadConfiguration)2 ProtoTransportPayloadConfiguration (org.thingsboard.server.common.data.device.profile.ProtoTransportPayloadConfiguration)2 TransportPayloadTypeConfiguration (org.thingsboard.server.common.data.device.profile.TransportPayloadTypeConfiguration)2 Customer (org.thingsboard.server.common.data.Customer)1 Tenant (org.thingsboard.server.common.data.Tenant)1 AlarmCondition (org.thingsboard.server.common.data.device.profile.AlarmCondition)1 AlarmConditionFilter (org.thingsboard.server.common.data.device.profile.AlarmConditionFilter)1 AlarmConditionFilterKey (org.thingsboard.server.common.data.device.profile.AlarmConditionFilterKey)1 AlarmRule (org.thingsboard.server.common.data.device.profile.AlarmRule)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