MBED NanoService Lighting Endpoint for NXP Ublox (Ethernet enabled)

Dependencies:   C027 C12832 EthernetInterface StatusReporter LM75B endpoint_core endpoint_nsp mbed-rtos mbed nsp_resources

Definitions.h

Committer:
ansond
Date:
2014-02-28
Revision:
16:2b016c0f4341
Parent:
15:04b77b0952ea
Child:
19:a1fb67efb302

File content as of revision 16:2b016c0f4341:

/* Copyright C2013 Doug Anson, MIT License
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
 * and associated documentation files the "Software", to deal in the Software without restriction,
 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all copies or
 * substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
 
#ifndef _DEFINITIONS_H_
#define _DEFINITIONS_H_

// platform
#include "mbed.h"

// Our Endpoint Version Annoucement
#define ENDPOINT_VERSION_ANNOUNCE "\r\nMBED IMPACT(NSP) Endpoint v1.0"

// Error Handler
#define MAX_LOG_MESSAGE     768                    // maximum size of a logging message

// Resource Configuration
#define RESOURCE_NAME_LEN   20                     // Resource name max length
#define RESOURCE_VALUE_LEN  20                     // Resource value max length

// MapEntry Name length
#define MAX_NAME_LENGTH     20

// Number of Resources our Endpoint has
#define NUM_RESOURCES       16

// IOC <--> Resource Mapping
#define NUM_MAPPINGS        NUM_RESOURCES          // matches the number of resources

// Light Configuration
#define NUM_LIGHTS          1                      // number of lights in this endpoint
#define LIGHT_NAME          "mbed-nsp-light-%d"    // name of each light in this endpoint
#define LIGHT_NAME_LEN      64                     // buffer size for the light name
#define LIGHT_ON_STATE      "0"                    // initial state of each light in this endpoint
#define LIGHT_DIM_STATE     "25"                   // initial dimming state of each light in this endpoint
#define NSP_NODE_TYPE       "MBED NSP light node"  // Node type
#define NSP_NODE_LIFETIME   "1200"                 // Node lifetime
#define RD_UPDATE_PERIOD    60                     // The number of seconds between NSP registration messages

// Endpoint GPS Coordinates
#define ENDPOINT_LOCATION   "Oulo Finland"         // Where this light/endpoint lives
#define ENDPOINT_GPS_COORDS "65.017210, 25.492411"  // work
//#define ENDPOINT_GPS_COORDS "65.020071, 25.467880"  // home

// TEMP - until we get HTTPS with BasicAuth working in MBED...
#define GW_IPADDRESS                "192.168.1.191"     // work
//#define GW_IPADDRESS                "10.1.0.27"         // home
#define GW_REDIRECT_URL             "http://%s:8888/NSP-IOC-Gateway/IOCRestAPI"
#define USE_GW_HTTP_REDIRECTOR      true                            // true - make http calls to IOC via GW, false - make http calls directly to IOC

// Keyword Definitions for MQTT packets
#define IOC_REQUEST_LOAD_ALL_VERB   "load"
#define IOC_REQUEST_UPDATE_ALL_VERB "update"
#define IOC_ENDPOINT_VERB           "Endpoint"
#define IOC_ENDPOINT_ALL_VERB       "all"
#define IOC_CHANGE_VERB             "Change"
#define IOC_REQUEST_VALUE_VERB      "Get"
#define IOC_RESPONSE_VERB           "response"
#define IOC_REPONSE_ID_KEY          "id"
#define IOC_DATASOURCE_ID           "198"

// IOC REST Buffer Lengths
#define IOC_REST_URL_LEN            128
#define IOC_RESULT_LEN              900
#define IOC_PAYLOAD_LEN             900
#define IOC_IOC_ID_LEN              16

// IOC REST URL for Load/Updates
#define IOC_USERNAME                "anson"
#define IOC_PASSWORD                "savetheplanet1"
#define IOC_HOST_NAME               "iocweb.bcu.ac.uk"
#define IOC_REST_URL                "https://%s/ibm/ioc/api/data-injection-service/datablocks/%s/dataitems%s"
#define IOC_RESPONSE_TEMPLATE       "%s:{ENDPOINT=%s RESOURCE=%s VALUE=%s}:%s"
#define IOC_RESPONSE_OK             "OK"
#define IOC_RESPONSE_FAILED         "FAILED"

// Transport Configuration
#define NUM_TRANSPORTS      2                      // Transports used
#define NSP_TRANSPORT       0                      // NSP Transport index
#define HTTP_TRANSPORT      1                      // HTTP Transport index

// NSP Configuration
#define NSP_ADDRESS         "192.168.1.150"        // Target NSP Service - work
//#define NSP_ADDRESS         "10.1.0.83"            // Target NSP Service - home
#define NSP_PORT            8080                   // Target NSP Service Port Number

// Main Loop
#define MAIN_LOOP_SLEEP     100                    // sleep time (ms) between main loop iterations

// LED Blink Time
#define BLINK_TIME          100                    // LED blink times

// Philips Light Support
#define PL_ENABLE                   false                           // true - enable for endpoint light, false - disable
#define PL_LIGHT_ID_DOUG            1                               // Dougs Light
#define PL_LIGHT_ID_BILL            2                               // Bills Light
#define PL_LIGHT_ID_KERRY           3                               // Kerrys Light
#define PL_LIGHT_ID                 PL_LIGHT_ID_DOUG                // Default light
#define PL_GW_ADDRESS               "192.168.1.178"                 // Philips Gateway in IOT lab (Austin)
#define PL_DEFAULT_STATE            1                               // on
#define PL_DEFAULT_DIM              11                              // dim value
#define PL_URL_BUFFER_LEN           128
#define PL_PAYLOAD_BUFFER_LEN       128
#define PL_RESPONSE_BUFFER_LEN      128
#define PL_URL_TEMPLATE             "http://%s/api/newdeveloper/lights/%d/state"  
#define PL_ON_COMMAND_TEMPLATE      "{\"on\":%s,\"sat\":211,\"bri\":%d,\"hue\":13122}"

#endif // _DEFINITIONS_H