MBED NanoService Lighting Endpoint for NXP Ublox (cellular enabled)
Dependencies: C027_Support C12832 StatusReporter LM75B c027_radios endpoint_core endpoint_nsp nsp_resources mbed mbed-rtos
Definitions.h@7:cca3a2adb6b8, 2014-02-28 (annotated)
- Committer:
- ansond
- Date:
- Fri Feb 28 05:11:46 2014 +0000
- Revision:
- 7:cca3a2adb6b8
- Parent:
- 6:c780baa3b7f1
- Child:
- 9:c2a0b8f2d7f6
updates
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ansond | 0:dcced975fb52 | 1 | /* Copyright C2013 Doug Anson, MIT License |
ansond | 0:dcced975fb52 | 2 | * |
ansond | 0:dcced975fb52 | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
ansond | 0:dcced975fb52 | 4 | * and associated documentation files the "Software", to deal in the Software without restriction, |
ansond | 0:dcced975fb52 | 5 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
ansond | 0:dcced975fb52 | 6 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
ansond | 0:dcced975fb52 | 7 | * furnished to do so, subject to the following conditions: |
ansond | 0:dcced975fb52 | 8 | * |
ansond | 0:dcced975fb52 | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
ansond | 0:dcced975fb52 | 10 | * substantial portions of the Software. |
ansond | 0:dcced975fb52 | 11 | * |
ansond | 0:dcced975fb52 | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
ansond | 0:dcced975fb52 | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
ansond | 0:dcced975fb52 | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
ansond | 0:dcced975fb52 | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
ansond | 0:dcced975fb52 | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
ansond | 0:dcced975fb52 | 17 | */ |
ansond | 0:dcced975fb52 | 18 | |
ansond | 0:dcced975fb52 | 19 | #ifndef _DEFINITIONS_H_ |
ansond | 0:dcced975fb52 | 20 | #define _DEFINITIONS_H_ |
ansond | 0:dcced975fb52 | 21 | |
ansond | 0:dcced975fb52 | 22 | // platform |
ansond | 0:dcced975fb52 | 23 | #include "mbed.h" |
ansond | 0:dcced975fb52 | 24 | |
ansond | 0:dcced975fb52 | 25 | // Our Endpoint Version Annoucement |
ansond | 0:dcced975fb52 | 26 | #define ENDPOINT_VERSION_ANNOUNCE "\r\nMBED IMPACT(NSP) Endpoint v1.0" |
ansond | 0:dcced975fb52 | 27 | |
ansond | 0:dcced975fb52 | 28 | // Error Handler |
ansond | 5:9e795e139e45 | 29 | #define MAX_LOG_MESSAGE 768 // maximum size of a logging message |
ansond | 5:9e795e139e45 | 30 | |
ansond | 5:9e795e139e45 | 31 | // Resource Configuration |
ansond | 5:9e795e139e45 | 32 | #define RESOURCE_NAME_LEN 20 // Resource name max length |
ansond | 5:9e795e139e45 | 33 | #define RESOURCE_VALUE_LEN 20 // Resource value max length |
ansond | 5:9e795e139e45 | 34 | |
ansond | 5:9e795e139e45 | 35 | // MapEntry Name length |
ansond | 5:9e795e139e45 | 36 | #define MAX_NAME_LENGTH 20 |
ansond | 5:9e795e139e45 | 37 | |
ansond | 5:9e795e139e45 | 38 | // Number of Resources our Endpoint has |
ansond | 5:9e795e139e45 | 39 | #define NUM_RESOURCES 16 |
ansond | 5:9e795e139e45 | 40 | |
ansond | 5:9e795e139e45 | 41 | // IOC <--> Resource Mapping |
ansond | 5:9e795e139e45 | 42 | #define NUM_MAPPINGS NUM_RESOURCES // matches the number of resources |
ansond | 0:dcced975fb52 | 43 | |
ansond | 0:dcced975fb52 | 44 | // Light Configuration |
ansond | 0:dcced975fb52 | 45 | #define NUM_LIGHTS 1 // number of lights in this endpoint |
ansond | 0:dcced975fb52 | 46 | #define LIGHT_NAME "mbed-nsp-light-%d" // name of each light in this endpoint |
ansond | 0:dcced975fb52 | 47 | #define LIGHT_NAME_LEN 64 // buffer size for the light name |
ansond | 0:dcced975fb52 | 48 | #define LIGHT_ON_STATE "0" // initial state of each light in this endpoint |
ansond | 0:dcced975fb52 | 49 | #define LIGHT_DIM_STATE "25" // initial dimming state of each light in this endpoint |
ansond | 0:dcced975fb52 | 50 | #define NSP_NODE_TYPE "MBED NSP light node" // Node type |
ansond | 0:dcced975fb52 | 51 | #define NSP_NODE_LIFETIME "1200" // Node lifetime |
ansond | 0:dcced975fb52 | 52 | #define RD_UPDATE_PERIOD 60 // The number of seconds between NSP registration messages |
ansond | 0:dcced975fb52 | 53 | |
ansond | 4:2469fd2fba1c | 54 | // Endpoint GPS Coordinates |
ansond | 4:2469fd2fba1c | 55 | #define ENDPOINT_LOCATION "Oulo Finland" // Where this light/endpoint lives |
ansond | 7:cca3a2adb6b8 | 56 | #define ENDPOINT_GPS_COORDS "65.017210,25.492411" // work |
ansond | 7:cca3a2adb6b8 | 57 | //#define ENDPOINT_GPS_COORDS "65.020071,25.467880" // home |
ansond | 7:cca3a2adb6b8 | 58 | |
ansond | 7:cca3a2adb6b8 | 59 | // TEMP - until we get HTTPS with BasicAuth working in MBED... |
ansond | 7:cca3a2adb6b8 | 60 | //#define GW_IPADDRESS "192.168.1.191" // work |
ansond | 7:cca3a2adb6b8 | 61 | #define GW_IPADDRESS "10.1.0.27" // home |
ansond | 7:cca3a2adb6b8 | 62 | #define GW_REDIRECT_URL "http://%s:8888/NSP-IOC-Gateway/IOCRestAPI" |
ansond | 7:cca3a2adb6b8 | 63 | #define USE_GW_HTTP_REDIRECTOR true // true - make http calls to IOC via GW, false - make http calls directly to IOC |
ansond | 7:cca3a2adb6b8 | 64 | |
ansond | 7:cca3a2adb6b8 | 65 | // Keyword Definitions for MQTT packets |
ansond | 7:cca3a2adb6b8 | 66 | #define IOC_REQUEST_LOAD_ALL_VERB "load" |
ansond | 7:cca3a2adb6b8 | 67 | #define IOC_REQUEST_UPDATE_ALL_VERB "update" |
ansond | 7:cca3a2adb6b8 | 68 | #define IOC_ENDPOINT_VERB "Endpoint" |
ansond | 7:cca3a2adb6b8 | 69 | #define IOC_ENDPOINT_ALL_VERB "all" |
ansond | 7:cca3a2adb6b8 | 70 | #define IOC_CHANGE_VERB "Change" |
ansond | 7:cca3a2adb6b8 | 71 | #define IOC_REQUEST_VALUE_VERB "Get" |
ansond | 7:cca3a2adb6b8 | 72 | #define IOC_RESPONSE_VERB "response" |
ansond | 7:cca3a2adb6b8 | 73 | #define IOC_REPONSE_ID_KEY "id" |
ansond | 7:cca3a2adb6b8 | 74 | #define IOC_DATASOURCE_ID "198" |
ansond | 7:cca3a2adb6b8 | 75 | |
ansond | 7:cca3a2adb6b8 | 76 | // IOC REST Buffer Lengths |
ansond | 7:cca3a2adb6b8 | 77 | #define IOC_REST_URL_LEN 128 |
ansond | 7:cca3a2adb6b8 | 78 | #define IOC_RESULT_LEN 900 |
ansond | 7:cca3a2adb6b8 | 79 | #define IOC_PAYLOAD_LEN 900 |
ansond | 7:cca3a2adb6b8 | 80 | #define IOC_IOC_ID_LEN 16 |
ansond | 7:cca3a2adb6b8 | 81 | |
ansond | 7:cca3a2adb6b8 | 82 | // IOC REST URL for Load/Updates |
ansond | 7:cca3a2adb6b8 | 83 | #define IOC_USERNAME "anson" |
ansond | 7:cca3a2adb6b8 | 84 | #define IOC_PASSWORD "savetheplanet1" |
ansond | 7:cca3a2adb6b8 | 85 | #define IOC_HOST_NAME "iocweb.bcu.ac.uk" |
ansond | 7:cca3a2adb6b8 | 86 | #define IOC_REST_URL "https://%s/ibm/ioc/api/data-injection-service/datablocks/%s/dataitems%s" |
ansond | 7:cca3a2adb6b8 | 87 | #define IOC_RESPONSE_TEMPLATE "%s:{ENDPOINT=%s RESOURCE=%s VALUE=%s}:%s" |
ansond | 7:cca3a2adb6b8 | 88 | #define IOC_RESPONSE_OK "OK" |
ansond | 7:cca3a2adb6b8 | 89 | #define IOC_RESPONSE_FAILED "FAILED" |
ansond | 4:2469fd2fba1c | 90 | |
ansond | 0:dcced975fb52 | 91 | // Transport Configuration |
ansond | 7:cca3a2adb6b8 | 92 | #define NUM_TRANSPORTS 2 // Transports used |
ansond | 0:dcced975fb52 | 93 | #define NSP_TRANSPORT 0 // NSP Transport index |
ansond | 7:cca3a2adb6b8 | 94 | #define HTTP_TRANSPORT 1 // HTTP Transport index |
ansond | 0:dcced975fb52 | 95 | |
ansond | 7:cca3a2adb6b8 | 96 | // NSP Configuration |
ansond | 0:dcced975fb52 | 97 | #define NSP_ADDRESS "192.168.1.150" // Target NSP Service |
ansond | 0:dcced975fb52 | 98 | #define NSP_PORT 8080 // Target NSP Service Port Number |
ansond | 0:dcced975fb52 | 99 | |
ansond | 0:dcced975fb52 | 100 | // Main Loop |
ansond | 0:dcced975fb52 | 101 | #define MAIN_LOOP_SLEEP 100 // sleep time (ms) between main loop iterations |
ansond | 0:dcced975fb52 | 102 | |
ansond | 0:dcced975fb52 | 103 | // LED Blink Time |
ansond | 5:9e795e139e45 | 104 | #define BLINK_TIME 100 // LED blink times |
ansond | 0:dcced975fb52 | 105 | |
ansond | 6:c780baa3b7f1 | 106 | // Philips Light Support |
ansond | 6:c780baa3b7f1 | 107 | #define PL_ENABLE false // true - enable for endpoint light, false - disable |
ansond | 6:c780baa3b7f1 | 108 | #define PL_LIGHT_ID_DOUG 1 // Dougs Light |
ansond | 6:c780baa3b7f1 | 109 | #define PL_LIGHT_ID_BILL 2 // Bills Light |
ansond | 6:c780baa3b7f1 | 110 | #define PL_LIGHT_ID_KERRY 3 // Kerrys Light |
ansond | 6:c780baa3b7f1 | 111 | #define PL_LIGHT_ID PL_LIGHT_ID_DOUG // Default light |
ansond | 6:c780baa3b7f1 | 112 | #define PL_GW_ADDRESS "192.168.1.178" // Philips Gateway in IOT lab (Austin) |
ansond | 6:c780baa3b7f1 | 113 | #define PL_DEFAULT_STATE 1 // on |
ansond | 6:c780baa3b7f1 | 114 | #define PL_DEFAULT_DIM 11 // dim value |
ansond | 6:c780baa3b7f1 | 115 | #define PL_URL_BUFFER_LEN 128 |
ansond | 6:c780baa3b7f1 | 116 | #define PL_PAYLOAD_BUFFER_LEN 128 |
ansond | 6:c780baa3b7f1 | 117 | #define PL_RESPONSE_BUFFER_LEN 128 |
ansond | 6:c780baa3b7f1 | 118 | #define PL_URL_TEMPLATE "http://%s/api/newdeveloper/lights/%d/state" |
ansond | 6:c780baa3b7f1 | 119 | #define PL_ON_COMMAND_TEMPLATE "{\"on\":%s,\"sat\":211,\"bri\":%d,\"hue\":13122}" |
ansond | 6:c780baa3b7f1 | 120 | |
ansond | 0:dcced975fb52 | 121 | #endif // _DEFINITIONS_H |