Toyomasa Watarai / Mbed 2 deprecated hello_message_pack

Dependencies:   mbed msgpack-embedded

Files at this revision

API Documentation at this revision

Comitter:
MACRUM
Date:
Sun Oct 22 02:10:47 2017 +0000
Commit message:
Initial commit

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
msgpack-embedded.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Oct 22 02:10:47 2017 +0000
@@ -0,0 +1,27 @@
+#include "mbed.h"
+#include "msgpack-embedded.h"
+
+int main(void) {
+
+        /* creates buffer and serializer instance. */
+        msgpack_sbuffer* buffer = msgpack_sbuffer_new();
+        msgpack_packer* pk = msgpack_packer_new(buffer, msgpack_sbuffer_write);
+
+        msgpack_sbuffer_clear(buffer);
+        msgpack_pack_array(pk, 2);      // number of array
+        
+        msgpack_pack_uint8(pk, 2);      // e.g. sensor ID
+        msgpack_pack_uint8(pk, 19);     // e.g. distance (cm)
+        
+        printf("buffer size = %d\n", buffer->size);
+
+        printf("buffer = ");
+        for(int i = 0; i < buffer->size; i++) {
+            printf("0x%02x, ", buffer->data[i]);
+        }
+        printf("\n");
+
+        /* cleaning */
+        msgpack_sbuffer_free(buffer);
+        msgpack_packer_free(pk);
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Oct 22 02:10:47 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/b484a57bc302
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/msgpack-embedded.lib	Sun Oct 22 02:10:47 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/hideakitai/code/msgpack-embedded/#bd0c06dd6e92