Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R&D: MsgPack serialization #4

Open
om26er opened this issue May 29, 2024 · 1 comment
Open

R&D: MsgPack serialization #4

om26er opened this issue May 29, 2024 · 1 comment

Comments

@om26er
Copy link
Member

om26er commented May 29, 2024

Need to check MSGPACK support

@asimfarooq5
Copy link
Collaborator

MsgPack serialization

This project demonstrates how to deserialize WAMP messages on an ESP32 by MsgPack serialization. It provides simple methods to convert WAMP message

Open Arduino IDE.

Create new Sketch and copy the code.

#include <MsgPack.h>

void setup() {
  Serial.begin(115200);
}

void loop() {
  delay(1000);
  uint8_t packedData[] = {0xA5, 'H', 'e', 'l', 'l', 'o'}; 
  size_t dataLength = sizeof(packedData);

  
  arduino::msgpack::Unpacker unpacker;

  // Feed the packed data to the Unpacker
  unpacker.feed(packedData, dataLength);

  
  arduino::msgpack::str_t unpackedString;
  
  if (unpacker.deserialize(unpackedString)) {
    // Successfully unpacked the string
    Serial.println(unpackedString.c_str());
  } else {
    Serial.println("Failed to unpack");
  }
}

Connect your ESP32, upload the code and you’ll see the deserialized WAMP message printed to the serial monitor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants