我想發佈一條消息,使用粒子光子上的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);
}
有沒有人有類似的問題,如果是這樣,你能指導我如何解決這個問題。
謝謝。
查看詳情https://github.com/pubnub/arduino#wifi-shield-support-for-wifi-shield-101 - 讓我知道這是否有幫助。 –