IotHubTransportMessage message = new IotHubTransportMessage(data, MessageType.DEVICE_TELEMETRY);
message = new IotHubTransportMessage(data, MessageType.DEVICE_METHODS); message = new IotHubTransportMessage(new byte[0], MessageType.DEVICE_METHODS);
private void checkSubscription() { if (!isSubscribed) { /* **Codes_SRS_DEVICETWIN_25_018: [**If not already subscribed then this method shall create a device twin message with empty payload and set its type as DEVICE_OPERATION_TWIN_SUBSCRIBE_DESIRED_PROPERTIES_REQUEST.**]** */ IotHubTransportMessage desiredPropertiesNotificationRequest = new IotHubTransportMessage(new byte[0], MessageType.DEVICE_TWIN); desiredPropertiesNotificationRequest.setDeviceOperationType(DeviceOperations.DEVICE_OPERATION_TWIN_SUBSCRIBE_DESIRED_PROPERTIES_REQUEST); /* **Codes_SRS_DEVICETWIN_25_019: [**If not already subscribed then this method shall send the message using sendEventAsync.**]** */ this.deviceIO.sendEventAsync(desiredPropertiesNotificationRequest, new deviceTwinRequestMessageCallback(), null, this.config.getDeviceId()); } }
public void getDeviceTwin() { /* **Codes_SRS_DEVICETWIN_25_005: [**The method shall create a device twin message with empty payload to be sent IotHub.**]** */ IotHubTransportMessage getTwinRequestMessage = new IotHubTransportMessage(new byte[0], MessageType.DEVICE_TWIN); /* **Codes_SRS_DEVICETWIN_25_007: [**This method shall set the request id for the message by calling setRequestId .**]** */ getTwinRequestMessage.setRequestId(String.valueOf(requestId++)); /* **Codes_SRS_DEVICETWIN_25_006: [**This method shall set the message type as DEVICE_OPERATION_TWIN_GET_REQUEST by calling setDeviceOperationType.**]** */ getTwinRequestMessage.setDeviceOperationType(DeviceOperations.DEVICE_OPERATION_TWIN_GET_REQUEST); /* **Codes_SRS_DEVICETWIN_25_008: [**This method shall send the message to the lower transport layers by calling sendEventAsync.**]** */ this.deviceIO.sendEventAsync(getTwinRequestMessage, new deviceTwinRequestMessageCallback(), null, this.config.getDeviceId()); }
IotHubTransportMessage message = new IotHubTransportMessage(methodRequest.toJson());
messsage = new IotHubTransportMessage(data, MessageType.DEVICE_TWIN); messsage.setDeviceOperationType(DeviceOperations.DEVICE_OPERATION_UNKNOWN); messsage = new IotHubTransportMessage(new byte[0], MessageType.DEVICE_TWIN); // empty body messsage.setDeviceOperationType(DeviceOperations.DEVICE_OPERATION_UNKNOWN); messsage = new IotHubTransportMessage(data, MessageType.DEVICE_TWIN); messsage.setDeviceOperationType(DeviceOperations.DEVICE_OPERATION_TWIN_SUBSCRIBE_DESIRED_PROPERTIES_RESPONSE);
IotHubTransportMessage subscribeMessage = new IotHubTransportMessage(new byte[0], MessageType.DEVICE_METHODS); subscribeMessage.setDeviceOperationType(DeviceOperations.DEVICE_OPERATION_METHOD_SUBSCRIBE_REQUEST); subscribeMessage.setConnectionDeviceId(this.config.getDeviceId());
IotHubTransportMessage message = new IotHubTransportMessage(fileUploadStatusParser.toJson());
IotHubTransportMessage updateReportedPropertiesRequest = new IotHubTransportMessage(serializedReportedProperties.getBytes(), MessageType.DEVICE_TWIN); updateReportedPropertiesRequest.setConnectionDeviceId(this.config.getDeviceId());
IotHubTransportMessage iotHubTransportMessage = new IotHubTransportMessage(msgBody, MessageType.UNKNOWN);
private IotHubStatusCode getContainer() throws IOException, IllegalArgumentException, URISyntaxException { /* Codes_SRS_FILEUPLOADTASK_21_007: [The run shall create a FileUpload request message, by using the FileUploadRequestParser.] */ FileUploadRequestParser fileUploadRequestParser = new FileUploadRequestParser(blobName); IotHubTransportMessage message = new IotHubTransportMessage(fileUploadRequestParser.toJson()); /* Codes_SRS_FILEUPLOADTASK_21_008: [The run shall set the message method as `POST`.] */ message.setIotHubMethod(IotHubMethod.POST); ResponseMessage responseMessage; synchronized (FILE_UPLOAD_LOCK) { /* Codes_SRS_FILEUPLOADTASK_21_010: [The run shall open the connection with the iothub, using the httpsTransportManager.] */ httpsTransportManager.open(); /* Codes_SRS_FILEUPLOADTASK_21_011: [The run shall send the blob request message to the iothub, using the httpsTransportManager.] */ responseMessage = httpsTransportManager.sendFileUploadMessage(message); /* Codes_SRS_FILEUPLOADTASK_21_012: [The run shall close the connection with the iothub, using the httpsTransportManager.] */ httpsTransportManager.close(); } IotHubStatusCode resultStatus = responseMessage.getStatus(); /* Codes_SRS_FILEUPLOADTASK_21_013: [If result status for the blob request is not `OK`, or `OK_EMPTY`, the run shall call the userCallback bypassing the received status, and abort the upload.] */ if(resultStatus == IotHubStatusCode.OK) { addBlobInformation(responseMessage); } else if(resultStatus == IotHubStatusCode.OK_EMPTY) { /* Codes_SRS_FILEUPLOADTASK_21_014: [If result status for the blob request is `OK_EMPTY`, the run shall call the userCallback with the stratus `ERROR`, and abort the upload.] */ resultStatus = IotHubStatusCode.ERROR; } return resultStatus; }
transportMessage = new IotHubTransportMessage(message.getBytes(), message.getMessageType(), message.getMessageId(), message.getCorrelationId(), message.getProperties()); transportMessage.setIotHubConnectionString(message.getIotHubConnectionString());
IotHubTransportMessage responseMessage = new IotHubTransportMessage(methodParserObject.toJson().getBytes(), MessageType.DEVICE_METHODS);
transportMessage = new IotHubTransportMessage(message.getBytes(), message.getMessageType(), message.getMessageId(), message.getCorrelationId(), message.getProperties()); transportMessage.setMessageCallback(this.config.getDeviceTelemetryMessageCallback(message.getInputName())); transportMessage.setMessageCallbackContext(this.config.getDeviceTelemetryMessageContext(message.getInputName()));
IotHubTransportMessage transportMessage = new IotHubTransportMessage(message.getBytes(), message.getMessageType(), message.getMessageId(), message.getCorrelationId(), message.getProperties()); if (status == IotHubStatusCode.OK || status == IotHubStatusCode.OK_EMPTY)