I am new to using NodeMCU and IOT. I am testing the NodeMCU (ESP8266) so that I can connect with pubnub server. Have taken code from github but there is error saying
'mac was not declared in this scope'
and some other error too.
Can anyone tell whats the problem?
This code is from pubnub github page - https://github.com/pubnub/arduino
Code:-
#include <Ethernet.h>
#include <PubNub.h>
void setup() {
/* For debugging, set to speed of your choice */
Serial.begin(9600);
/* If you use some other HW, you need to do some other
initialization of it here... */
Ethernet.begin();
/* Start the Pubnub library by giving it a publish and subscribe
keys */
PubNub.begin(publisher key, subscriber key);
}
void loop() {
/* Maintain DHCP lease. For other HW, you may need to do
something else here, or maybe nothing at all. */
Ethernet.maintain();
/* Publish message. You could use `auto` here... */
PubNonSubClient *pclient = PubNub.publish(pubchannel, "\"message\"");
if (!pclient) return;
PublishCracker cheez;
cheez.read_and_parse(pclient);
/** You're mostly interested in `outcome()`, and,
if it's "failed", then `description()`.
*/
Serial.print("Outcome: "); Serial.print(cheez.outcome());
Serial.print(' '); Serial.println(cheez.to_str(cheez.outcome()));
Serial.print("description: "); Serial.println(cheez.description());
Serial.print("timestamp: "); Serial.println(cheez.timestamp());
Serial.print("state: "); Serial.print(cheez.state());
Serial.print(' '); Serial.println(cheez.to_str(cheez.state()));
pclient->stop();
/* Wait for news. */
PubSubClient *sclient = PubNub.subscribe(subchannel);
if (!sclient) return; // error
String msg;
SubscribeCracker ritz(sclient);
while (!ritz.finished()) {
ritz.get(msg);
if (msg.length() > 0) {
Serial.print("Received: "); Serial.println(msg);
}
}
sclient->stop();
delay(1000);
}
error :-
sketch_jan17a:28:47: error: 'pubchannel' was not declared in this scope
PubNonSubClient *pclient = PubNub.publish(pubchannel, "\"message\"");
^
sketch_jan17a:44:46: error: 'subchannel' was not declared in this scope
PubSubClient *sclient = PubNub.subscribe(subchannel);
^
Multiple libraries were found for "Ethernet.h"
Used: C:\Users\sultan\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0-beta2\libraries\Ethernet
Not used: C:\Program Files (x86)\Arduino\libraries\Ethernet
exit status 1
'mac' was not declared in this scope