Sample program for using Pubnub on AT&T IoT Starter Kit (which has the WNC modem)

Dependencies:   Pubnub_mbed2_sync WNCInterface mbed-rtos mbed

Fork of WNCInterface_M2XMQTTdemo by Avnet

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers pubnub_config.h Source File

pubnub_config.h

00001 /* -*- c-file-style:"stroustrup"; indent-tabs-mode: nil -*- */
00002 #if !defined INC_PUBNUB_CONFIG
00003 #define      INC_PUBNUB_CONFIG
00004 
00005 
00006 /* -- Next few definitions can be tweaked by the user, but with care -- */
00007 
00008 /** Maximum number of PubNub contexts. It is used only if the
00009  * contexts are statically allocated.
00010  * A context is used to publish messages or subscribe to (get) them.
00011  *
00012  * Doesn't make much sense to have less than 1. :)
00013  * OTOH, don't put too many, as each context takes (for our purposes)
00014  * a significant amount of memory - app. 128 + @ref PUBNUB_BUF_MAXLEN +
00015  * @ref PUBNUB_REPLY_MAXLEN bytes.
00016  *
00017  * A typical configuration may consist of a single pubnub context for
00018  * channel subscription and another pubnub context that will periodically
00019  * publish messages about device status (with timeout lower than message
00020  * generation frequency).
00021  *
00022  * Another typical setup may have a single subscription context and
00023  * maintain a pool of contexts for each publish call triggered by an
00024  * external event (e.g. a button push).
00025  *
00026  * Of course, there is nothing wrong with having just one context, but
00027  * you can't publish and subscribe at the same time on the same context.
00028  * This isn't as bad as it sounds, but may be a source of headaches
00029  * (lost messages, etc).
00030  */
00031 #define PUBNUB_CTX_MAX 2
00032 
00033 /** Maximum length of the HTTP buffer. This is a major component of
00034  * the memory size of the whole pubnub context, but it is also an
00035  * upper bound on URL-encoded form of published message, so if you
00036  * need to construct big messages, you may need to raise this.  */
00037 #define PUBNUB_BUF_MAXLEN 32000
00038 
00039 /** Set to 0 to use a static buffer and then set its size via
00040     #PUBNUB_REPLY_MAXLEN.  Set to anything !=0 to use a dynamic
00041     buffer, that is, dynamically try to allocate as much memory as
00042     needed for the buffer.
00043  */
00044 #define PUBNUB_DYNAMIC_REPLY_BUFFER 1
00045 
00046 #if !PUBNUB_DYNAMIC_REPLY_BUFFER
00047 
00048 /** Maximum length of the HTTP reply when using a static buffer. The
00049  * other major component of the memory size of the PubNub context,
00050  * beside #PUBNUB_BUF_MAXLEN.  Replies of API calls longer than this
00051  * will be discarded and an error will be reported. Specifically, this
00052  * may cause lost messages returned by subscribe if too many too large
00053  * messages got queued on the Pubnub server. */
00054 #define PUBNUB_REPLY_MAXLEN 32000
00055 
00056 #endif
00057 
00058 /** This is the URL of the Pubnub server. Change only for testing
00059     purposes.
00060 */
00061 #define PUBNUB_ORIGIN  "pubsub.pubnub.com"
00062 
00063 /** Set to 0 to disable changing the origin from the default
00064     #PUBNUB_ORIGIN.  Set to anything != 0 to enable changing the
00065     origin (per context).
00066  */
00067 #define PUBNUB_ORIGIN_SETTABLE 1
00068 
00069 /** Duration of the transaction timeout set during context initialization,
00070     in milliseconds. Can be changed later by the user.
00071     */
00072 #define PUBNUB_DEFAULT_TRANSACTION_TIMER    310000
00073 
00074 #define PUBNUB_HAVE_MD5 0
00075 #define PUBNUB_HAVE_SHA1 0
00076 
00077 
00078 /** The size of the stack (in kilobytes) for the "polling" thread, when using 
00079     the callback interface. We don't need much, so, if you want to conserve 
00080     memory, you can try small values. It's hard to say what is the minumum, 
00081     as it depends on the OS functions we call, but, you probably 
00082     shouldn't try less than 64 KB.
00083     
00084     Set to `0` to use the default stack size.
00085     */
00086 #define PUBNUB_CALLBACK_THREAD_STACK_SIZE_KB 0
00087 
00088 
00089 /** If true (!=0), enable support for (HTTP/S) proxy */
00090 #define PUBNUB_PROXY_API 0
00091 
00092 /** The maximum length (in characters) of the host name of the proxy
00093     that will be saved in the Pubnub context.
00094 */
00095 #define PUBNUB_MAX_PROXY_HOSTNAME_LENGTH 63
00096 
00097 /** If true (!=0), enable support for message encryption/decryption */
00098 #define PUBNUB_CRYPTO_API 0
00099 
00100 
00101 #include <MODSERIAL.h>
00102 extern MODSERIAL pc;
00103 #define PUBNUB_LOG_PRINTF(...) pc.printf(__VA_ARGS__)
00104     
00105 
00106 #endif /* !defined INC_PUBNUB_CONFIG */