Skip to content

Instantly share code, notes, and snippets.

Last active April 3, 2018 20:29
Show Gist options
  • Save banasrini/0fcfa02301f4e11c0f50 to your computer and use it in GitHub Desktop.
Save banasrini/0fcfa02301f4e11c0f50 to your computer and use it in GitHub Desktop.
#include <SPI.h>
#include <Ethernet.h>
#include "string.h"
#include "iotconnector.h"
// Some Ethernet shields have a MAC address printed on a sticker on the shield;
// fill in that address here, or choose your own at random:
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
char pubkey[] = "demo";
char subkey[] = "demo";
char channel[] = "iotchannel";
char uuid[] = "Arduino";
iotbridge arduino;
void initialize(){
Serial.println("Serial set up");
while (!Ethernet.begin(mac)) {
Serial.println("Ethernet setup error");
Serial.println("Ethernet set up");
void do_something(String value){
Serial.println("in the callback");
void setup()
arduino.init( pubkey, subkey, uuid);
Serial.println("PubNub set up");
void loop()
String returnmessage;
Serial.println("publishing a message");
arduino.send(channel,"\"Hey There\"");
Serial.println("waiting for a message");
returnmessage = arduino.connect(channel);
// callback function of sorts, to work with the received message
#include "PubNub.h"
#include <SPI.h>
#include <Ethernet.h>
class iotbridge{
const char *publish_key;
const char *subscribe_key;
const char *uuid;
const char *channel;
const char *message;
bool init(const char *publish_key, const char *subscribe_key, const char *uuid);
bool send(const char *channel, const char *message);
String connect(const char *channel);
bool iotbridge::init(const char *publish_key, const char *subscribe_key, const char *uuid){
bool iotbridge::send(const char *channel, const char *message){
EthernetClient *client;
client = PubNub.publish(channel,message);
return client;
String iotbridge::connect(const char *channel){
String message = "";
int i = 0;
PubSubClient *pclient = PubNub.subscribe(channel);
if (!pclient) {
return 0;
while (pclient->wait_for_data()) {
char c = pclient->read();
message += c;
return message;
Copy link

millesm commented Aug 29, 2016

same problem....

In file included from C:\Arduino\pub_nub_test\sketch_aug29a\sketch_aug29a.ino:4:0:

C:\Arduino\libraries\PubNub/iotconnector.h: In member function 'String iotbridge::connect(const char*)':

C:\Arduino\libraries\PubNub/iotconnector.h:39:10: error: converting to 'String' from initializer list would use explicit constructor 'String::String(int, unsigned char)'

return 0;


exit status 1

Error compiling.

no idea what it actually means but cannot compile code.

Copy link

mskoczen commented Apr 3, 2018

You are attempting to return an integer in a function with a return type of String.
It should compile if you change line 39 of iotconnector.h to return "";

NOTE: I have not looked at the rest of the code to verify that this will not cause other problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment