MBED MQTT Lighting Endpoint for NXP Ublox (cellular enabled)

Dependencies:   C027_Support C12832 StatusReporter LM75B MQTT-ansond c027_radios endpoint_core endpoint_mqtt mbed-rtos mbed

Committer:
ansond
Date:
Wed Mar 26 20:01:43 2014 +0000
Revision:
173:b8f479524c92
Parent:
172:e996f6ce25f7
Child:
174:4da75aabdd67
updates

Who changed what in which revision?

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