-
Notifications
You must be signed in to change notification settings - Fork 10
Conversation
-> Fixing test case 'beginAddStatusProperty' due to previous change in the encoding of the values -> Deleting build.sh script - accidentially committed at an earlier commit -> Adjusting test case 'addThingAndChangeValue' after changing encoding of name/type from strings to CborIntegerMapKeys -> Adjusting test case 'decodeBuffer' after changing encoding of name/type from strings to CborIntegerMapKeys -> Removing unnecessary trailing '0' -> Adjusting test case 'decodeProperties' after changing encoding of name/type from strings to CborIntegerMapKeys -> Bugfix: Converting CBOR Half Float Types to Float has been incorrectly implemented -> Adding separator comments for better readabiltiy
…in the int property case
-> Adjusting test case 'decodeBufferShouldnUpdateIfReadonly' after changing encoding of name/type from strings to CborIntegerMapKeys -> Adjusting test case 'shouldNotDecode' after changing encoding of name/type from strings to CborIntegerMapKeys -> Adjusting test case 'decodeShouldNotHang' after changing encoding of name/type from strings to CborIntegerMapKeys -> Deleting test 'intAndFloatDiffer' since the test has no purpose and is incorrectly implemented on top of it assertNotEqual(buf, buf2) only compares the address of the 2 buffers which are of course ... not equal thing.encode(...) is called twice with the same 'buf' -> hence 'buf' is written twice and 'buf2' never ... There is no value in knowing that different CBOR buffers are created from float and integer ... better would be to check if the appopriate buffers are created for int/float -> Fixing test case 'testIfCallbackIsCalledWhenPropertyIsChanged' after changing encoding encoding of name/type from strings to CborIntegerMapKeys -> Fixing test case 'testMinimumDeltaWhenPublishOnChange' after changing encoding encoding of name/type from strings to CborIntegerMapKeys -> Fixing test case 'testWhenPublishOnChangeIfRateLimitWorks' after changing encoding encoding of name/type from strings to CborIntegerMapKeys -> Fixing test case 'writeOnly' after changing encoding encoding of name/type from strings to CborIntegerMapKeys -> Fixing test case 'publishEvery' after changing encoding encoding of name/type from strings to CborIntegerMapKeys -> Fixing test case 'createaManyProperties' after changing encoding encoding of name/type from strings to CborIntegerMapKeys -> Fixing test case 'stringProperty' after changing encoding encoding of name/type from strings to CborIntegerMapKeys -> Refactoring test case 'beginAddStatusProperty' to 'encodeStatusProperty' -> Replacing test function 'stringProperty' with 'encodeStringProperty' and 'decodeStringProperty' -> Refactor test case 'decodeBuffer' to 'decodeIntProperty' -> Adding test case 'encodeIntProperty' -> Adding test case 'encodeFloatProperty' and 'decodeFloatProperty' -> Aggregating test function for 'readOnly' and 'writeOnly' -> Adding test cases for encoding/decoding boolean properties -> Moving test cases for decoding/encoding multiple properties on the position where they belong -> Aggregate tests where the encoder is provided with invalid data -> Deleting redundant test case 'testWhenPublishOnChangeIfPropertyIsNotChangedValueShouldBeEncodedOnlyOnceAtStartup' - test 'encodeBoolProperty' contains the same test coverage -> Deleting test 'publishEvery' because test 'testWhenPublishEveryNSecondsIfDataIsReallyOnlyPublishedEveryNSeconds' contains the same amount of information -> Refactoring of all testcases now complete ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR looks convincing, of course it can't be merged until both decode and encode won't use the same format; one of my earliest proposals was to make the tag usage optional (via a runtime switch) so the backend can be adapted progressively so we could test tag encoding only for boards with low bitrate like Lora.
@mattiabertorello @mastrolinux
Making the tag usage configurable at runtime (or maybe dependent on a compile time switch, aka |
…n all test cases - test code needed
…rder to enable offline testing without an Arduino board
…to appopriate directories
…or both protocols
…implify the loop condition
Rewrite complete - according to the unit tests decode/encode should work for both old and new protocol version. |
I test this PR with the onudra cli and It almost working:
The base name could be removed but the base time and also the tag |
The old parser "ate" such CBOR data sets but it did not extract neither |
Yes, they are necessary. The CBOR tags that should be added are |
The |
Okay - that is certainly possible. I've got one more question though - do we need the support for |
Yes, we can merge, but before it's mandatory to ignore the tags not yet supported. |
In this case I think the better approach is to do the full implementation. Will update when done. |
…seName and Time entry (next to the property name and value entries
…longer important, as long as there is only one CBOR key per map
…nstead of cancelling the parse process
… datatype into a smaller version
Ready to merge ;) |
The stated aim of CM-386 is to reduce the payload size by exchanging the string keys used to identify names, data types, ... by integer numbers by using the table found at RFC8428.
Example:
[{"n": "test", "vs": "test"}]
becomes[{0: "test", 3: "test"}]
.This has been successfully implemented when for the
encode
method (data is sent from device to server) and verified via unit tests.Difficulties arise when trying to implement the same functionality for the method
decode
(data is sent from server to the device). This is due to the fact that the function used for retrieve the value for a given keycbor_value_map_find_value
only except string keys and unfortunately no integer keys as we would need.The consequence of this fact would be to perform a major rewrite of method
ArduinoCloudThing::decode
in order to use less of the higher-level CBOR functions likecbor_value_map_find_value
and implement the functionality using lower level CBOR functions.I'd like to have input wether to live with the fact that the compression currently only works for encoding or if a rewrite of the decode function should be undertaken.
Last but nut least: There has been a lingering bug when half float values were sent from the server due to the nature of the implementation of the
cbor_value_get_half_float
function and the ArduinoCloudThing's library usage:and
As one can see memcpy-ing a 16-Bit unsigned int to a float can simply not work.
Code for properly converting from the CBOR half float contained in the uint16_t can be found on page #50 of RFC7049 and is fairly esoteric.
The bugfix has been implemented and tested.