use of org.eclipse.hono.adapter.lora.LoraCommand in project hono by eclipse.
the class LoraProviderTestBase method testGenerateCommandMessage.
/**
* Verifies that command messages are formatted correctly.
*/
@Test
public void testGenerateCommandMessage() {
final CommandEndpoint commandEndpoint = new CommandEndpoint();
commandEndpoint.setPayloadProperties(Map.of("py-property", "my-property-value"));
commandEndpoint.setUri("https://my-lns.io/{{deviceId}}/command");
final LoraCommand command = provider.getCommand(commandEndpoint, TEST_DEVICE_ID, Buffer.buffer("bumlux".getBytes(StandardCharsets.UTF_8)), "2");
assertThat(command.getUri()).isEqualTo("https://my-lns.io/" + TEST_DEVICE_ID + "/command");
assertCommandFormat(command.getPayload());
}
use of org.eclipse.hono.adapter.lora.LoraCommand in project hono by eclipse.
the class JsonBasedLoraProvider method getCommand.
@Override
public LoraCommand getCommand(final CommandEndpoint commandEndpoint, final String deviceId, final Buffer payload, final String subject) {
Objects.requireNonNull(commandEndpoint);
Objects.requireNonNull(deviceId);
Objects.requireNonNull(payload);
Objects.requireNonNull(subject);
if (Strings.isNullOrEmpty(commandEndpoint.getUri())) {
throw new IllegalArgumentException("command endpoint uri is empty");
}
final JsonObject commandPayload = getCommandPayload(payload, deviceId, subject);
commandEndpoint.getPayloadProperties().forEach(commandPayload::put);
return new LoraCommand(commandPayload, commandEndpoint.getFormattedUri(deviceId));
}
Aggregations