Search in sources :

Example 1 with KuraBirthPayloadBuilder

use of org.eclipse.kura.core.message.KuraBirthPayload.KuraBirthPayloadBuilder in project kura by eclipse.

the class LifeCyclePayloadBuilder method buildBirthPayload.

public KuraBirthPayload buildBirthPayload() {
    // build device profile
    KuraDeviceProfile deviceProfile = buildDeviceProfile();
    // build application IDs
    String appIds = buildApplicationIDs();
    // build accept encoding
    String acceptEncoding = buildAcceptEncoding();
    // build device name
    CloudServiceOptions cso = this.m_cloudServiceImpl.getCloudServiceOptions();
    String deviceName = cso.getDeviceDisplayName();
    if (deviceName == null) {
        deviceName = this.m_cloudServiceImpl.getSystemService().getDeviceName();
    }
    // build birth certificate
    KuraBirthPayloadBuilder birthPayloadBuilder = new KuraBirthPayloadBuilder();
    birthPayloadBuilder.withUptime(deviceProfile.getUptime()).withDisplayName(deviceName).withModelName(deviceProfile.getModelName()).withModelId(deviceProfile.getModelId()).withPartNumber(deviceProfile.getPartNumber()).withSerialNumber(deviceProfile.getSerialNumber()).withFirmwareVersion(deviceProfile.getFirmwareVersion()).withBiosVersion(deviceProfile.getBiosVersion()).withOs(deviceProfile.getOs()).withOsVersion(deviceProfile.getOsVersion()).withJvmName(deviceProfile.getJvmName()).withJvmVersion(deviceProfile.getJvmVersion()).withJvmProfile(deviceProfile.getJvmProfile()).withKuraVersion(deviceProfile.getKuraVersion()).withConnectionInterface(deviceProfile.getConnectionInterface()).withConnectionIp(deviceProfile.getConnectionIp()).withAcceptEncoding(acceptEncoding).withApplicationIdentifiers(appIds).withAvailableProcessors(deviceProfile.getAvailableProcessors()).withTotalMemory(deviceProfile.getTotalMemory()).withOsArch(deviceProfile.getOsArch()).withOsgiFramework(deviceProfile.getOsgiFramework()).withOsgiFrameworkVersion(deviceProfile.getOsgiFrameworkVersion());
    if (this.m_cloudServiceImpl.m_imei != null && this.m_cloudServiceImpl.m_imei.length() > 0 && !this.m_cloudServiceImpl.m_imei.equals(ERROR)) {
        birthPayloadBuilder.withModemImei(this.m_cloudServiceImpl.m_imei);
    }
    if (this.m_cloudServiceImpl.m_iccid != null && this.m_cloudServiceImpl.m_iccid.length() > 0 && !this.m_cloudServiceImpl.m_iccid.equals(ERROR)) {
        birthPayloadBuilder.withModemIccid(this.m_cloudServiceImpl.m_iccid);
    }
    if (this.m_cloudServiceImpl.m_imsi != null && this.m_cloudServiceImpl.m_imsi.length() > 0 && !this.m_cloudServiceImpl.m_imsi.equals(ERROR)) {
        birthPayloadBuilder.withModemImsi(this.m_cloudServiceImpl.m_imsi);
    }
    if (this.m_cloudServiceImpl.m_rssi != null && this.m_cloudServiceImpl.m_rssi.length() > 0) {
        birthPayloadBuilder.withModemRssi(this.m_cloudServiceImpl.m_rssi);
    }
    if (deviceProfile.getLatitude() != null && deviceProfile.getLongitude() != null) {
        KuraPosition KuraPosition = new KuraPosition();
        KuraPosition.setLatitude(deviceProfile.getLatitude());
        KuraPosition.setLongitude(deviceProfile.getLongitude());
        KuraPosition.setAltitude(deviceProfile.getAltitude());
        birthPayloadBuilder.withPosition(KuraPosition);
    }
    return birthPayloadBuilder.build();
}
Also used : KuraPosition(org.eclipse.kura.message.KuraPosition) KuraDeviceProfile(org.eclipse.kura.core.message.KuraDeviceProfile) KuraBirthPayloadBuilder(org.eclipse.kura.core.message.KuraBirthPayload.KuraBirthPayloadBuilder)

Aggregations

KuraBirthPayloadBuilder (org.eclipse.kura.core.message.KuraBirthPayload.KuraBirthPayloadBuilder)1 KuraDeviceProfile (org.eclipse.kura.core.message.KuraDeviceProfile)1 KuraPosition (org.eclipse.kura.message.KuraPosition)1