Open YushaBinArif opened 6 years ago
Can you include your sketch please?
Yes here it is
/// sketch
int payload = -1; P2PMQTT mqtt(true); // add parameter true for debugging void setup() { // use the serial port to monitor that things work Serial.begin(9600); Serial.println("ready"); mqtt.connect(0,60000); // add 1min timeout
// initiate the communication to the phone
mqtt.begin("Basic Robot");
}
// to store the data
void loop() {
// get a P2PMQTT package and extract the type
int type = mqtt.getType(mqtt.buffer);
// depending on the package type do different things
switch(type) {
case CONNECT:
Serial.println("connected");
break;
case PUBLISH:
payload = mqtt.getPayload(mqtt.buffer, type)[0];
Serial.print("command: ");
Serial.println(payload);
break;
default:
// do nothing
break;
}
}
I first unzipped the files in "libraries" directory where all the default libraries of arduino are present, then wrote the above code.
Arduino: 1.8.5 (Windows 10), Board: "Arduino/Genuino Uno"
Wrox_AOA_c8p1_Basic_Robot:52: error: 'P2PMQTT' does not name a type
P2PMQTT mqtt(true); // add parameter true for debugging
^
E:\arduino-1.8.5\libraries\AOA_code\Wrox_AOA_c8p1_Basic_Robot\Wrox_AOA_c8p1_Basic_Robot.ino: In function 'void setup()':
Wrox_AOA_c8p1_Basic_Robot:60: error: 'mqtt' was not declared in this scope
mqtt.begin("Basic Robot");
^
E:\arduino-1.8.5\libraries\AOA_code\Wrox_AOA_c8p1_Basic_Robot\Wrox_AOA_c8p1_Basic_Robot.ino: In function 'void loop()':
Wrox_AOA_c8p1_Basic_Robot:70: error: 'mqtt' was not declared in this scope
int type = mqtt.getType(mqtt.buffer);
Wrox_AOA_c8p1_Basic_Robot:75: error: 'CONNECT' was not declared in this scope
Wrox_AOA_c8p1_Basic_Robot:79: error: 'PUBLISH' was not declared in this scope
exit status 1 'P2PMQTT' does not name a type
This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences.
/// These are the errors i am having while importing P2PMQTT.h in my arduino code