Core Base Classes for the Light Endpoints

Dependencies:   BufferedSerial

Dependents:   mbed_mqtt_endpoint_ublox_ethernet mbed_mqtt_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_ethernet ... more

Committer:
ansond
Date:
Thu Mar 27 02:58:30 2014 +0000
Revision:
133:667409048c68
Parent:
132:46e8c66129e4
Child:
134:58e7537a8c5f
updates

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ansond 38:825f8e834e77 1 /* Copyright C2013 Doug Anson, MIT License
ansond 38:825f8e834e77 2 *
ansond 38:825f8e834e77 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
ansond 38:825f8e834e77 4 * and associated documentation files the "Software", to deal in the Software without restriction,
ansond 38:825f8e834e77 5 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
ansond 38:825f8e834e77 6 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
ansond 38:825f8e834e77 7 * furnished to do so, subject to the following conditions:
ansond 38:825f8e834e77 8 *
ansond 38:825f8e834e77 9 * The above copyright notice and this permission notice shall be included in all copies or
ansond 38:825f8e834e77 10 * substantial portions of the Software.
ansond 38:825f8e834e77 11 *
ansond 38:825f8e834e77 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
ansond 38:825f8e834e77 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
ansond 38:825f8e834e77 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
ansond 38:825f8e834e77 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
ansond 38:825f8e834e77 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
ansond 38:825f8e834e77 17 */
ansond 38:825f8e834e77 18
ansond 38:825f8e834e77 19 #ifndef _COMMON_DEFINITIONS_H_
ansond 38:825f8e834e77 20 #define _COMMON_DEFINITIONS_H_
ansond 38:825f8e834e77 21
ansond 38:825f8e834e77 22 // Error Handler Log Message Length
ansond 50:daebff684b04 23 #define MAX_LOG_MESSAGE 900 // maximum size of a logging message
ansond 53:a009aee720fe 24 #define TEMP_BUFFER_LEN 128 // working/temp buffer length
ansond 38:825f8e834e77 25
ansond 38:825f8e834e77 26 // Resource Configuration
ansond 93:ac4a8d3c2a4f 27 #define RESOURCE_NAME_LEN 25 // Resource name max length
ansond 93:ac4a8d3c2a4f 28 #define RESOURCE_VALUE_LEN 33 // Resource value max length
ansond 38:825f8e834e77 29
ansond 38:825f8e834e77 30 // Number of Resources our Endpoint has
ansond 93:ac4a8d3c2a4f 31 #define NUM_RESOURCES 50 // do not exceed this number of resources in the endpoint. currently at 25
ansond 85:8af3f3101ba3 32
ansond 85:8af3f3101ba3 33 // IOC <--> Resource Mapping
ansond 93:ac4a8d3c2a4f 34 #define NUM_MAPPINGS 50 // do not exceed this number of IOC <--> NSP resource mappings. currently at 17
ansond 38:825f8e834e77 35
ansond 38:825f8e834e77 36 // MapEntry Name length
ansond 93:ac4a8d3c2a4f 37 #define MAX_NAME_LENGTH 25
ansond 38:825f8e834e77 38
ansond 112:1fb53d4729af 39 // Preferences configuration
ansond 112:1fb53d4729af 40 #define MAX_NUM_PREFERENCES 10 // support a total of 10 unique preferences
ansond 112:1fb53d4729af 41 #define PREFERENCE_NAME_LEN 32 // largest preference name
ansond 112:1fb53d4729af 42 #define PREFERENCE_VALUE_LEN 48 // largest preference value
ansond 112:1fb53d4729af 43
ansond 38:825f8e834e77 44 // Common Light Definition
ansond 45:da431cd42313 45 #define NUM_LIGHTS 1 // number of lights in this endpoint
ansond 53:a009aee720fe 46 #define LIGHT_NAME_LEN 48 // buffer size for the light name
ansond 45:da431cd42313 47 #define LIGHT_ON_STATE "0" // initial state of each light in this endpoint
ansond 45:da431cd42313 48 #define LIGHT_DIM_STATE "25" // initial dimming state of each light in this endpoint
ansond 38:825f8e834e77 49
ansond 38:825f8e834e77 50 // Main Loop
ansond 109:c34e2cf341a4 51 #define MAIN_LOOP_SLEEP 250 // sleep time (ms) between main loop iterations
ansond 38:825f8e834e77 52
ansond 38:825f8e834e77 53 // LED Blink Time
ansond 45:da431cd42313 54 #define BLINK_TIME 100 // LED blink times
ansond 38:825f8e834e77 55
ansond 90:0fed8d3e0b81 56 // Default Light State
ansond 90:0fed8d3e0b81 57 #define LIGHT_DEFAULT_STATE 1 // ON by default
ansond 90:0fed8d3e0b81 58
ansond 114:bd38ad417d6a 59 // IOC Linkage Resource
ansond 114:bd38ad417d6a 60 #define IOC_LINKAGE_RESOURCE "/dev/addldata" // resource containing IOC linkage ID
ansond 114:bd38ad417d6a 61 #define IOC_LINKAGE_UNSET "id:0" // IOC linkage not set
ansond 114:bd38ad417d6a 62
ansond 38:825f8e834e77 63 // Philips Light Support
ansond 38:825f8e834e77 64 #define PL_LIGHT_ID_DOUG 1 // Dougs Light
ansond 38:825f8e834e77 65 #define PL_LIGHT_ID_BILL 2 // Bills Light
ansond 38:825f8e834e77 66 #define PL_LIGHT_ID_KERRY 3 // Kerrys Light
ansond 102:432e7450a8fc 67 //#define PL_GW_ADDRESS "192.168.1.178" // Philips Gateway in IOT lab (Austin)
ansond 102:432e7450a8fc 68 #define PL_GW_ADDRESS "10.1.0.82" // Philips Gateway in IOT lab (Home)
ansond 90:0fed8d3e0b81 69 #define PL_DEFAULT_STATE LIGHT_DEFAULT_STATE // on
ansond 38:825f8e834e77 70 #define PL_DEFAULT_DIM 11 // dim value
ansond 38:825f8e834e77 71 #define PL_URL_BUFFER_LEN 128
ansond 38:825f8e834e77 72 #define PL_PAYLOAD_BUFFER_LEN 128
ansond 38:825f8e834e77 73 #define PL_RESPONSE_BUFFER_LEN 128
ansond 38:825f8e834e77 74 #define PL_URL_TEMPLATE "http://%s/api/newdeveloper/lights/%d/state"
ansond 97:d631edbc157b 75 #define PL_ON_COMMAND_TEMPLATE "{ \"on\":%s, \"sat\":211, \"bri\":%d, \"hue\":13122 } "
ansond 38:825f8e834e77 76
ansond 70:055ebf51f6ad 77 // Error Handler - use mutexes?
ansond 119:c620eb98af8b 78 #define EH_USE_MUTEXES true // true - yes, undef - no
ansond 119:c620eb98af8b 79
ansond 119:c620eb98af8b 80 // Network - use mutexes?
ansond 119:c620eb98af8b 81 #define NETWORK_MUTEX true // true - yes, undef - no
ansond 70:055ebf51f6ad 82
ansond 128:fde8d042a9af 83 // Platform specific customizations
ansond 127:58cd1d28f734 84 #ifdef _ENDPOINT_UBLOX_PLATFORM
ansond 128:fde8d042a9af 85 #define PLATFORM_STRING "U-Blox MBED" // platform string
ansond 133:667409048c68 86 #define EXT_LED_PIN D6 // pin to use for external LED cathode
ansond 130:630d05daed77 87 #define BATTERY_POT_PIN A0 // pin for the battery POT
ansond 130:630d05daed77 88 #define VOLTAGE_POT_PIN A1 // pin for the voltage POT
ansond 130:630d05daed77 89 #define TEMP_SENSOR_PIN1 P0_0 // pin for temp sensor
ansond 130:630d05daed77 90 #define TEMP_SENSOR_PIN2 P0_1 // pin for temp sensor
ansond 127:58cd1d28f734 91 #endif
ansond 127:58cd1d28f734 92
ansond 127:58cd1d28f734 93 #ifdef _ENDPOINT_NXP_PLATFORM
ansond 128:fde8d042a9af 94 #define PLATFORM_STRING "NXP MBED" // platform string
ansond 128:fde8d042a9af 95 #define EXT_LED_PIN p21 // pin to use for external LED cathode
ansond 128:fde8d042a9af 96 #define BATTERY_POT_PIN p20 // pin for the battery POT
ansond 128:fde8d042a9af 97 #define VOLTAGE_POT_PIN p19 // pin for the voltage POT
ansond 128:fde8d042a9af 98 #define TEMP_SENSOR_PIN1 p28 // pin for temp sensor
ansond 128:fde8d042a9af 99 #define TEMP_SENSOR_PIN2 p27 // pin for temp sensor
ansond 127:58cd1d28f734 100 #endif
ansond 127:58cd1d28f734 101
ansond 128:fde8d042a9af 102 #ifdef _ENDPOINT_FREEDOM_PLATFORM
ansond 128:fde8d042a9af 103 #define PLATFORM_STRING "Freescale MBED" // platform string
ansond 128:fde8d042a9af 104 #define EXT_LED_PIN p21 // pin to use for external LED cathode
ansond 128:fde8d042a9af 105 #define BATTERY_POT_PIN p20 // pin for the battery POT
ansond 128:fde8d042a9af 106 #define VOLTAGE_POT_PIN p19 // pin for the voltage POT
ansond 128:fde8d042a9af 107 #define TEMP_SENSOR_PIN1 p28 // pin for temp sensor
ansond 128:fde8d042a9af 108 #define TEMP_SENSOR_PIN2 p27 // pin for temp sensor
ansond 127:58cd1d28f734 109 #endif
ansond 127:58cd1d28f734 110
ansond 38:825f8e834e77 111 #endif // _COMMON_DEFINITIONS_H_