【发布时间】:2016-08-30 17:16:08
【问题描述】:
我正在尝试使用 Particle Photon 上的 pubnub 发布消息。下面的代码 sn-p 直接来自 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);
}
有没有人遇到过类似的问题,如果有,你能指导我如何解决这个问题。
谢谢。
【问题讨论】:
-
详情请参阅github.com/pubnub/… - 如果有帮助请告诉我。