use of org.eclipse.vorto.mapping.engine.model.blegatt.GattDevice in project vorto by eclipse.
the class BinaryMappingTest method testMappingWithGattStructure.
@Test
public void testMappingWithGattStructure() throws Exception {
IDataMapper mapper = IDataMapper.newBuilder().withSpecification(new SpecGattConverter()).registerConverterFunction(BinaryFunctionFactory.createFunctions()).registerScriptEvalProvider(new JavascriptEvalProvider()).build();
GattDevice gattDevice = new GattDevice();
GattService gattService = new GattService();
List<GattCharacteristic> characteristics = new ArrayList<GattCharacteristic>();
byte[] dest = new byte[6];
byte[] value = Conversion.intToByteArray(2000, 0, dest, 3, 3);
characteristics.add(new GattCharacteristic("23-D1-13-EF-5F-78-23-15-DE-EF-12-12-0D-F0-00-00", value));
gattService.setCharacteristics(characteristics);
List<GattService> services = new ArrayList<GattService>();
services.add(gattService);
gattDevice.setModelNumber("23-23-23");
gattDevice.setServices(services);
gattDevice.setCharacteristics(characteristics);
String json = new Gson().toJson(gattDevice);
InfomodelValue mapped = mapper.mapSource(gson.fromJson(json, Object.class));
assertEquals(20.00, mapped.get("button").getStatusProperty("sensor_value").get().getValue());
System.out.println(mapped);
}
Aggregations