【问题标题】:Pubnub library not compiling on Particle PhotonPubnub 库未在 Particle Photon 上编译
【发布时间】: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);
}

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

谢谢。

【问题讨论】:

标签: pubnub particles photon


【解决方案1】:

看起来 Build IDE 中可用的库是旧版本 (0.0.1)。已修复,最新版本 (0.0.2) 已发布。

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

然后进入Libraries抽屉,找到PubNub库,点击Include in App,选择你的应用并确认:

【讨论】:

  • 很高兴听到!我想您可以将问题标记为已回答:)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-01-09
  • 1970-01-01
  • 1970-01-01
  • 2014-06-19
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多