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