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:
Tue Jul 01 20:59:35 2014 +0000
Revision:
45:974cd0fba897
Parent:
35:30b5f17896c6
Child:
46:32a7545dde45
updated external gateway

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 45:974cd0fba897 29 #ifdef CELLULAR_NETWORK
ansond 45:974cd0fba897 30 // Gateway REST API URL (external)
ansond 45:974cd0fba897 31 #define GW_REDIRECT_URL "http://%s:15479/NSP-IOC-Gateway/IOCRestAPI"
ansond 45:974cd0fba897 32 #else
ansond 3:ade23c97d256 33 // Gateway REST API URL
ansond 3:ade23c97d256 34 #define GW_REDIRECT_URL "http://%s:8888/NSP-IOC-Gateway/IOCRestAPI"
ansond 45:974cd0fba897 35 #endif
ansond 3:ade23c97d256 36
ansond 3:ade23c97d256 37 // Preference File Configuration
ansond 3:ade23c97d256 38 #define PREFERENCES_FILE "/local/mqtt.cfg" // preferences file for endpoint
ansond 3:ade23c97d256 39
ansond 8:17c29d3b967b 40 // Personality Name Configuration
ansond 8:17c29d3b967b 41 #ifdef LIGHT_PERSONALITY
ansond 22:afb208d1d79e 42 #define PERSONALITY_NAME "light-mqtt-%d" // name of each personality (i.e. light) in this endpoint
ansond 22:afb208d1d79e 43 #define PERSONALITY_TYPE LIGHT_TYPE_STRING // type of personality
ansond 22:afb208d1d79e 44 #define MQTT_ENDPOINT_TYPE "MBED MQTT Light Node" // mfg type
ansond 17:36a4ab911aaa 45 #endif
ansond 17:36a4ab911aaa 46 #ifdef COPCAR_PERSONALITY
ansond 22:afb208d1d79e 47 #define PERSONALITY_NAME "copcar-mqtt-%d" // name of each personality (i.e. copcar) in this endpoint
ansond 22:afb208d1d79e 48 #define PERSONALITY_TYPE "Cop Car" // type of personality
ansond 22:afb208d1d79e 49 #define MQTT_ENDPOINT_TYPE "MBED MQTT Cop Car" // mfg type
ansond 8:17c29d3b967b 50 #endif
ansond 3:ade23c97d256 51
ansond 3:ade23c97d256 52 // Keyword Definitions for MQTT packets
ansond 3:ade23c97d256 53 #define IOC_REQUEST_LOAD_ALL_VERB "load"
ansond 3:ade23c97d256 54 #define IOC_REQUEST_UPDATE_ALL_VERB "update"
ansond 3:ade23c97d256 55 #define IOC_ENDPOINT_VERB "Endpoint"
ansond 3:ade23c97d256 56 #define IOC_ENDPOINT_ALL_VERB "all"
ansond 3:ade23c97d256 57 #define IOC_CHANGE_VERB "Change"
ansond 3:ade23c97d256 58 #define IOC_REQUEST_VALUE_VERB "Get"
ansond 3:ade23c97d256 59 #define IOC_RESPONSE_VERB "response"
ansond 3:ade23c97d256 60 #define IOC_REPONSE_ID_KEY "id"
ansond 34:e81be933358d 61 #define IOC_DATASOURCE_ID "386"
ansond 3:ade23c97d256 62
ansond 35:30b5f17896c6 63 // remap the IOC Datasource ID if we are a copcar
ansond 35:30b5f17896c6 64 #ifdef COPCAR_PERSONALITY
ansond 35:30b5f17896c6 65 #undef IOC_DATASOURCE_ID
ansond 35:30b5f17896c6 66 #define IOC_DATASOURCE_ID "388"
ansond 35:30b5f17896c6 67 #endif
ansond 35:30b5f17896c6 68
ansond 3:ade23c97d256 69 // IOC REST Buffer Lengths
ansond 3:ade23c97d256 70 #define IOC_REST_URL_LEN 128
ansond 3:ade23c97d256 71 #define IOC_RESULT_LEN 1024
ansond 3:ade23c97d256 72 #define IOC_PAYLOAD_LEN 768
ansond 3:ade23c97d256 73 #define IOC_IOC_ID_LEN 16
ansond 3:ade23c97d256 74
ansond 3:ade23c97d256 75 // IOC REST URL for Load/Updates
ansond 3:ade23c97d256 76 #define IOC_USERNAME "anson"
ansond 3:ade23c97d256 77 #define IOC_PASSWORD "savetheplanet1"
ansond 3:ade23c97d256 78 #define IOC_HOST_NAME "iocweb.bcu.ac.uk" // IOC Web - iocweb.bcu.ac.uk
ansond 3:ade23c97d256 79 #define IOC_REST_URL "https://%s/ibm/ioc/api/data-injection-service/datablocks/%s/dataitems%s"
ansond 3:ade23c97d256 80 #define IOC_RESPONSE_TEMPLATE "%s:{ENDPOINT=%s RESOURCE=%s VALUE=%s}:%s"
ansond 3:ade23c97d256 81 #define IOC_RESPONSE_OK "OK"
ansond 3:ade23c97d256 82 #define IOC_RESPONSE_FAILED "FAILED"
ansond 3:ade23c97d256 83
ansond 3:ade23c97d256 84 // Transport Configuration
ansond 3:ade23c97d256 85 #define NUM_TRANSPORTS 2 // MQTT, HTTP
ansond 3:ade23c97d256 86 #define MQTT_TRANSPORT 0 // MQTT Transport index
ansond 3:ade23c97d256 87 #define HTTP_TRANSPORT 1 // HTTP Transport index
ansond 3:ade23c97d256 88
ansond 3:ade23c97d256 89 // Index for Transport to use for Update/Load
ansond 3:ade23c97d256 90 #define LOAD_TRANSPORT 1 // 0 - MQTT, 1 - HTTP
ansond 3:ade23c97d256 91
ansond 3:ade23c97d256 92 // largest MQTT message that PubSubClient will send
ansond 3:ade23c97d256 93 #define MAX_MQTT_MESSAGE_LENGTH 128
ansond 3:ade23c97d256 94
ansond 3:ade23c97d256 95 // MQTT connect information
ansond 3:ade23c97d256 96 #define MQTT_HOSTNAME "iocana.bcu.ac.uk" // IOC MQTT Broker Host - iocana.bcu.ac.uk
ansond 3:ade23c97d256 97 #define MQTT_HOSTPORT 1883 // IOC MQTT Broker Port
ansond 3:ade23c97d256 98 #define MQTT_ENDPOINT_ID "mbed%d%d" // IOC MQTT Endpoint ID template
ansond 3:ade23c97d256 99 #define MQTT_MAXID_VALUE 99 // IOC MQTT Endpoint ID maximum integer value
ansond 29:ac6390032cec 100 #define MQTT_ENDPOINT_IDLEN 20 // IOC MQTT Endpoint ID length (max)
ansond 3:ade23c97d256 101 #define MQTT_IOC_TOPIC "ARM/sensinode/control/%s" // IOC MQTT Topic
ansond 3:ade23c97d256 102 #define MQTT_IOC_ALL_TOPIC "ARM/sensinode/control/all" // IOC MQTT Topic (broadcast)
ansond 3:ade23c97d256 103 #define MQTT_PING_SEND_TOPIC "ARM/sensinode/ping" // IOC MQTT Ping Send Topic
ansond 3:ade23c97d256 104 #define MQTT_IOC_ALL_ENDPOINT "all" // must be the same as the last element of MATT_IOC_ANNOUNCE_TOPIC
ansond 3:ade23c97d256 105 #define MQTT_IOC_TOPIC_LEN 64 // max length for the topic string
ansond 3:ade23c97d256 106 #define MQTT_PAYLOAD_SEGMENT_LEN 64 // max length for a segment of the payload
ansond 3:ade23c97d256 107 #define MQTT_USERNAME "" // IOC MQTT Username
ansond 3:ade23c97d256 108 #define MQTT_PASSWORD "" // IOC MQTT Password
ansond 3:ade23c97d256 109 #define MQTT_PING_VERB_LEN 10 // Ping or Pong
ansond 20:ee03f10c074e 110 #define MQTT_PING_COUNTDOWN 3600 // Send ping to GW every 3600'th 250ms iteration (approx 15 minutes)
ansond 3:ade23c97d256 111 #define MQTT_MAX_COUNTER 32768 // largest Ping counter before reset back to 1
ansond 3:ade23c97d256 112
ansond 3:ade23c97d256 113 #endif // _MQTT_DEFINITIONS_H_