我想发布一条消息,使用粒子光子上的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 - 让我知道这是否有帮助。 –