|
Post by Masondb on Mar 26, 2016 0:16:12 GMT
I am trying to upload the gateway_ethernet.ino to my arduino and I am getting this error. Gateway_Ethernet:28: error: 'callback' was not declared in this scope PubSubClient client(server, 1883, callback, ethClient); ^ exit status 1 'callback' was not declared in this scope Please help
|
|
|
Post by greginkansas on Mar 26, 2016 2:01:24 GMT
This is from version 2.2 gateway not sure what verson you have
PubSubClient mqttClient(mqtt_server, 1883, mqtt_subs, ethClient );
|
|
|
Post by jbird41 on Apr 5, 2016 23:37:13 GMT
If you look a few lines down, the call back function is defined, what I did was move that function up above the statement that you have highlighted and that should fix itt
|
|
|
Post by Uwe on Mar 26, 2017 19:38:28 GMT
I have had same problem. My sulution was to use Arduino 1.6.5 for compiling. Then everthing works fine
|
|
|
Post by papa on Mar 27, 2017 1:09:10 GMT
Welcome, Uwe, & thanks for sharing. Yes, that's one way to work around such an issue. The other one is to follow what is required by the Arduino IDE's later versions, the (apparently) more standard programming practice of putting a function before another part of the sketch uses the function. While cryptic, Arduino IDE error messages are helpful. "28: error: 'callback' was not declared" tells us the error is at (or maybe near) the sketch's line 28. It involves the term 'callback' because it was not declared, set up, properly before use. Below that the offending sketch line is displayed & under that a carat "^" points at (or maybe near) where the error occurs. The Arduino IDE error above is telling us that what is inside the single quotes (here 'callback') is not declared, not defined. The declaration may be missing from the whole sketch or was placed after where it is used. In some cases, we have slightly misspelled either the declaration or where it is to be used. IDE is telling us, "You want to use 'callback' here, but so far in effect, you have not told me about its traits sufficiently or timely enough. Put the declaration above line 28. Either move a declaration you put later or write a new one." jbird41's post above solved the error in the standard programming way. jbird41 found declaration of the callback function in the sketch's line 37 & moved it above line 28 where it was used. ---------------------------------------------- Saying more about the first post in this thread, it quotes an error from a line in a (outmoded?) gateway sketch offered by Eric Tsai, who wrote the inspiring Uber Home Automation Instructable & founded this forum. It must have been written on an earlier Arduino IDE that allowed functions to be declared at the end of a sketch. The Uber system used two Arduino's for the gateway. This forum has been primarily using computourist's Gateway (2.4 the latest version), available here. Unlike the Uber version, it uses only one Arduino & is part of a bidirectional communication system. Computourist's Gateway sketches have functions placed so the above error does not occur in current IDE versions. Again, visit, comment, share, & ask questions, any time (about the subject of this forum). We'll do our best to respond. If you are interested in DIY Home Automation, this forum may offer things to learn or a place to share what you know.
|
|