mqtt specific components for the impact mbed endpoint library

Dependents:   mbed_mqtt_endpoint_ublox_ethernet mbed_mqtt_endpoint_ublox_cellular mbed_mqtt_endpoint_nxp

Committer:
ansond
Date:
Mon Mar 31 21:03:09 2014 +0000
Revision:
17:36a4ab911aaa
Parent:
8:17c29d3b967b
Child:
20:ee03f10c074e
updates

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ansond 3:ade23c97d256 1 /* Copyright C2013 Doug Anson, MIT License
ansond 3:ade23c97d256 2 *
ansond 3:ade23c97d256 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
ansond 3:ade23c97d256 4 * and associated documentation files the "Software", to deal in the Software without restriction,
ansond 3:ade23c97d256 5 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
ansond 3:ade23c97d256 6 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
ansond 3:ade23c97d256 7 * furnished to do so, subject to the following conditions:
ansond 3:ade23c97d256 8 *
ansond 3:ade23c97d256 9 * The above copyright notice and this permission notice shall be included in all copies or
ansond 3:ade23c97d256 10 * substantial portions of the Software.
ansond 3:ade23c97d256 11 *
ansond 3:ade23c97d256 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
ansond 3:ade23c97d256 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
ansond 3:ade23c97d256 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
ansond 3:ade23c97d256 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
ansond 3:ade23c97d256 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
ansond 3:ade23c97d256 17 */
ansond 3:ade23c97d256 18
ansond 3:ade23c97d256 19 #ifndef _MQTT_DEFINITIONS_H_
ansond 3:ade23c97d256 20 #define _MQTT_DEFINITIONS_H_
ansond 3:ade23c97d256 21
ansond 3:ade23c97d256 22 // Our Endpoint Version Annoucement
ansond 8:17c29d3b967b 23 #define ENDPOINT_VERSION_ANNOUNCE "\r\nMBED MQTT Endpoint v1.0"
ansond 3:ade23c97d256 24
ansond 3:ade23c97d256 25 // Until we get HTTPS with BasicAuth working in MBED...
ansond 8:17c29d3b967b 26 #define GW_IPADDRESS "192.168.1.220" // gateway IP address (default)
ansond 8:17c29d3b967b 27 #define USE_GW_HTTP_REDIRECTOR true // true - make http calls to IOC via GW, false - make http calls directly to IOC
ansond 3:ade23c97d256 28
ansond 3:ade23c97d256 29 // Gateway REST API URL
ansond 3:ade23c97d256 30 #define GW_REDIRECT_URL "http://%s:8888/NSP-IOC-Gateway/IOCRestAPI"
ansond 3:ade23c97d256 31
ansond 3:ade23c97d256 32 // Preference File Configuration
ansond 3:ade23c97d256 33 #define PREFERENCES_FILE "/local/mqtt.cfg" // preferences file for endpoint
ansond 3:ade23c97d256 34
ansond 8:17c29d3b967b 35 // Personality Name Configuration
ansond 8:17c29d3b967b 36 #ifdef LIGHT_PERSONALITY
ansond 17:36a4ab911aaa 37 #define PERSONALITY_NAME "light-mqtt-%d" // name of each personality (i.e. light) in this endpoint
ansond 17:36a4ab911aaa 38 #define PERSONALITY_TYPE LIGHT_TYPE_STRING // type of personality
ansond 17:36a4ab911aaa 39 #endif
ansond 17:36a4ab911aaa 40 #ifdef COPCAR_PERSONALITY
ansond 17:36a4ab911aaa 41 #define PERSONALITY_NAME "copcar-mqtt-%d" // name of each personality (i.e. copcar) in this endpoint
ansond 17:36a4ab911aaa 42 #define PERSONALITY_TYPE "Cop Car" // type of personality
ansond 8:17c29d3b967b 43 #endif
ansond 3:ade23c97d256 44
ansond 3:ade23c97d256 45 // Keyword Definitions for MQTT packets
ansond 3:ade23c97d256 46 #define IOC_REQUEST_LOAD_ALL_VERB "load"
ansond 3:ade23c97d256 47 #define IOC_REQUEST_UPDATE_ALL_VERB "update"
ansond 3:ade23c97d256 48 #define IOC_ENDPOINT_VERB "Endpoint"
ansond 3:ade23c97d256 49 #define IOC_ENDPOINT_ALL_VERB "all"
ansond 3:ade23c97d256 50 #define IOC_CHANGE_VERB "Change"
ansond 3:ade23c97d256 51 #define IOC_REQUEST_VALUE_VERB "Get"
ansond 3:ade23c97d256 52 #define IOC_RESPONSE_VERB "response"
ansond 3:ade23c97d256 53 #define IOC_REPONSE_ID_KEY "id"
ansond 3:ade23c97d256 54 #define IOC_DATASOURCE_ID "229"
ansond 3:ade23c97d256 55
ansond 3:ade23c97d256 56 // IOC REST Buffer Lengths
ansond 3:ade23c97d256 57 #define IOC_REST_URL_LEN 128
ansond 3:ade23c97d256 58 #define IOC_RESULT_LEN 1024
ansond 3:ade23c97d256 59 #define IOC_PAYLOAD_LEN 768
ansond 3:ade23c97d256 60 #define IOC_IOC_ID_LEN 16
ansond 3:ade23c97d256 61
ansond 3:ade23c97d256 62 // IOC REST URL for Load/Updates
ansond 3:ade23c97d256 63 #define IOC_USERNAME "anson"
ansond 3:ade23c97d256 64 #define IOC_PASSWORD "savetheplanet1"
ansond 3:ade23c97d256 65 #define IOC_HOST_NAME "iocweb.bcu.ac.uk" // IOC Web - iocweb.bcu.ac.uk
ansond 3:ade23c97d256 66 #define IOC_REST_URL "https://%s/ibm/ioc/api/data-injection-service/datablocks/%s/dataitems%s"
ansond 3:ade23c97d256 67 #define IOC_RESPONSE_TEMPLATE "%s:{ENDPOINT=%s RESOURCE=%s VALUE=%s}:%s"
ansond 3:ade23c97d256 68 #define IOC_RESPONSE_OK "OK"
ansond 3:ade23c97d256 69 #define IOC_RESPONSE_FAILED "FAILED"
ansond 3:ade23c97d256 70
ansond 3:ade23c97d256 71 // Transport Configuration
ansond 3:ade23c97d256 72 #define NUM_TRANSPORTS 2 // MQTT, HTTP
ansond 3:ade23c97d256 73 #define MQTT_TRANSPORT 0 // MQTT Transport index
ansond 3:ade23c97d256 74 #define HTTP_TRANSPORT 1 // HTTP Transport index
ansond 3:ade23c97d256 75
ansond 3:ade23c97d256 76 // Index for Transport to use for Update/Load
ansond 3:ade23c97d256 77 #define LOAD_TRANSPORT 1 // 0 - MQTT, 1 - HTTP
ansond 3:ade23c97d256 78
ansond 3:ade23c97d256 79 // largest MQTT message that PubSubClient will send
ansond 3:ade23c97d256 80 #define MAX_MQTT_MESSAGE_LENGTH 128
ansond 3:ade23c97d256 81
ansond 3:ade23c97d256 82 // MQTT connect information
ansond 3:ade23c97d256 83 #define MQTT_HOSTNAME "iocana.bcu.ac.uk" // IOC MQTT Broker Host - iocana.bcu.ac.uk
ansond 3:ade23c97d256 84 #define MQTT_HOSTPORT 1883 // IOC MQTT Broker Port
ansond 3:ade23c97d256 85 #define MQTT_ENDPOINT_ID "mbed%d%d" // IOC MQTT Endpoint ID template
ansond 3:ade23c97d256 86 #define MQTT_MAXID_VALUE 99 // IOC MQTT Endpoint ID maximum integer value
ansond 3:ade23c97d256 87 #define MQTT_ENDPOINT_IDLEN 64 // IOC MQTT Endpoint ID length (max)
ansond 3:ade23c97d256 88 #define MQTT_IOC_TOPIC "ARM/sensinode/control/%s" // IOC MQTT Topic
ansond 3:ade23c97d256 89 #define MQTT_IOC_ALL_TOPIC "ARM/sensinode/control/all" // IOC MQTT Topic (broadcast)
ansond 3:ade23c97d256 90 #define MQTT_PING_SEND_TOPIC "ARM/sensinode/ping" // IOC MQTT Ping Send Topic
ansond 3:ade23c97d256 91 #define MQTT_IOC_ALL_ENDPOINT "all" // must be the same as the last element of MATT_IOC_ANNOUNCE_TOPIC
ansond 3:ade23c97d256 92 #define MQTT_IOC_TOPIC_LEN 64 // max length for the topic string
ansond 3:ade23c97d256 93 #define MQTT_PAYLOAD_SEGMENT_LEN 64 // max length for a segment of the payload
ansond 3:ade23c97d256 94 #define MQTT_USERNAME "" // IOC MQTT Username
ansond 3:ade23c97d256 95 #define MQTT_PASSWORD "" // IOC MQTT Password
ansond 3:ade23c97d256 96 #define MQTT_PING_VERB_LEN 10 // Ping or Pong
ansond 3:ade23c97d256 97 #define MQTT_PING_COUNTDOWN 1200 // Send ping to GW every 1200'th 250ms iterations (5 minutes)
ansond 3:ade23c97d256 98 #define MQTT_MAX_COUNTER 32768 // largest Ping counter before reset back to 1
ansond 3:ade23c97d256 99
ansond 3:ade23c97d256 100 #endif // _MQTT_DEFINITIONS_H_