MBED MQTT Lighting Endpoint for NXP Ublox (Ethernet enabled)

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

Committer:
ansond
Date:
Thu Feb 27 22:07:45 2014 +0000
Revision:
21:d1ce325d1d32
Parent:
19:956b694f6542
Child:
22:f1002e5993c5
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 0:ae2a45502448 25 // Our Endpoint Version Annoucement
ansond 0:ae2a45502448 26 #define ENDPOINT_VERSION_ANNOUNCE "\r\nMBED IMPACT(MQTT) Endpoint v1.0"
ansond 0:ae2a45502448 27
ansond 13:25448d92c205 28 // Error Handler Log Message Length
ansond 21:d1ce325d1d32 29 #define MAX_LOG_MESSAGE 850 // maximum size of a logging message
ansond 0:ae2a45502448 30
ansond 0:ae2a45502448 31 // Light Configuration
ansond 15:e44d75d95b38 32 #define NUM_LIGHTS 1 // number of lights in this endpoint
ansond 15:e44d75d95b38 33 #define LIGHT_NAME "mbed-mqtt-light-%d" // name of each light in this endpoint
ansond 15:e44d75d95b38 34 #define LIGHT_NAME_LEN 20 // buffer size for the light name
ansond 15:e44d75d95b38 35 #define LIGHT_ON_STATE "0" // initial state of each light in this endpoint
ansond 15:e44d75d95b38 36 #define LIGHT_DIM_STATE "25" // initial dimming state of each light in this endpoint
ansond 0:ae2a45502448 37
ansond 9:ff877db53cfd 38 // Endpoint GPS Coordinates
ansond 15:e44d75d95b38 39 #define ENDPOINT_LOCATION "Oulo Finland" // Where this light/endpoint lives
ansond 15:e44d75d95b38 40 #define ENDPOINT_GPS_COORDS "65.017210,25.492411" // Where this light/endpoint lives
ansond 9:ff877db53cfd 41
ansond 13:25448d92c205 42 // Keyword Definitions for MQTT packets
ansond 13:25448d92c205 43 #define IOC_REQUEST_LOAD_ALL_VERB "load"
ansond 13:25448d92c205 44 #define IOC_REQUEST_UPDATE_ALL_VERB "update"
ansond 13:25448d92c205 45 #define IOC_ENDPOINT_VERB "Endpoint"
ansond 13:25448d92c205 46 #define IOC_ENDPOINT_ALL_VERB "all"
ansond 13:25448d92c205 47 #define IOC_CHANGE_VERB "Change"
ansond 13:25448d92c205 48 #define IOC_REQUEST_VALUE_VERB "Get"
ansond 13:25448d92c205 49 #define IOC_RESPONSE_VERB "response"
ansond 13:25448d92c205 50 #define IOC_REPONSE_ID_KEY "id"
ansond 13:25448d92c205 51 #define IOC_DATASOURCE_ID "198"
ansond 13:25448d92c205 52
ansond 13:25448d92c205 53 // IOC REST Buffer Lengths
ansond 13:25448d92c205 54 #define IOC_REST_URL_LEN 128
ansond 21:d1ce325d1d32 55 #define IOC_RESULT_LEN 850
ansond 21:d1ce325d1d32 56 #define IOC_PAYLOAD_LEN 850
ansond 13:25448d92c205 57 #define IOC_IOC_ID_LEN 16
ansond 13:25448d92c205 58
ansond 10:748fc7052e61 59 // IOC REST URL for Load/Updates
ansond 13:25448d92c205 60 #define IOC_USERNAME "anson"
ansond 13:25448d92c205 61 #define IOC_PASSWORD "savetheplanet1"
ansond 21:d1ce325d1d32 62 #define IOC_HOST_NAME "iocweb.bcu.ac.uk"
ansond 13:25448d92c205 63 #define IOC_REST_URL "https://%s/ibm/ioc/api/data-injection-service/datablocks/%s/dataitems%s"
ansond 13:25448d92c205 64 #define IOC_RESPONSE_TEMPLATE "%s:{ENDPOINT=%s RESOURCE=%s VALUE=%s}:%s"
ansond 13:25448d92c205 65 #define IOC_RESPONSE_OK "OK"
ansond 13:25448d92c205 66 #define IOC_RESPONSE_FAILED "FAILED"
ansond 10:748fc7052e61 67
ansond 21:d1ce325d1d32 68 // TEMP - until we get HTTPS with BasicAuth working in MBED...
ansond 21:d1ce325d1d32 69 #define GW_IPADDRESS "192.168.1.191"
ansond 21:d1ce325d1d32 70 #define GW_REDIRECT_URL "http://%s:8888/NSP-IOC-Gateway/IOCRestAPI"
ansond 21:d1ce325d1d32 71 #define USE_GW_HTTP_REDIRECTOR true // true - make http calls to IOC via GW, false - make http calls directly to IOC
ansond 21:d1ce325d1d32 72
ansond 0:ae2a45502448 73 // Resource Configuration
ansond 15:e44d75d95b38 74 #define RESOURCE_NAME_LEN 20 // Resource name max length
ansond 15:e44d75d95b38 75 #define RESOURCE_VALUE_LEN 20 // Resource value max length
ansond 15:e44d75d95b38 76
ansond 15:e44d75d95b38 77 // Number of Resources our Endpoint has
ansond 15:e44d75d95b38 78 #define NUM_RESOURCES 16
ansond 15:e44d75d95b38 79
ansond 15:e44d75d95b38 80 // MapEntry Name length
ansond 15:e44d75d95b38 81 #define MAX_NAME_LENGTH 20
ansond 15:e44d75d95b38 82
ansond 15:e44d75d95b38 83 // IOC <--> Resource Mapping
ansond 15:e44d75d95b38 84 #define NUM_MAPPINGS NUM_RESOURCES // matches the number of resources
ansond 0:ae2a45502448 85
ansond 0:ae2a45502448 86 // Transport Configuration
ansond 13:25448d92c205 87 #define NUM_TRANSPORTS 2 // MQTT, HTTP
ansond 13:25448d92c205 88 #define MQTT_TRANSPORT 0 // MQTT Transport index
ansond 13:25448d92c205 89 #define HTTP_TRANSPORT 1 // HTTP Transport index
ansond 0:ae2a45502448 90
ansond 9:ff877db53cfd 91 // Index for Transport to use for Update/Load
ansond 13:25448d92c205 92 #define LOAD_TRANSPORT 1 // 0 - MQTT, 1 - HTTP
ansond 9:ff877db53cfd 93
ansond 0:ae2a45502448 94 // MQTT connect information
ansond 13:25448d92c205 95 #define MQTT_HOSTNAME "iocana.bcu.ac.uk" // IOC MQTT Broker Host - iocana.bcu.ac.uk
ansond 13:25448d92c205 96 #define MQTT_HOSTPORT 1883 // IOC MQTT Broker Port
ansond 13:25448d92c205 97 #define MQTT_ENDPOINT_ID "mbed%d" // IOC MQTT Endpoint ID template
ansond 13:25448d92c205 98 #define MQTT_MAXID_VALUE 99 // IOC MQTT Endpoint ID maximum integer value
ansond 13:25448d92c205 99 #define MQTT_ENDPOINT_IDLEN 64 // IOC MQTT Endpoint ID length (max)
ansond 13:25448d92c205 100 #define MQTT_IOC_TOPIC "ARM/sensinode/control/%s" // IOC MQTT Topic
ansond 13:25448d92c205 101 #define MQTT_IOC_TOPIC_LEN 42 // max length for the topic string
ansond 13:25448d92c205 102 #define MQTT_USERNAME "" // IOC MQTT Username
ansond 13:25448d92c205 103 #define MQTT_PASSWORD "" // IOC MQTT Password
ansond 0:ae2a45502448 104
ansond 0:ae2a45502448 105 // Main Loop
ansond 13:25448d92c205 106 #define MAIN_LOOP_SLEEP 100 // sleep time (ms) between main loop iterations
ansond 0:ae2a45502448 107
ansond 0:ae2a45502448 108 // LED Blink Time
ansond 13:25448d92c205 109 #define BLINK_TIME 100 // LED blink times
ansond 0:ae2a45502448 110
ansond 0:ae2a45502448 111 #endif // _DEFINITIONS_H