Open pauljurczak opened 8 months ago
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);
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);
| ^
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
When I try:
the message is truncated at the first
0x00
. Is there a way to send an arbitrary byte stream? I don't see an overload ofpublish()
, which accepts other thanString
arguments.