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