mbed project

Dependencies:   ESP8266NodeMCUInterface Pubnub_mbed2_sync mbed

Committer:
ECE4180
Date:
Tue Apr 11 20:39:27 2017 +0000
Revision:
1:694056dc14d9
Parent:
0:2730fbdae986
fixed compiler error;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ECE4180 0:2730fbdae986 1 /* -*- c-file-style:"stroustrup"; indent-tabs-mode: nil -*- */
ECE4180 0:2730fbdae986 2 #if !defined INC_PUBNUB_CONFIG
ECE4180 0:2730fbdae986 3 #define INC_PUBNUB_CONFIG
ECE4180 0:2730fbdae986 4
ECE4180 0:2730fbdae986 5
ECE4180 0:2730fbdae986 6 /* -- Next few definitions can be tweaked by the user, but with care -- */
ECE4180 0:2730fbdae986 7
ECE4180 0:2730fbdae986 8 /** Maximum number of PubNub contexts. It is used only if the
ECE4180 0:2730fbdae986 9 * contexts are statically allocated.
ECE4180 0:2730fbdae986 10 * A context is used to publish messages or subscribe to (get) them.
ECE4180 0:2730fbdae986 11 *
ECE4180 0:2730fbdae986 12 * Doesn't make much sense to have less than 1. :)
ECE4180 0:2730fbdae986 13 * OTOH, don't put too many, as each context takes (for our purposes)
ECE4180 0:2730fbdae986 14 * a significant amount of memory - app. 128 + @ref PUBNUB_BUF_MAXLEN +
ECE4180 0:2730fbdae986 15 * @ref PUBNUB_REPLY_MAXLEN bytes.
ECE4180 0:2730fbdae986 16 *
ECE4180 0:2730fbdae986 17 * A typical configuration may consist of a single pubnub context for
ECE4180 0:2730fbdae986 18 * channel subscription and another pubnub context that will periodically
ECE4180 0:2730fbdae986 19 * publish messages about device status (with timeout lower than message
ECE4180 0:2730fbdae986 20 * generation frequency).
ECE4180 0:2730fbdae986 21 *
ECE4180 0:2730fbdae986 22 * Another typical setup may have a single subscription context and
ECE4180 0:2730fbdae986 23 * maintain a pool of contexts for each publish call triggered by an
ECE4180 0:2730fbdae986 24 * external event (e.g. a button push).
ECE4180 0:2730fbdae986 25 *
ECE4180 0:2730fbdae986 26 * Of course, there is nothing wrong with having just one context, but
ECE4180 0:2730fbdae986 27 * you can't publish and subscribe at the same time on the same context.
ECE4180 0:2730fbdae986 28 * This isn't as bad as it sounds, but may be a source of headaches
ECE4180 0:2730fbdae986 29 * (lost messages, etc).
ECE4180 0:2730fbdae986 30 */
ECE4180 0:2730fbdae986 31 #define PUBNUB_CTX_MAX 2
ECE4180 0:2730fbdae986 32
ECE4180 0:2730fbdae986 33 /** Maximum length of the HTTP buffer. This is a major component of
ECE4180 0:2730fbdae986 34 * the memory size of the whole pubnub context, but it is also an
ECE4180 0:2730fbdae986 35 * upper bound on URL-encoded form of published message, so if you
ECE4180 0:2730fbdae986 36 * need to construct big messages, you may need to raise this. */
ECE4180 0:2730fbdae986 37 #define PUBNUB_BUF_MAXLEN 32000
ECE4180 0:2730fbdae986 38
ECE4180 0:2730fbdae986 39 /** Set to 0 to use a static buffer and then set its size via
ECE4180 0:2730fbdae986 40 #PUBNUB_REPLY_MAXLEN. Set to anything !=0 to use a dynamic
ECE4180 0:2730fbdae986 41 buffer, that is, dynamically try to allocate as much memory as
ECE4180 0:2730fbdae986 42 needed for the buffer.
ECE4180 0:2730fbdae986 43 */
ECE4180 0:2730fbdae986 44 #define PUBNUB_DYNAMIC_REPLY_BUFFER 1
ECE4180 0:2730fbdae986 45
ECE4180 0:2730fbdae986 46 #if !PUBNUB_DYNAMIC_REPLY_BUFFER
ECE4180 0:2730fbdae986 47
ECE4180 0:2730fbdae986 48 /** Maximum length of the HTTP reply when using a static buffer. The
ECE4180 0:2730fbdae986 49 * other major component of the memory size of the PubNub context,
ECE4180 0:2730fbdae986 50 * beside #PUBNUB_BUF_MAXLEN. Replies of API calls longer than this
ECE4180 0:2730fbdae986 51 * will be discarded and an error will be reported. Specifically, this
ECE4180 0:2730fbdae986 52 * may cause lost messages returned by subscribe if too many too large
ECE4180 0:2730fbdae986 53 * messages got queued on the Pubnub server. */
ECE4180 0:2730fbdae986 54 #define PUBNUB_REPLY_MAXLEN 32000
ECE4180 0:2730fbdae986 55
ECE4180 0:2730fbdae986 56 #endif
ECE4180 0:2730fbdae986 57
ECE4180 0:2730fbdae986 58 /** This is the URL of the Pubnub server. Change only for testing
ECE4180 0:2730fbdae986 59 purposes.
ECE4180 0:2730fbdae986 60 */
ECE4180 0:2730fbdae986 61 #define PUBNUB_ORIGIN "pubsub.pubnub.com"
ECE4180 0:2730fbdae986 62
ECE4180 0:2730fbdae986 63 /** Set to 0 to disable changing the origin from the default
ECE4180 0:2730fbdae986 64 #PUBNUB_ORIGIN. Set to anything != 0 to enable changing the
ECE4180 0:2730fbdae986 65 origin (per context).
ECE4180 0:2730fbdae986 66 */
ECE4180 0:2730fbdae986 67 #define PUBNUB_ORIGIN_SETTABLE 1
ECE4180 0:2730fbdae986 68
ECE4180 0:2730fbdae986 69 /** Duration of the transaction timeout set during context initialization,
ECE4180 0:2730fbdae986 70 in milliseconds. Can be changed later by the user.
ECE4180 0:2730fbdae986 71 */
ECE4180 0:2730fbdae986 72 #define PUBNUB_DEFAULT_TRANSACTION_TIMER 310000
ECE4180 0:2730fbdae986 73
ECE4180 0:2730fbdae986 74 #define PUBNUB_HAVE_MD5 0
ECE4180 0:2730fbdae986 75 #define PUBNUB_HAVE_SHA1 0
ECE4180 0:2730fbdae986 76
ECE4180 0:2730fbdae986 77
ECE4180 0:2730fbdae986 78 /** The size of the stack (in kilobytes) for the "polling" thread, when using
ECE4180 0:2730fbdae986 79 the callback interface. We don't need much, so, if you want to conserve
ECE4180 0:2730fbdae986 80 memory, you can try small values. It's hard to say what is the minumum,
ECE4180 0:2730fbdae986 81 as it depends on the OS functions we call, but, you probably
ECE4180 0:2730fbdae986 82 shouldn't try less than 64 KB.
ECE4180 0:2730fbdae986 83
ECE4180 0:2730fbdae986 84 Set to `0` to use the default stack size.
ECE4180 0:2730fbdae986 85 */
ECE4180 0:2730fbdae986 86 #define PUBNUB_CALLBACK_THREAD_STACK_SIZE_KB 0
ECE4180 0:2730fbdae986 87
ECE4180 0:2730fbdae986 88
ECE4180 0:2730fbdae986 89 /** If true (!=0), enable support for (HTTP/S) proxy */
ECE4180 0:2730fbdae986 90 #define PUBNUB_PROXY_API 0
ECE4180 0:2730fbdae986 91
ECE4180 0:2730fbdae986 92 /** The maximum length (in characters) of the host name of the proxy
ECE4180 0:2730fbdae986 93 that will be saved in the Pubnub context.
ECE4180 0:2730fbdae986 94 */
ECE4180 0:2730fbdae986 95 #define PUBNUB_MAX_PROXY_HOSTNAME_LENGTH 63
ECE4180 0:2730fbdae986 96
ECE4180 0:2730fbdae986 97 /** If true (!=0), enable support for message encryption/decryption */
ECE4180 0:2730fbdae986 98 #define PUBNUB_CRYPTO_API 0
ECE4180 0:2730fbdae986 99
ECE4180 0:2730fbdae986 100
ECE4180 0:2730fbdae986 101 #include <mbed.h>
ECE4180 0:2730fbdae986 102 extern Serial pc;
ECE4180 0:2730fbdae986 103 #define PUBNUB_LOG_PRINTF(...) pc.printf(__VA_ARGS__)
ECE4180 0:2730fbdae986 104
ECE4180 0:2730fbdae986 105
ECE4180 0:2730fbdae986 106 #endif /* !defined INC_PUBNUB_CONFIG */