Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ESP8266WiFi.h>
- #define PubNub_BASE_CLIENT WiFiClient
- #define PUBNUB_DEFINE_STRSPN_AND_STRNCASECMP
- #include <PubNub.h>
- String pubkey = "pub-c-4a9cdbca-5688-4939-a852-f63cf6743980";
- String subkey = "sub-c-9b4067ae-1293-11e9-b4a6-026d6924b094";
- String pubchannel = "sec-c-NmFiYjliODYtMTc3Mi00YTMzLTg0OWMtMDgzYjE2ZGUwNzg5";
- void setup() {
- /* For debugging, set to speed of your choice */
- Serial.begin(9600);
- /* Start the Pubnub library by giving it a publish and subscribe
- keys */
- PubNub.begin(pubkey, subkey);
- }
- void loop() {
- /* Maintain DHCP lease. For other HW, you may need to do
- something else here, or maybe nothing at all. */
- /* 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:-
- node_mcu_test_code:44:46: error: 'subchannel' was not declared in this scope
- PubSubClient *sclient = PubNub.subscribe(subchannel);
- ^
- node_mcu_test_code:54:14: error: 'class PubSubClient' has no member named 'stop'
- sclient->stop();
- ^
- exit status 1
- no matching function for call to 'PubNub::begin(String&, String&)'
Add Comment
Please, Sign In to add comment