pubnubparticle-photon

Pubnub library not compiling on Particle Photon


I am trying to publish a message using pubnub on the Particle Photon. The code snippet below comes straight out of the Pubnub example code.

The code will not compile, with the message from the compiler as follows:

PubNub/PubNub.h:87:47: error: expected class-name before '{' token
 class PubSubClient: public PubNub_BASE_CLIENT {
                                               ^

PubNub/PubNub.h: In constructor 'PubSubClient::PubSubClient()':

 PubNub/PubNub.h:23:28: error: class 'PubSubClient' does not have any field named 'WiFiClient'
 #define PubNub_BASE_CLIENT WiFiClient
                        ^

The code for this tiny project is as follows:

// This #include statement was automatically added by the Particle IDE.
#include "PubNub/PubNub.h"

char pubkey[] = "<key here>"; 
char subkey[] = "<key here>"; 
char channel[] = "Channel"; 

void setup() {

    Serial.begin(9600); 
    Particle.publish("Serial set up"); 
    PubNub.begin(pubkey, subkey); 

}

void loop() {

    TCPClient *client; 
    char msg[64] = "{\"photon\":\"on\"}"; 
    client = PubNub.publish(channel, msg); 
    client->stop(); 

    Delay (30000);
}

Has anyone had a similar problem, and if so, can you guide me as to how to fix this.

Thanks.


Solution

  • It looks like the library available in Build IDE was in an older version (0.0.1). Fixed, latest version (0.0.2) has been published.

    To update library in your app you need to remove the PubNub library from your app in Apps drawer:

    And then go to Libraries drawer, find PubNub library, click Include in App, select your app and confirm: