Giter Site home page Giter Site logo

Comments (5)

tyeth avatar tyeth commented on July 30, 2024

https://github.com/adafruit/Adafruit_Wippersnapper_Arduino/actions/runs/3451873666/jobs/5761396456#step:8:120
Both lines in this error message are missing the QOS parameter which are on the next lines in the MQTT library.

 /home/runner/Arduino/libraries/Adafruit_Wippersnapper_Arduino/src/Wippersnapper.cpp: In function 'void publishI2CResponse(wippersnapper_signal_v1_I2CResponse*)':
  /home/runner/Arduino/libraries/Adafruit_Wippersnapper_Arduino/src/Wippersnapper.cpp:466:79: error: call of overloaded 'publish(char*&, uint8_t [512], size_t&, int)' is ambiguous
     WS._mqtt->publish(WS._topic_signal_i2c_device, WS._buffer_outgoing, msgSz, 1);
                                                                                 ^
  In file included from /home/runner/Arduino/libraries/Adafruit_Wippersnapper_Arduino/src/Wippersnapper.h:51,
                   from /home/runner/Arduino/libraries/Adafruit_Wippersnapper_Arduino/src/Wippersnapper.cpp:34:
  /home/runner/Arduino/libraries/Adafruit_MQTT_Library/Adafruit_MQTT.h:195:8: note: candidate: 'bool Adafruit_MQTT::publish(const char*, uint8_t*, uint16_t, uint8_t)'
     bool publish(const char *topic, uint8_t *payload, uint16_t bLen,
          ^~~~~~~
  /home/runner/Arduino/libraries/Adafruit_MQTT_Library/Adafruit_MQTT.h:197:8: note: candidate: 'bool Adafruit_MQTT::publish(const char*, uint8_t*, uint16_t, bool, uint8_t)'
     bool publish(const char *topic, uint8_t *payload, uint16_t bLen, bool retain,
          ^~~~~~~

from adafruit_mqtt_library.

tyeth avatar tyeth commented on July 30, 2024

I had a quick play and removing the default values for qos in the header file allowed my wippersnapper build to get past the ambiguity, but that feels not great as it wasn't added to line 192 etc in #216. Played with parameter order and defaults but didn't help.
Then occurred to me to remove the default values for just the new overloads, avoiding breaking the default QOS value in old code examples, but enforcing the providing of both qos+retain if specifying retain. Don't know if that's acceptable or not
@ben-willmore @brentru

This was what I ended up with in .h file lines 192-198:

  bool publish(const char *topic, const char *payload, uint8_t qos = 0);
  bool publish(const char *topic, const char *payload, uint8_t qos,
               bool retain);
  bool publish(const char *topic, uint8_t *payload, uint16_t bLen,
               uint8_t qos = 0);
  bool publish(const char *topic, uint8_t *payload, uint16_t bLen, 
               uint8_t qos, bool retain);

-Edit- Whoops, forgot I left the order changed, well you get the idea, by not specifying QOS in the second overloaded forms which include retain, the ambiguity goes away.

-Edit2- When I change the parameter order back, and leave QOS default specified, then everything breaks again, I guess due to the value for QOS being misinterpreted as a value suitable for retain (bool) in the wippersnapper example.

from adafruit_mqtt_library.

ben-willmore avatar ben-willmore commented on July 30, 2024

You're right -- it's a bit surprising that this is ambiguous but it does make sense. Unless I misunderstood your second edit, I don't see a better solution to this than moving retain to the end of the argument list and giving it a default value, as in https://github.com/ben-willmore/Adafruit_MQTT_Library/tree/retain-default-parameters .

from adafruit_mqtt_library.

tyeth avatar tyeth commented on July 30, 2024

Yeah i think that makes most sense looking at what you've done in that branch, but to be honest I suck at c/c++, more of a c# guy sorry and haven't got time to retest this moment.

from adafruit_mqtt_library.

brentru avatar brentru commented on July 30, 2024

@ben-willmore your commit in ben-willmore@83af73f makes sense and fixes this issue. Are you OK with checking out a PR? I can test WipperSnapper against that.

from adafruit_mqtt_library.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.