MBED MQTT Lighting Endpoint for NXP LPC1768+AppBoard

Dependencies:   C12832_lcd EthernetInterface StatusReporter LM75B MQTT-ansond endpoint_core endpoint_mqtt mbed-rtos mbed

Committer:
ansond
Date:
Tue Mar 04 05:27:00 2014 +0000
Revision:
72:ffd155ec8b93
Parent:
69:090e16acccb7
Child:
75:c3bf90aca502
updates

Who changed what in which revision?

UserRevisionLine numberNew 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 61:5bafa4632a87 28 // Memory Debug Enable/Disable
ansond 72:ffd155ec8b93 29 #define ENABLE_MEMORY_DEBUG true // false - disable, true - enable
ansond 61:5bafa4632a87 30
ansond 0:ae2a45502448 31 // Our Endpoint Version Annoucement
ansond 0:ae2a45502448 32 #define ENDPOINT_VERSION_ANNOUNCE "\r\nMBED IMPACT(MQTT) Endpoint v1.0"
ansond 0:ae2a45502448 33
ansond 0:ae2a45502448 34 // Light Configuration
ansond 15:e44d75d95b38 35 #define LIGHT_NAME "mbed-mqtt-light-%d" // name of each light in this endpoint
ansond 0:ae2a45502448 36
ansond 59:80bb2471bd1c 37 // Philips Light Config
ansond 63:d89fb4ded2d6 38 #define PL_ENABLE false // true - enable for endpoint light, false - disable
ansond 59:80bb2471bd1c 39 #define PL_LIGHT_ID PL_LIGHT_ID_DOUG // Default light for Philips Light
ansond 59:80bb2471bd1c 40
ansond 37:c6c94f1b3e5d 41 // Endpoint GPS Coordinates/Location
ansond 15:e44d75d95b38 42 #define ENDPOINT_LOCATION "Oulo Finland" // Where this light/endpoint lives
ansond 23:793b2898522e 43 //#define ENDPOINT_GPS_COORDS "25.492411 65.017210" // work
ansond 23:793b2898522e 44 #define ENDPOINT_GPS_COORDS "25.467880 65.020071" // home
ansond 9:ff877db53cfd 45
ansond 13:25448d92c205 46 // Keyword Definitions for MQTT packets
ansond 13:25448d92c205 47 #define IOC_REQUEST_LOAD_ALL_VERB "load"
ansond 13:25448d92c205 48 #define IOC_REQUEST_UPDATE_ALL_VERB "update"
ansond 13:25448d92c205 49 #define IOC_ENDPOINT_VERB "Endpoint"
ansond 13:25448d92c205 50 #define IOC_ENDPOINT_ALL_VERB "all"
ansond 13:25448d92c205 51 #define IOC_CHANGE_VERB "Change"
ansond 13:25448d92c205 52 #define IOC_REQUEST_VALUE_VERB "Get"
ansond 13:25448d92c205 53 #define IOC_RESPONSE_VERB "response"
ansond 13:25448d92c205 54 #define IOC_REPONSE_ID_KEY "id"
ansond 30:5c670ec5d203 55 #define IOC_DATASOURCE_ID "199"
ansond 13:25448d92c205 56
ansond 13:25448d92c205 57 // IOC REST Buffer Lengths
ansond 13:25448d92c205 58 #define IOC_REST_URL_LEN 128
ansond 47:081874a5d049 59 #define IOC_RESULT_LEN 1024
ansond 48:d3663434128d 60 #define IOC_PAYLOAD_LEN 768
ansond 13:25448d92c205 61 #define IOC_IOC_ID_LEN 16
ansond 13:25448d92c205 62
ansond 10:748fc7052e61 63 // IOC REST URL for Load/Updates
ansond 13:25448d92c205 64 #define IOC_USERNAME "anson"
ansond 13:25448d92c205 65 #define IOC_PASSWORD "savetheplanet1"
ansond 21:d1ce325d1d32 66 #define IOC_HOST_NAME "iocweb.bcu.ac.uk"
ansond 13:25448d92c205 67 #define IOC_REST_URL "https://%s/ibm/ioc/api/data-injection-service/datablocks/%s/dataitems%s"
ansond 13:25448d92c205 68 #define IOC_RESPONSE_TEMPLATE "%s:{ENDPOINT=%s RESOURCE=%s VALUE=%s}:%s"
ansond 13:25448d92c205 69 #define IOC_RESPONSE_OK "OK"
ansond 13:25448d92c205 70 #define IOC_RESPONSE_FAILED "FAILED"
ansond 10:748fc7052e61 71
ansond 21:d1ce325d1d32 72 // TEMP - until we get HTTPS with BasicAuth working in MBED...
ansond 58:245e02d02f34 73 #define GW_IPADDRESS "192.168.1.191" // work
ansond 58:245e02d02f34 74 //#define GW_IPADDRESS "10.1.0.27" // home
ansond 21:d1ce325d1d32 75 #define GW_REDIRECT_URL "http://%s:8888/NSP-IOC-Gateway/IOCRestAPI"
ansond 21:d1ce325d1d32 76 #define USE_GW_HTTP_REDIRECTOR true // true - make http calls to IOC via GW, false - make http calls directly to IOC
ansond 21:d1ce325d1d32 77
ansond 0:ae2a45502448 78 // Transport Configuration
ansond 13:25448d92c205 79 #define NUM_TRANSPORTS 2 // MQTT, HTTP
ansond 13:25448d92c205 80 #define MQTT_TRANSPORT 0 // MQTT Transport index
ansond 13:25448d92c205 81 #define HTTP_TRANSPORT 1 // HTTP Transport index
ansond 0:ae2a45502448 82
ansond 9:ff877db53cfd 83 // Index for Transport to use for Update/Load
ansond 13:25448d92c205 84 #define LOAD_TRANSPORT 1 // 0 - MQTT, 1 - HTTP
ansond 9:ff877db53cfd 85
ansond 0:ae2a45502448 86 // MQTT connect information
ansond 13:25448d92c205 87 #define MQTT_HOSTNAME "iocana.bcu.ac.uk" // IOC MQTT Broker Host - iocana.bcu.ac.uk
ansond 13:25448d92c205 88 #define MQTT_HOSTPORT 1883 // IOC MQTT Broker Port
ansond 32:a7b3c285446c 89 #define MQTT_ENDPOINT_ID "mbed%d" // IOC MQTT Endpoint ID template
ansond 13:25448d92c205 90 #define MQTT_MAXID_VALUE 99 // IOC MQTT Endpoint ID maximum integer value
ansond 13:25448d92c205 91 #define MQTT_ENDPOINT_IDLEN 64 // IOC MQTT Endpoint ID length (max)
ansond 13:25448d92c205 92 #define MQTT_IOC_TOPIC "ARM/sensinode/control/%s" // IOC MQTT Topic
ansond 30:5c670ec5d203 93 #define MQTT_IOC_ANNOUNCE_TOPIC "ARM/sensinode/control/all" // IOC MQTT Topic (since MQTT on MBED cannot seem to handle wildcards)
ansond 48:d3663434128d 94 #define MQTT_IOC_ALL_ENDPOINT "all" // must be the same as the last element of MATT_IOC_ANNOUNCE_TOPIC
ansond 48:d3663434128d 95 #define MQTT_IOC_TOPIC_LEN 64 // max length for the topic string
ansond 69:090e16acccb7 96 #define MQTT_PAYLOAD_SEGMENT_LEN 64 // max length for a segment of the payload
ansond 13:25448d92c205 97 #define MQTT_USERNAME "" // IOC MQTT Username
ansond 13:25448d92c205 98 #define MQTT_PASSWORD "" // IOC MQTT Password
ansond 0:ae2a45502448 99
ansond 0:ae2a45502448 100 #endif // _DEFINITIONS_H