@Override public IDeviceEventBatchResponse addDeviceEventBatch(String assignmentToken, IDeviceEventBatch batch) throws SiteWhereException { return SiteWherePersistence.deviceEventBatchLogic(assignmentToken, batch, this); }
@Override public IDevice deleteDeviceElementMapping(String hardwareId, String path) throws SiteWhereException { return SiteWherePersistence.deviceElementMappingDeleteLogic(this, hardwareId, path); }
public static String boilerplate(List<String> messages, String c) { return boilerplate(messages, c, DEFAULT_MESSAGE_WIDTH); }
@Override public List<IDecodedDeviceRequest<?>> decode(byte[] payload, Map<String, Object> metadata) throws EventDecodeException { LOGGER.info("=== EVENT DATA BEGIN ==="); LOGGER.info(new String(payload)); LOGGER.info("(hex) " + DataUtils.bytesToHex(payload)); LOGGER.info("=== EVENT DATA END ==="); return new ArrayList<IDecodedDeviceRequest<?>>(); }
@Override public IDevice createDeviceElementMapping(String hardwareId, IDeviceElementMapping mapping) throws SiteWhereException { return SiteWherePersistence.deviceElementMappingCreateLogic(this, hardwareId, mapping); }
@Override public IBatchOperation createBatchCommandInvocation(IBatchCommandInvocationRequest request) throws SiteWhereException { String uuid = ((request.getToken() != null) ? request.getToken() : UUID.randomUUID().toString()); IBatchOperationCreateRequest generic = SiteWherePersistence.batchCommandInvocationCreateLogic(request, uuid); return createBatchOperation(generic); }
/** * Update an existing device command. * * @param context * @param token * @param request * @return * @throws SiteWhereException */ public static DeviceCommand updateDeviceCommand(IHBaseContext context, String token, IDeviceCommandCreateRequest request) throws SiteWhereException { DeviceCommand updated = assertDeviceCommand(context, token); List<IDeviceCommand> existing = listDeviceCommands(context, updated.getSpecificationToken(), false); SiteWherePersistence.deviceCommandUpdateLogic(request, updated, existing); return putDeviceCommandPayload(context, updated); }
public static byte[] doubleDigest(byte[] input) { return doubleDigest(input, 0, input.length); }
/** * Generate unique id by creating a UUID and encoding the bytes in base 58. * * @return */ protected String generateUniqueId() { UUID uuid = UUID.randomUUID(); ByteBuffer bb = ByteBuffer.wrap(new byte[16]); bb.putLong(uuid.getMostSignificantBits()); bb.putLong(uuid.getLeastSignificantBits()); return Base58.encode(bb.array()); }
/** * Handle common logic for updating a hardware asset. * * @param hardware * @param request * @throws SiteWhereException */ public static void hardwareAssetUpdateLogic(HardwareAsset hardware, IHardwareAssetCreateRequest request) throws SiteWhereException { assetUpdateLogic(hardware, request); if (request.getSku() != null) { hardware.setSku(request.getSku()); } if (request.getDescription() != null) { hardware.setDescription(request.getDescription()); } }
public static String boilerplate(String message) { return boilerplate(message, "*", DEFAULT_MESSAGE_WIDTH); }
@Override public byte[] encode(IDeviceCommandExecution execution, IDeviceNestingContext nested, IDeviceAssignment assignment) throws SiteWhereException { byte[] encoded = ProtobufMessageBuilder.createMessage(execution, nested, assignment, getTenant()); LOGGER.debug("Protobuf message: 0x" + DataUtils.bytesToHex(encoded)); return encoded; }
@Override public IDeviceEventBatchResponse addDeviceEventBatch(String assignmentToken, IDeviceEventBatch batch) throws SiteWhereException { return SiteWherePersistence.deviceEventBatchLogic(assignmentToken, batch, this); }
@Override public IDevice deleteDeviceElementMapping(String hardwareId, String path) throws SiteWhereException { return SiteWherePersistence.deviceElementMappingDeleteLogic(this, hardwareId, path); }
@Override public IDevice createDeviceElementMapping(String hardwareId, IDeviceElementMapping mapping) throws SiteWhereException { return SiteWherePersistence.deviceElementMappingCreateLogic(this, hardwareId, mapping); }
public static String boilerplate(String message) { return boilerplate(message, "*", DEFAULT_MESSAGE_WIDTH); }
@Override public IDeviceEventBatchResponse addDeviceEventBatch(String assignmentToken, IDeviceEventBatch batch) throws SiteWhereException { return SiteWherePersistence.deviceEventBatchLogic(assignmentToken, batch, this); }
public static String boilerplate(List<String> messages, String c) { return boilerplate(messages, c, DEFAULT_MESSAGE_WIDTH); }
public static String boilerplate(String message, String character, int maxlength) { return boilerplate(new ArrayList<String>(Arrays.asList(new String[] { message })), character, maxlength); }
public static String boilerplate(String message, String character, int maxlength) { return boilerplate(new ArrayList<String>(Arrays.asList(new String[] { message })), character, maxlength); }