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

Is there a way to send 0x00? #136

Open
pauljurczak opened this issue Feb 4, 2024 · 3 comments
Open

Is there a way to send 0x00? #136

pauljurczak opened this issue Feb 4, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@pauljurczak
Copy link

When I try:

  uint8_t a[8] = {48, 49, 50, 0, 51, 52, 0, 53};
  client.publish(outTopic, String(a, 8));

the message is truncated at the first 0x00. Is there a way to send an arbitrary byte stream? I don't see an overload of publish(), which accepts other than String arguments.

@pauljurczak pauljurczak added the enhancement New feature or request label Feb 4, 2024
@ChuckMash
Copy link

Look like you could just be able to pass 'a' right to publish without using String
https://github.com/plapointe6/EspMQTTClient/blob/master/src/EspMQTTClient.cpp#L421

Maybe just

  uint8_t a[8] = {48, 49, 50, 0, 51, 52, 0, 53};
  client.publish(outTopic, a, 8);

@pauljurczak
Copy link
Author

It should work, but I have the newest version 1.13.3 installed through Arduino IDE library manager and bool publish(const char* topic, const uint8_t* payload, unsigned int plenght, bool retain) is not there.

I copied the files from GitHub repo manually and this snippet:

  const uint8_t a[] = {48, 49, 50, 0, 51, 52, 0, 53};
  client.publish("out", a, 8);

still fails the same way, even though bool publish(const char* topic, const uint8_t* payload, unsigned int plenght, bool retain) is now available:

/home/paul/Arduino/mqtt/mqtt.ino: In function 'void loop()':
/home/paul/Arduino/mqtt/mqtt.ino:48:25: error: invalid user-defined conversion from 'const uint8_t [8]' {aka 'const unsigned char [8]'} to 'const String&' [-fpermissive]
   48 |   client.publish("out", a, 8);
      |                         ^

@pauljurczak
Copy link
Author

That function needs all arguments, i.e.:

  client.publish("out", a, 8, false);

It compiles now, but fails to link:

/home/paul/.arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/esp-12.2.0_20230208/bin/../lib/gcc/xtensa-esp32-elf/12.2.0/../../../../xtensa-esp32-elf/bin/ld: /home/paul/.var/app/cc.arduino.IDE2/cache/arduino/sketches/D4176805DF73D754A303F0A6672650D8/sketch/mqtt.ino.cpp.o:(.literal._Z4loopv+0x28): undefined reference to `_ZN13EspMQTTClient7publishEPKcPKhjb'
/home/paul/.arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/esp-12.2.0_20230208/bin/../lib/gcc/xtensa-esp32-elf/12.2.0/../../../../xtensa-esp32-elf/bin/ld: /home/paul/.var/app/cc.arduino.IDE2/cache/arduino/sketches/D4176805DF73D754A303F0A6672650D8/sketch/mqtt.ino.cpp.o:(.literal.startup._GLOBAL__sub_I_i+0x1c): undefined reference to `_ZN13EspMQTTClientC1EPKcS1_S1_S1_t'
/home/paul/.arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/esp-12.2.0_20230208/bin/../lib/gcc/xtensa-esp32-elf/12.2.0/../../../../xtensa-esp32-elf/bin/ld: /home/paul/.var/app/cc.arduino.IDE2/cache/arduino/sketches/D4176805DF73D754A303F0A6672650D8/sketch/mqtt.ino.cpp.o: in function `_Z4loopv':
/home/paul/Arduino/mqtt/mqtt.ino:48: undefined reference to `_ZN13EspMQTTClient7publishEPKcPKhjb'
/home/paul/.arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/esp-12.2.0_20230208/bin/../lib/gcc/xtensa-esp32-elf/12.2.0/../../../../xtensa-esp32-elf/bin/ld: /home/paul/.var/app/cc.arduino.IDE2/cache/arduino/sketches/D4176805DF73D754A303F0A6672650D8/sketch/mqtt.ino.cpp.o: in function `_GLOBAL__sub_I_i':
/home/paul/Arduino/mqtt/mqtt.ino:25: undefined reference to `_ZN13EspMQTTClientC1EPKcS1_S1_S1_t'
collect2: error: ld returned 1 exit status

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

No branches or pull requests

2 participants