2016-08-30 55 views
1

我想发布一条消息,使用粒子光子上的pubnub。下面的代码片段直接来自Pubnub示例代码。Pubnub库没有编译粒子光子

的代码将无法编译,该消息从编译如下:

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 
         ^

对于这个小项目的代码如下:

// 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); 
} 

有没有人有类似的问题,如果是这样,你能指导我如何解决这个问题。

谢谢。

+0

查看详情https://github.com/pubnub/arduino#wifi-shield-support-for-wifi-shield-101 - 让我知道这是否有帮助。 –

回答

3

它看起来像Build IDE中可用的库是旧版本(0.0.1)。固定,最新版本(0.0.2)已经发布。

要将您的应用更新库,你需要从你的应用程序中删除PubNub库应用抽屉:

然后去抽屉,找到PubNub库中,单击包含在App中,选择您的应用并确认:

+0

此修复程序解决了问题。非常感谢。 – Grenello

+0

好听!我想你可以将问题标记为已回答:) – suda