Microchip® Advanced Software Framework

PubNub.h File Reference

PubNub Example.

Copyright (c) 2016-2018 Microchip Technology Inc. and its subsidiaries.

Data Structures

struct  pubnub
 

Macros

#define PUBNUB_BUF_MAXLEN   (256)
 
#define PUBNUB_CTX_MAX   (2)
 
#define PUBNUB_ORIGIN   "pubsub.pubnub.com"
 
#define PUBNUB_ORIGIN_PORT   (80)
 
#define PUBNUB_PRINTF(x)
 Use PUBNUB_ENABLE_DEBUG macro to enable/disable PubNub debug. More...
 
#define PUBNUB_REPLY_MAXLEN   (512)
 
#define PUBNUB_REQUEST   "GET %s HTTP/1.1\r\nHost: %s\r\nUser-Agent: PubNub-WINC1500\r\nConnection: Keep-Alive\r\n\r\n"
 

Typedefs

typedef struct pubnub pubnub_t
 

Enumerations

enum  pubnub_res {
  PNR_OK,
  PNR_TIMEOUT,
  PNR_IO_ERROR,
  PNR_HTTP_ERROR,
  PNR_FORMAT_ERROR,
  PNR_CANCELLED,
  PNR_STARTED,
  PNR_IN_PROGRESS,
  PNR_RX_BUFF_NOT_EMPTY,
  PNR_TX_BUFF_TOO_SMALL
}
 
enum  pubnub_state {
  PS_IDLE,
  PS_WAIT_DNS,
  PS_WAIT_CONNECT,
  PS_WAIT_SEND,
  PS_WAIT_RECV,
  PS_RECV
}
 
enum  pubnub_trans {
  PBTT_NONE,
  PBTT_SUBSCRIBE,
  PBTT_PUBLISH,
  PBTT_LEAVE
}
 

Functions

void handle_dns_found (const char *name, uint32_t hostip)
 
void handle_tcpip (SOCKET sock, uint8_t u8Msg, void *pvMsg)
 
char const * pubnub_get (pubnub_t *pb)
 
pubnub_tpubnub_get_ctx (uint8_t index)
 Return a context for the given index. More...
 
void pubnub_init (pubnub_t *pb, const char *publish_key, const char *subscribe_key)
 Initialize the PubNub Client API. More...
 
bool pubnub_publish (pubnub_t *pb, const char *channel, const char *message)
 
bool pubnub_subscribe (pubnub_t *pb, const char *channel)
 

#define PUBNUB_BUF_MAXLEN   (256)

Referenced by handle_transaction().

#define PUBNUB_CTX_MAX   (2)
#define PUBNUB_ORIGIN   "pubsub.pubnub.com"
#define PUBNUB_ORIGIN_PORT   (80)

Referenced by handle_start_connect().

#define PUBNUB_PRINTF (   x)

Use PUBNUB_ENABLE_DEBUG macro to enable/disable PubNub debug.

Referenced by handle_tcpip(), handle_tcpip_connect(), handle_tcpip_recv(), handle_transaction(), and pubnub_publish().

#define PUBNUB_REPLY_MAXLEN   (512)

Referenced by pubnub_subscribe().

#define PUBNUB_REQUEST   "GET %s HTTP/1.1\r\nHost: %s\r\nUser-Agent: PubNub-WINC1500\r\nConnection: Keep-Alive\r\n\r\n"

Referenced by handle_transaction().

typedef struct pubnub pubnub_t

enum pubnub_res
Enumerator
PNR_OK 

Success.

Transaction finished successfully.

PNR_TIMEOUT 

Time out before the request has completed.

PNR_IO_ERROR 

Communication error (network or HTTP response format).

PNR_HTTP_ERROR 

HTTP error.

PNR_FORMAT_ERROR 

Unexpected input in received JSON.

PNR_CANCELLED 

Request cancelled by user.

PNR_STARTED 

Transaction started.

Await the outcome via process message.

PNR_IN_PROGRESS 

Transaction (already) ongoing.

Can't start a new transaction.

PNR_RX_BUFF_NOT_EMPTY 

Receive buffer (from previous transaction) not read, new subscription not allowed.

PNR_TX_BUFF_TOO_SMALL 

The buffer is to small.

Increase PUBNUB_BUF_MAXLEN.

Enumerator
PS_IDLE 
PS_WAIT_DNS 
PS_WAIT_CONNECT 
PS_WAIT_SEND 
PS_WAIT_RECV 
PS_RECV 
Enumerator
PBTT_NONE 

No transaction at all.

PBTT_SUBSCRIBE 

Subscribe transaction.

PBTT_PUBLISH 

Publish transaction.

PBTT_LEAVE 

Leave (channel(s)) transaction.

void handle_dns_found ( const char *  name,
uint32_t  hostip 
)
char const* pubnub_get ( pubnub_t pb)
pubnub_t* pubnub_get_ctx ( uint8_t  index)

Return a context for the given index.

Contexts are statically allocated by the PubNub library and this is the only to get a pointer to one of them.

References m_aCtx, and PUBNUB_CTX_MAX.

Referenced by main().

void pubnub_init ( pubnub_t pb,
const char *  publish_key,
const char *  subscribe_key 
)