Microchip® Advanced Software Framework

iot_cloud_demo/PubNub.c File Reference

PubNub Example.

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

#include <assert.h>
#include <string.h>
#include "PubNub.h"
#include "common/include/nm_common.h"

Functions

static int find_string_start (char const *buf, int len)
 
void handle_dns_found (char const *name, uint32_t hostip)
 
static void handle_start_connect (pubnub_t *pb)
 Handles start of a TCP(HTTP) connection. More...
 
void handle_tcpip (SOCKET sock, uint8_t u8Msg, void *pvMsg)
 
static void handle_tcpip_connect (SOCKET sock, uint8_t u8Msg, void *pvMsg)
 
static void handle_tcpip_recv (SOCKET sock, uint8_t u8Msg, void *pvMsg)
 
static void handle_transaction (pubnub_t *pb)
 
static int parse_subscribe_response (pubnub_t *p)
 
static pubnub_tpubnub_find_ctx (SOCKET sock, enum pubnub_state state)
 
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)
 
static bool split_array (char *buf)
 Split buf string containing a JSON array (with arbitrary contents) to multiple NUL-terminated C strings, in-place. More...
 
static bool valid_ctx_prt (pubnub_t const *pb)
 

Variables

static struct pubnub m_aCtx [PUBNUB_CTX_MAX]
 
struct sockaddr_in pubnub_origin_addr
 

static int find_string_start ( char const *  buf,
int  len 
)
static

References i.

Referenced by parse_subscribe_response().

void handle_dns_found ( char const *  name,
uint32_t  hostip 
)

Referenced by socket_resolve_cb().

void handle_tcpip ( SOCKET  sock,
uint8_t  u8Msg,
void *  pvMsg 
)
static void handle_tcpip_connect ( SOCKET  sock,
uint8_t  u8Msg,
void *  pvMsg 
)
static
static pubnub_t* pubnub_find_ctx ( SOCKET  sock,
enum pubnub_state  state 
)
static
char const* pubnub_get ( pubnub_t pb)

Referenced by main().

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.

Referenced by main().

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

Initialize the PubNub Client API.

Referenced by main().

bool pubnub_publish ( pubnub_t pb,
const char *  channel,
const char *  message 
)

Referenced by main().

bool pubnub_subscribe ( pubnub_t pb,
const char *  channel 
)

Referenced by main().

static bool split_array ( char *  buf)
static

Split buf string containing a JSON array (with arbitrary contents) to multiple NUL-terminated C strings, in-place.

References buf.

Referenced by parse_subscribe_response().

static bool valid_ctx_prt ( pubnub_t const *  pb)
static

struct sockaddr_in pubnub_origin_addr