MBED MQTT Lighting Endpoint for NXP LPC1768+AppBoard
Dependencies: C12832_lcd EthernetInterface StatusReporter LM75B MQTT-ansond endpoint_core endpoint_mqtt mbed-rtos mbed
Definitions.h@141:0a09f2d03528, 2014-03-19 (annotated)
- Committer:
- ansond
- Date:
- Wed Mar 19 04:02:17 2014 +0000
- Revision:
- 141:0a09f2d03528
- Parent:
- 138:6159f1940b1d
- Child:
- 144:c7913812742a
updates
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ansond | 0:ae2a45502448 | 1 | /* Copyright C2013 Doug Anson, MIT License |
ansond | 0:ae2a45502448 | 2 | * |
ansond | 0:ae2a45502448 | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
ansond | 0:ae2a45502448 | 4 | * and associated documentation files the "Software", to deal in the Software without restriction, |
ansond | 0:ae2a45502448 | 5 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
ansond | 0:ae2a45502448 | 6 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
ansond | 0:ae2a45502448 | 7 | * furnished to do so, subject to the following conditions: |
ansond | 0:ae2a45502448 | 8 | * |
ansond | 0:ae2a45502448 | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
ansond | 0:ae2a45502448 | 10 | * substantial portions of the Software. |
ansond | 0:ae2a45502448 | 11 | * |
ansond | 0:ae2a45502448 | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
ansond | 0:ae2a45502448 | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
ansond | 0:ae2a45502448 | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
ansond | 0:ae2a45502448 | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
ansond | 0:ae2a45502448 | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
ansond | 0:ae2a45502448 | 17 | */ |
ansond | 0:ae2a45502448 | 18 | |
ansond | 0:ae2a45502448 | 19 | #ifndef _DEFINITIONS_H_ |
ansond | 0:ae2a45502448 | 20 | #define _DEFINITIONS_H_ |
ansond | 0:ae2a45502448 | 21 | |
ansond | 0:ae2a45502448 | 22 | // platform |
ansond | 0:ae2a45502448 | 23 | #include "mbed.h" |
ansond | 0:ae2a45502448 | 24 | |
ansond | 37:c6c94f1b3e5d | 25 | // include common definitions |
ansond | 37:c6c94f1b3e5d | 26 | #include "CommonDefinitions.h" |
ansond | 37:c6c94f1b3e5d | 27 | |
ansond | 101:eb5b14440b3d | 28 | // Until we get HTTPS with BasicAuth working in MBED... |
ansond | 137:6577dd23f6ed | 29 | //#define GW_IPADDRESS "192.168.1.191" // mac at work |
ansond | 137:6577dd23f6ed | 30 | #define GW_IPADDRESS "192.168.1.220" // registrydb work and home - vm |
ansond | 137:6577dd23f6ed | 31 | //#define GW_IPADDRESS "10.1.0.27" // mini |
ansond | 101:eb5b14440b3d | 32 | #define GW_REDIRECT_URL "http://%s:8888/NSP-IOC-Gateway/IOCRestAPI" |
ansond | 101:eb5b14440b3d | 33 | #define USE_GW_HTTP_REDIRECTOR true // true - make http calls to IOC via GW, false - make http calls directly to IOC |
ansond | 101:eb5b14440b3d | 34 | |
ansond | 61:5bafa4632a87 | 35 | // Memory Debug Enable/Disable |
ansond | 82:4c8ab5227b7b | 36 | // #define ENABLE_MEMORY_DEBUG true // false - disable, true - enable |
ansond | 61:5bafa4632a87 | 37 | |
ansond | 96:1f20bd8eb24e | 38 | // Hush Logging |
ansond | 96:1f20bd8eb24e | 39 | //#define HUSH_LOG true // false - logging output, true - no logging |
ansond | 96:1f20bd8eb24e | 40 | |
ansond | 96:1f20bd8eb24e | 41 | // Hush LED usage |
ansond | 96:1f20bd8eb24e | 42 | //define HUSH_LEDS true // false - enable LEDs, true - disable LEDs |
ansond | 96:1f20bd8eb24e | 43 | |
ansond | 0:ae2a45502448 | 44 | // Our Endpoint Version Annoucement |
ansond | 0:ae2a45502448 | 45 | #define ENDPOINT_VERSION_ANNOUNCE "\r\nMBED IMPACT(MQTT) Endpoint v1.0" |
ansond | 0:ae2a45502448 | 46 | |
ansond | 138:6159f1940b1d | 47 | // Preference File Configuration |
ansond | 138:6159f1940b1d | 48 | #define PREFERENCES_FILE "/local/mqtt.cfg" // preferences file for endpoint |
ansond | 138:6159f1940b1d | 49 | |
ansond | 79:67accc95965a | 50 | // our MAC address |
ansond | 136:ea8f3900bc13 | 51 | #define MAC_ADDRESS 0xa0,0x12,0xAB,0xE3,0x4F,0x56 |
ansond | 79:67accc95965a | 52 | |
ansond | 0:ae2a45502448 | 53 | // Light Configuration |
ansond | 75:c3bf90aca502 | 54 | #define LIGHT_NAME "light-mqtt-%d" // name of each light in this endpoint |
ansond | 135:662f96c35bfa | 55 | #define LIGHT_BLINK_WAIT_MS 1000 // time between blinks (ms) |
ansond | 141:0a09f2d03528 | 56 | #define LIGHT_NAME_INDEX 1 // start index for the ID of the light name |
ansond | 141:0a09f2d03528 | 57 | |
ansond | 0:ae2a45502448 | 58 | |
ansond | 59:80bb2471bd1c | 59 | // Philips Light Config |
ansond | 135:662f96c35bfa | 60 | #define PL_ENABLE false // true - enable for endpoint light, false - disable |
ansond | 141:0a09f2d03528 | 61 | #define PL_LIGHT_ID PL_LIGHT_ID_BILL // Default light for Philips Light |
ansond | 125:f47543f28298 | 62 | |
ansond | 125:f47543f28298 | 63 | // External LED Light Configuration |
ansond | 141:0a09f2d03528 | 64 | #define EXT_LED_ENABLE true // true - enable external LED endpoint light, false - disable |
ansond | 141:0a09f2d03528 | 65 | #define EXT_LED_PIN p21 // pin to use for external LED cathode |
ansond | 59:80bb2471bd1c | 66 | |
ansond | 37:c6c94f1b3e5d | 67 | // Endpoint GPS Coordinates/Location |
ansond | 84:a50f8d0ec197 | 68 | #define ENDPOINT_LOCATION "Las Vegas Country Club" // Where this light/endpoint lives |
ansond | 84:a50f8d0ec197 | 69 | #define ENDPOINT_GPS_COORDS "-115.143470 36.131916" // golf course -115.143470 36.131916 |
ansond | 9:ff877db53cfd | 70 | |
ansond | 85:9fdd9198001c | 71 | // MBED doesnt have a good notion of time - so we code it here |
ansond | 89:6e7dd4cba216 | 72 | #define ENDPOINT_STARTTIME "\"STARTDATETIME\":\"2014-03-09T22:03:06-07:00\"," |
ansond | 90:b71b8107bf4b | 73 | #define ENDPOINT_STOPTIME "\"ENDDATETIME\":\"2015-03-10T03:35:55-07:00\"," |
ansond | 89:6e7dd4cba216 | 74 | #define ENDPOINT_TIMEZONE "\"TIMEZONEOFFSET\":\"-07:00\"" |
ansond | 85:9fdd9198001c | 75 | |
ansond | 13:25448d92c205 | 76 | // Keyword Definitions for MQTT packets |
ansond | 13:25448d92c205 | 77 | #define IOC_REQUEST_LOAD_ALL_VERB "load" |
ansond | 13:25448d92c205 | 78 | #define IOC_REQUEST_UPDATE_ALL_VERB "update" |
ansond | 13:25448d92c205 | 79 | #define IOC_ENDPOINT_VERB "Endpoint" |
ansond | 13:25448d92c205 | 80 | #define IOC_ENDPOINT_ALL_VERB "all" |
ansond | 13:25448d92c205 | 81 | #define IOC_CHANGE_VERB "Change" |
ansond | 13:25448d92c205 | 82 | #define IOC_REQUEST_VALUE_VERB "Get" |
ansond | 13:25448d92c205 | 83 | #define IOC_RESPONSE_VERB "response" |
ansond | 13:25448d92c205 | 84 | #define IOC_REPONSE_ID_KEY "id" |
ansond | 102:36b8e2f5f416 | 85 | #define IOC_DATASOURCE_ID "229" |
ansond | 13:25448d92c205 | 86 | |
ansond | 13:25448d92c205 | 87 | // IOC REST Buffer Lengths |
ansond | 13:25448d92c205 | 88 | #define IOC_REST_URL_LEN 128 |
ansond | 47:081874a5d049 | 89 | #define IOC_RESULT_LEN 1024 |
ansond | 48:d3663434128d | 90 | #define IOC_PAYLOAD_LEN 768 |
ansond | 13:25448d92c205 | 91 | #define IOC_IOC_ID_LEN 16 |
ansond | 13:25448d92c205 | 92 | |
ansond | 10:748fc7052e61 | 93 | // IOC REST URL for Load/Updates |
ansond | 13:25448d92c205 | 94 | #define IOC_USERNAME "anson" |
ansond | 13:25448d92c205 | 95 | #define IOC_PASSWORD "savetheplanet1" |
ansond | 21:d1ce325d1d32 | 96 | #define IOC_HOST_NAME "iocweb.bcu.ac.uk" |
ansond | 13:25448d92c205 | 97 | #define IOC_REST_URL "https://%s/ibm/ioc/api/data-injection-service/datablocks/%s/dataitems%s" |
ansond | 13:25448d92c205 | 98 | #define IOC_RESPONSE_TEMPLATE "%s:{ENDPOINT=%s RESOURCE=%s VALUE=%s}:%s" |
ansond | 13:25448d92c205 | 99 | #define IOC_RESPONSE_OK "OK" |
ansond | 13:25448d92c205 | 100 | #define IOC_RESPONSE_FAILED "FAILED" |
ansond | 10:748fc7052e61 | 101 | |
ansond | 0:ae2a45502448 | 102 | // Transport Configuration |
ansond | 13:25448d92c205 | 103 | #define NUM_TRANSPORTS 2 // MQTT, HTTP |
ansond | 13:25448d92c205 | 104 | #define MQTT_TRANSPORT 0 // MQTT Transport index |
ansond | 13:25448d92c205 | 105 | #define HTTP_TRANSPORT 1 // HTTP Transport index |
ansond | 0:ae2a45502448 | 106 | |
ansond | 9:ff877db53cfd | 107 | // Index for Transport to use for Update/Load |
ansond | 13:25448d92c205 | 108 | #define LOAD_TRANSPORT 1 // 0 - MQTT, 1 - HTTP |
ansond | 9:ff877db53cfd | 109 | |
ansond | 129:c4fa24308e33 | 110 | // largest MQTT message that PubSubClient will send |
ansond | 134:e2dd9d85f991 | 111 | #define MAX_MQTT_MESSAGE_LENGTH 128 |
ansond | 129:c4fa24308e33 | 112 | |
ansond | 0:ae2a45502448 | 113 | // MQTT connect information |
ansond | 13:25448d92c205 | 114 | #define MQTT_HOSTNAME "iocana.bcu.ac.uk" // IOC MQTT Broker Host - iocana.bcu.ac.uk |
ansond | 13:25448d92c205 | 115 | #define MQTT_HOSTPORT 1883 // IOC MQTT Broker Port |
ansond | 32:a7b3c285446c | 116 | #define MQTT_ENDPOINT_ID "mbed%d" // IOC MQTT Endpoint ID template |
ansond | 13:25448d92c205 | 117 | #define MQTT_MAXID_VALUE 99 // IOC MQTT Endpoint ID maximum integer value |
ansond | 13:25448d92c205 | 118 | #define MQTT_ENDPOINT_IDLEN 64 // IOC MQTT Endpoint ID length (max) |
ansond | 13:25448d92c205 | 119 | #define MQTT_IOC_TOPIC "ARM/sensinode/control/%s" // IOC MQTT Topic |
ansond | 132:563a1ee99efc | 120 | #define MQTT_PING_SEND_TOPIC "ARM/sensinode/ping" // IOC MQTT Ping Send Topic |
ansond | 48:d3663434128d | 121 | #define MQTT_IOC_ALL_ENDPOINT "all" // must be the same as the last element of MATT_IOC_ANNOUNCE_TOPIC |
ansond | 48:d3663434128d | 122 | #define MQTT_IOC_TOPIC_LEN 64 // max length for the topic string |
ansond | 69:090e16acccb7 | 123 | #define MQTT_PAYLOAD_SEGMENT_LEN 64 // max length for a segment of the payload |
ansond | 13:25448d92c205 | 124 | #define MQTT_USERNAME "" // IOC MQTT Username |
ansond | 13:25448d92c205 | 125 | #define MQTT_PASSWORD "" // IOC MQTT Password |
ansond | 129:c4fa24308e33 | 126 | #define MQTT_PING_VERB_LEN 10 // Ping or Pong |
ansond | 132:563a1ee99efc | 127 | #define MQTT_PING_COUNTDOWN 1200 // Send ping to GW every 1200'th 250ms iterations (5 minutes) |
ansond | 129:c4fa24308e33 | 128 | #define MQTT_MAX_COUNTER 32768 // largest Ping counter before reset back to 1 |
ansond | 0:ae2a45502448 | 129 | |
ansond | 0:ae2a45502448 | 130 | #endif // _DEFINITIONS_H |