2016-08-30 54 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