Search in sources :

Example 1 with SenMLPack

use of org.eclipse.leshan.senml.SenMLPack in project leshan by eclipse.

the class AbstractSenMLTest method getPackWithSingleOpaqueValue.

protected SenMLPack getPackWithSingleOpaqueValue(String path, byte[] value) {
    SenMLPack pack = new SenMLPack();
    SenMLRecord r = new SenMLRecord();
    r.setBaseName(path);
    r.setOpaqueValue(value);
    pack.addRecord(r);
    return pack;
}
Also used : SenMLPack(org.eclipse.leshan.senml.SenMLPack) SenMLRecord(org.eclipse.leshan.senml.SenMLRecord)

Example 2 with SenMLPack

use of org.eclipse.leshan.senml.SenMLPack in project leshan by eclipse.

the class SenMLCborSerializerTest method deserialize_device_object_.

@Test
public void deserialize_device_object_() throws Exception {
    SenMLPack pack = decoder.fromSenML(Hex.decodeHex(givenSenMLCborExample().toCharArray()));
    SenMLTestUtil.assertSenMLPackEquals(givenDeviceObjectInstance(), pack);
}
Also used : SenMLPack(org.eclipse.leshan.senml.SenMLPack) Test(org.junit.Test)

Example 3 with SenMLPack

use of org.eclipse.leshan.senml.SenMLPack in project leshan by eclipse.

the class SenMLCborSerializerTest method deserialize_opaque_resource.

@Test
public void deserialize_opaque_resource() throws Exception {
    // value : [{-2: "/0/0/3", 8: h'ABCDEF'}]
    byte[] cbor = Hex.decodeHex("81a221662f302f302f330843abcdef".toCharArray());
    SenMLPack pack = decoder.fromSenML(cbor);
    SenMLTestUtil.assertSenMLPackEquals(getPackWithSingleOpaqueValue("/0/0/3", Hex.decodeHex("ABCDEF".toCharArray())), pack);
}
Also used : SenMLPack(org.eclipse.leshan.senml.SenMLPack) Test(org.junit.Test)

Example 4 with SenMLPack

use of org.eclipse.leshan.senml.SenMLPack in project leshan by eclipse.

the class SenMLCborSerializerTest method serialize_opaque_resource_.

@Test
public void serialize_opaque_resource_() throws Exception {
    SenMLPack pack = getPackWithSingleOpaqueValue("/0/0/3", Hex.decodeHex("ABCDEF".toCharArray()));
    byte[] cbor = encoder.toSenML(pack);
    // value : [{-2: "/0/0/3", 8: h'ABCDEF'}]
    String expected = "81a221662f302f302f330843abcdef";
    Assert.assertEquals(expected, Hex.encodeHexString(cbor));
}
Also used : SenMLPack(org.eclipse.leshan.senml.SenMLPack) Test(org.junit.Test)

Example 5 with SenMLPack

use of org.eclipse.leshan.senml.SenMLPack in project leshan by eclipse.

the class SenMLJsonSerDesTest method serialize_then_deserialize_device_object.

@Test
public void serialize_then_deserialize_device_object() throws SenMLException {
    byte[] json = encoder.toSenML(givenDeviceObjectInstance());
    SenMLPack pack = decoder.fromSenML(json);
    SenMLTestUtil.assertSenMLPackEquals(givenDeviceObjectInstance(), pack);
}
Also used : SenMLPack(org.eclipse.leshan.senml.SenMLPack) Test(org.junit.Test)

Aggregations

SenMLPack (org.eclipse.leshan.senml.SenMLPack)23 SenMLException (org.eclipse.leshan.senml.SenMLException)11 CodecException (org.eclipse.leshan.core.node.codec.CodecException)10 Test (org.junit.Test)10 SenMLRecord (org.eclipse.leshan.senml.SenMLRecord)9 LwM2mPath (org.eclipse.leshan.core.node.LwM2mPath)6 TimestampedLwM2mNode (org.eclipse.leshan.core.node.TimestampedLwM2mNode)6 LwM2mNode (org.eclipse.leshan.core.node.LwM2mNode)5 ArrayList (java.util.ArrayList)3 Collection (java.util.Collection)2 CBORNumber (com.upokecenter.cbor.CBORNumber)1 CBORObject (com.upokecenter.cbor.CBORObject)1 BigInteger (java.math.BigInteger)1 HashMap (java.util.HashMap)1 TimestampedLwM2mNodes (org.eclipse.leshan.core.node.TimestampedLwM2mNodes)1 ULong (org.eclipse.leshan.core.util.datatype.ULong)1