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:
Wed Jul 16 17:29:00 2014 +0000
Revision:
167:2529c18d0eb1
Parent:
161:a85cb6cba5ed
Child:
171:3f07e1df766c
added APMDemoLight

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 134:58e7537a8c5f 23 #define MAX_LOG_MESSAGE 900 // maximum size of a logging message
ansond 134:58e7537a8c5f 24 #define TEMP_BUFFER_LEN 128 // working/temp buffer length
ansond 38:825f8e834e77 25
ansond 38:825f8e834e77 26 // Resource Configuration
ansond 134:58e7537a8c5f 27 #define RESOURCE_NAME_LEN 25 // Resource name max length
ansond 134:58e7537a8c5f 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 155:582462821bd7 31 #define NUM_RESOURCES 30 // 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 155:582462821bd7 34 #define NUM_MAPPINGS 20 // 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 155:582462821bd7 40 #define MAX_NUM_PREFERENCES 5 // support a total of 5 unique preferences
ansond 155:582462821bd7 41 #define PREFERENCE_NAME_LEN 24 // largest preference name
ansond 155:582462821bd7 42 #define PREFERENCE_VALUE_LEN 40 // largest preference value
ansond 134:58e7537a8c5f 43
ansond 134:58e7537a8c5f 44 // Personality Configuration
ansond 134:58e7537a8c5f 45 #define NUM_PERSONALITY_INSTANCES 1 // number of isntances of a specific personality (i.e. light) in this endpoint
ansond 134:58e7537a8c5f 46 #define PERSONALITY_NAME_LEN 48 // buffer size for the personality name
ansond 134:58e7537a8c5f 47 #define PERSONALITY_NAME_INDEX 1 // start index for the ID of the personality name
ansond 112:1fb53d4729af 48
ansond 38:825f8e834e77 49 // Common Light Definition
ansond 134:58e7537a8c5f 50 #define LIGHT_ON_STATE "0" // initial state of each light in this endpoint
ansond 140:df0ca2c95982 51 #define LIGHT_DIM_STATE "100" // initial dimming state of each light in this endpoint
ansond 134:58e7537a8c5f 52 #define LIGHT_TYPE_STRING "Light" // Type of Light (string)
ansond 134:58e7537a8c5f 53 #define LIGHT_BLINK_WAIT_MS 1000 // time between blinks (ms)
ansond 140:df0ca2c95982 54 #define LIGHT_DEFAULT_STATE 1 // ON by default
ansond 140:df0ca2c95982 55
ansond 158:0cecb265bb18 56 // Multitech probe for temperature reporting
ansond 158:0cecb265bb18 57 //#define MULTITECH_TEMP_PROBE true
ansond 158:0cecb265bb18 58
ansond 140:df0ca2c95982 59 // Personalities may have unique default light states
ansond 140:df0ca2c95982 60 #ifdef LIGHT_PERSONALITY
ansond 140:df0ca2c95982 61 #undef LIGHT_DEFAULT_STATE
ansond 140:df0ca2c95982 62 #undef LIGHT_BLINK_WAIT_MS
ansond 141:26dca377597f 63 #define LIGHT_DEFAULT_STATE "1" // ON by default
ansond 140:df0ca2c95982 64 #define LIGHT_BLINK_WAIT_MS 1000 // time between blinks (ms)
ansond 167:2529c18d0eb1 65 #if APM_LIGHT_ENABLE
ansond 167:2529c18d0eb1 66 #define APM_LIGHT_PERSONALITY true
ansond 167:2529c18d0eb1 67 #endif
ansond 140:df0ca2c95982 68 #endif
ansond 140:df0ca2c95982 69 #ifdef COPCAR_PERSONALITY
ansond 140:df0ca2c95982 70 #undef LIGHT_DEFAULT_STATE
ansond 140:df0ca2c95982 71 #undef LIGHT_BLINK_WAIT_MS
ansond 141:26dca377597f 72 #define LIGHT_DEFAULT_STATE "0" // OFF by default
ansond 140:df0ca2c95982 73 #define LIGHT_BLINK_WAIT_MS 400 // time between blinks (ms)
ansond 140:df0ca2c95982 74 #endif
ansond 38:825f8e834e77 75
ansond 38:825f8e834e77 76 // Main Loop
ansond 134:58e7537a8c5f 77 #define MAIN_LOOP_SLEEP 250 // sleep time (ms) between main loop iterations
ansond 38:825f8e834e77 78
ansond 38:825f8e834e77 79 // LED Blink Time
ansond 134:58e7537a8c5f 80 #define BLINK_TIME 100 // LED blink times
ansond 38:825f8e834e77 81
ansond 134:58e7537a8c5f 82 // External Linkage Resource
ansond 134:58e7537a8c5f 83 #define EXTERNAL_LINKAGE_RESOURCE "/dev/addldata" // resource containing IOC linkage ID
ansond 134:58e7537a8c5f 84 #define EXTERNAL_LINKAGE_UNSET "id:0" // IOC linkage not set
ansond 114:bd38ad417d6a 85
ansond 38:825f8e834e77 86 // Philips Light Support
ansond 38:825f8e834e77 87 #define PL_LIGHT_ID_DOUG 1 // Dougs Light
ansond 38:825f8e834e77 88 #define PL_LIGHT_ID_BILL 2 // Bills Light
ansond 38:825f8e834e77 89 #define PL_LIGHT_ID_KERRY 3 // Kerrys Light
ansond 134:58e7537a8c5f 90 #define PL_GW_ADDRESS "192.168.1.178" // Philips Gateway in IOT lab (Austin)
ansond 90:0fed8d3e0b81 91 #define PL_DEFAULT_STATE LIGHT_DEFAULT_STATE // on
ansond 38:825f8e834e77 92 #define PL_DEFAULT_DIM 11 // dim value
ansond 38:825f8e834e77 93 #define PL_URL_BUFFER_LEN 128
ansond 38:825f8e834e77 94 #define PL_PAYLOAD_BUFFER_LEN 128
ansond 38:825f8e834e77 95 #define PL_RESPONSE_BUFFER_LEN 128
ansond 38:825f8e834e77 96 #define PL_URL_TEMPLATE "http://%s/api/newdeveloper/lights/%d/state"
ansond 97:d631edbc157b 97 #define PL_ON_COMMAND_TEMPLATE "{ \"on\":%s, \"sat\":211, \"bri\":%d, \"hue\":13122 } "
ansond 38:825f8e834e77 98
ansond 160:24337c83dd1d 99 #ifndef CELLULAR_NETWORK
ansond 161:a85cb6cba5ed 100 // Error Handler - use mutexes?
ansond 161:a85cb6cba5ed 101 #define EH_USE_MUTEXES true // true - yes, undef - no
ansond 161:a85cb6cba5ed 102
ansond 161:a85cb6cba5ed 103 // Network - use mutexes?
ansond 161:a85cb6cba5ed 104 #define NETWORK_MUTEX true // true - yes, undef - no
ansond 161:a85cb6cba5ed 105
ansond 161:a85cb6cba5ed 106 // Has Threads?
ansond 161:a85cb6cba5ed 107 #define ENABLE_THREADS true // true - yes, undef - no
ansond 160:24337c83dd1d 108 #endif
ansond 160:24337c83dd1d 109
ansond 128:fde8d042a9af 110 // Platform specific customizations
ansond 127:58cd1d28f734 111 #ifdef _ENDPOINT_UBLOX_PLATFORM
ansond 128:fde8d042a9af 112 #define PLATFORM_STRING "U-Blox MBED" // platform string
ansond 136:f433e40f8d65 113 #define EXT_LED_PIN D3 // pin to use for external LED cathode, use D6 for speaker
ansond 145:24ac7ac92777 114 #define EXT_LED_PIN_COPCAR D10 // pin to use for external LED cathode (copcar personality only)
ansond 130:630d05daed77 115 #define BATTERY_POT_PIN A0 // pin for the battery POT
ansond 130:630d05daed77 116 #define VOLTAGE_POT_PIN A1 // pin for the voltage POT
ansond 130:630d05daed77 117 #define TEMP_SENSOR_PIN1 P0_0 // pin for temp sensor
ansond 130:630d05daed77 118 #define TEMP_SENSOR_PIN2 P0_1 // pin for temp sensor
ansond 127:58cd1d28f734 119 #endif
ansond 127:58cd1d28f734 120
ansond 127:58cd1d28f734 121 #ifdef _ENDPOINT_NXP_PLATFORM
ansond 128:fde8d042a9af 122 #define PLATFORM_STRING "NXP MBED" // platform string
ansond 128:fde8d042a9af 123 #define EXT_LED_PIN p21 // pin to use for external LED cathode
ansond 143:1388cb37c27e 124 #define EXT_LED_PIN_COPCAR p22 // pin to use for external LED cathode (copcar personality only)
ansond 128:fde8d042a9af 125 #define BATTERY_POT_PIN p20 // pin for the battery POT
ansond 128:fde8d042a9af 126 #define VOLTAGE_POT_PIN p19 // pin for the voltage POT
ansond 128:fde8d042a9af 127 #define TEMP_SENSOR_PIN1 p28 // pin for temp sensor
ansond 128:fde8d042a9af 128 #define TEMP_SENSOR_PIN2 p27 // pin for temp sensor
ansond 127:58cd1d28f734 129 #endif
ansond 127:58cd1d28f734 130
ansond 128:fde8d042a9af 131 #ifdef _ENDPOINT_FREEDOM_PLATFORM
ansond 128:fde8d042a9af 132 #define PLATFORM_STRING "Freescale MBED" // platform string
ansond 128:fde8d042a9af 133 #define EXT_LED_PIN p21 // pin to use for external LED cathode
ansond 143:1388cb37c27e 134 #define EXT_LED_PIN_COPCAR p22 // pin to use for external LED cathode (copcar personality only)
ansond 128:fde8d042a9af 135 #define BATTERY_POT_PIN p20 // pin for the battery POT
ansond 128:fde8d042a9af 136 #define VOLTAGE_POT_PIN p19 // pin for the voltage POT
ansond 128:fde8d042a9af 137 #define TEMP_SENSOR_PIN1 p28 // pin for temp sensor
ansond 128:fde8d042a9af 138 #define TEMP_SENSOR_PIN2 p27 // pin for temp sensor
ansond 127:58cd1d28f734 139 #endif
ansond 127:58cd1d28f734 140
ansond 38:825f8e834e77 141 #endif // _COMMON_DEFINITIONS_H_