Color sensor reset at the end of calibration added. sensor id auto assignment was changed to be a fixed value assignment to avoid sensor id shift when some sensor is absent.

Dependencies:   UniGraphic mbed vt100

Committer:
Rhyme
Date:
Fri Feb 23 05:40:22 2018 +0000
Revision:
0:ce97f6d34336
color sensor reset was added at the end of calibration

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Rhyme 0:ce97f6d34336 1 #ifndef _AF_ATTRIBUTES_H_
Rhyme 0:ce97f6d34336 2 #define _AF_ATTRIBUTES_H_
Rhyme 0:ce97f6d34336 3
Rhyme 0:ce97f6d34336 4 #include "mbed.h"
Rhyme 0:ce97f6d34336 5 #include "afLib.h"
Rhyme 0:ce97f6d34336 6
Rhyme 0:ce97f6d34336 7 /**
Rhyme 0:ce97f6d34336 8 * af_attributes.h
Rhyme 0:ce97f6d34336 9 *
Rhyme 0:ce97f6d34336 10 */
Rhyme 0:ce97f6d34336 11
Rhyme 0:ce97f6d34336 12 #define ATTRIBUTE_TYPE_SINT8 2
Rhyme 0:ce97f6d34336 13 #define ATTRIBUTE_TYPE_SINT16 3
Rhyme 0:ce97f6d34336 14 #define ATTRIBUTE_TYPE_SINT32 4
Rhyme 0:ce97f6d34336 15 #define ATTRIBUTE_TYPE_SINT64 5
Rhyme 0:ce97f6d34336 16 #define ATTRIBUTE_TYPE_BOOLEAN 1
Rhyme 0:ce97f6d34336 17 #define ATTRIBUTE_TYPE_UTF8S 20
Rhyme 0:ce97f6d34336 18 #define ATTRIBUTE_TYPE_BYTES 21
Rhyme 0:ce97f6d34336 19 #define ATTRIBUTE_TYPE_FIXED_15_16 6
Rhyme 0:ce97f6d34336 20
Rhyme 0:ce97f6d34336 21 #define afSUCCESS 0 // Operation completed successfully
Rhyme 0:ce97f6d34336 22 #define afERROR_NO_SUCH_ATTRIBUTE -1 // Request was made for unknown attribute id
Rhyme 0:ce97f6d34336 23 #define afERROR_BUSY -2 // Request already in progress, try again
Rhyme 0:ce97f6d34336 24 #define afERROR_INVALID_COMMAND -3 // Command could not be parsed
Rhyme 0:ce97f6d34336 25 #define afERROR_QUEUE_OVERFLOW -4 // Queue is full
Rhyme 0:ce97f6d34336 26 #define afERROR_QUEUE_UNDERFLOW -5 // Queue is empty
Rhyme 0:ce97f6d34336 27 #define afERROR_INVALID_PARAM -6 // Bad input parameter
Rhyme 0:ce97f6d34336 28
Rhyme 0:ce97f6d34336 29 #define AF_SYSTEM_COMMAND 65012
Rhyme 0:ce97f6d34336 30 #define AF_SYSTEM_ASR_STATE 65013
Rhyme 0:ce97f6d34336 31 #define AF_SYSTEM_LINKED_TIMESTAMP 65015
Rhyme 0:ce97f6d34336 32
Rhyme 0:ce97f6d34336 33 #define MODULE_STATE_REBOOTED 0
Rhyme 0:ce97f6d34336 34 #define MODULE_STATE_LINKED 1
Rhyme 0:ce97f6d34336 35 #define MODULE_STATE_UPDATING 2
Rhyme 0:ce97f6d34336 36 #define MOUDLE_STATE_UPDATE_READY 3
Rhyme 0:ce97f6d34336 37
Rhyme 0:ce97f6d34336 38 #define MODULE_COMMAND_NONE 0
Rhyme 0:ce97f6d34336 39 #define MODULE_COMMAND_REBOOT 1
Rhyme 0:ce97f6d34336 40
Rhyme 0:ce97f6d34336 41 #define ATTR_SENSE_VAL 1
Rhyme 0:ce97f6d34336 42 #define ATTR_ACCEL_PRESENT 100
Rhyme 0:ce97f6d34336 43 #define ATTR_ACCEL_ENABLE 101
Rhyme 0:ce97f6d34336 44 #define ATTR_ACCEL_INTERVAL 102
Rhyme 0:ce97f6d34336 45 #define ATTR_ACCEL_VALUE 103
Rhyme 0:ce97f6d34336 46
Rhyme 0:ce97f6d34336 47 #define ATTR_COLOR0_PRESENT 200
Rhyme 0:ce97f6d34336 48 #define ATTR_COLOR0_ENABLE 201
Rhyme 0:ce97f6d34336 49 #define ATTR_COLOR0_INTERVAL 202
Rhyme 0:ce97f6d34336 50 #define ATTR_COLOR0_TRIGMODE 203
Rhyme 0:ce97f6d34336 51 #define ATTR_COLOR0_ITIME 204
Rhyme 0:ce97f6d34336 52 #define ATTR_COLOR0_CALIBRATE 205
Rhyme 0:ce97f6d34336 53 #define ATTR_COLOR0_PWM_R 206
Rhyme 0:ce97f6d34336 54 #define ATTR_COLOR0_PWM_G 207
Rhyme 0:ce97f6d34336 55 #define ATTR_COLOR0_PWM_B 208
Rhyme 0:ce97f6d34336 56 #define ATTR_COLOR0_PWM_PERIOD 209
Rhyme 0:ce97f6d34336 57 #define ATTR_COLOR0_PWM_TARGET 210
Rhyme 0:ce97f6d34336 58 #define ATTR_COLOR0_R_VALUE 211
Rhyme 0:ce97f6d34336 59 #define ATTR_COLOR0_G_VALUE 212
Rhyme 0:ce97f6d34336 60 #define ATTR_COLOR0_B_VALUE 213
Rhyme 0:ce97f6d34336 61
Rhyme 0:ce97f6d34336 62 #define ATTR_COLOR1_PRESENT 220
Rhyme 0:ce97f6d34336 63 #define ATTR_COLOR1_ENABLE 221
Rhyme 0:ce97f6d34336 64 #define ATTR_COLOR1_INTERVAL 222
Rhyme 0:ce97f6d34336 65 #define ATTR_COLOR1_TRIGMODE 223
Rhyme 0:ce97f6d34336 66 #define ATTR_COLOR1_ITIME 224
Rhyme 0:ce97f6d34336 67 #define ATTR_COLOR1_CALIBRATE 225
Rhyme 0:ce97f6d34336 68 #define ATTR_COLOR1_PWM_R 226
Rhyme 0:ce97f6d34336 69 #define ATTR_COLOR1_PWM_G 227
Rhyme 0:ce97f6d34336 70 #define ATTR_COLOR1_PWM_B 228
Rhyme 0:ce97f6d34336 71 #define ATTR_COLOR1_PWM_PERIOD 229
Rhyme 0:ce97f6d34336 72 #define ATTR_COLOR1_PWM_TARGET 230
Rhyme 0:ce97f6d34336 73 #define ATTR_COLOR1_R_VALUE 231
Rhyme 0:ce97f6d34336 74 #define ATTR_COLOR1_G_VALUE 232
Rhyme 0:ce97f6d34336 75 #define ATTR_COLOR1_B_VALUE 233
Rhyme 0:ce97f6d34336 76
Rhyme 0:ce97f6d34336 77 /* temperature sensor LM75B with color0 */
Rhyme 0:ce97f6d34336 78 #define ATTR_TEMP0_PRESENT 300
Rhyme 0:ce97f6d34336 79 #define ATTR_TEMP0_ENABLE 301
Rhyme 0:ce97f6d34336 80 #define ATTR_TEMP0_INTERVAL 302
Rhyme 0:ce97f6d34336 81 #define ATTR_TEMP0_VALUE 303
Rhyme 0:ce97f6d34336 82
Rhyme 0:ce97f6d34336 83 /* temperature sensor AT502-11 (before) */
Rhyme 0:ce97f6d34336 84 #define ATTR_TEMP1_PRESENT 310
Rhyme 0:ce97f6d34336 85 #define ATTR_TEMP1_ENABLE 311
Rhyme 0:ce97f6d34336 86 #define ATTR_TEMP1_INTERVAL 312
Rhyme 0:ce97f6d34336 87 #define ATTR_TEMP1_VALUE 313
Rhyme 0:ce97f6d34336 88
Rhyme 0:ce97f6d34336 89 /* temperature sensor AT502-11 (after) */
Rhyme 0:ce97f6d34336 90 #define ATTR_TEMP2_PRESENT 320
Rhyme 0:ce97f6d34336 91 #define ATTR_TEMP2_ENABLE 321
Rhyme 0:ce97f6d34336 92 #define ATTR_TEMP2_INTERVAL 322
Rhyme 0:ce97f6d34336 93 #define ATTR_TEMP2_VALUE 323
Rhyme 0:ce97f6d34336 94
Rhyme 0:ce97f6d34336 95 /* temperature sensor LM75B with color1 */
Rhyme 0:ce97f6d34336 96 #define ATTR_TEMP3_PRESENT 330
Rhyme 0:ce97f6d34336 97 #define ATTR_TEMP3_ENABLE 331
Rhyme 0:ce97f6d34336 98 #define ATTR_TEMP3_INTERVAL 332
Rhyme 0:ce97f6d34336 99 #define ATTR_TEMP3_VALUE 333
Rhyme 0:ce97f6d34336 100
Rhyme 0:ce97f6d34336 101 /* gas pressure sensor */
Rhyme 0:ce97f6d34336 102 /* gas pressure sensor */
Rhyme 0:ce97f6d34336 103 #define ATTR_GAS_PRESENT 400
Rhyme 0:ce97f6d34336 104 #define ATTR_GAS_ENABLE 401
Rhyme 0:ce97f6d34336 105 #define ATTR_GAS_INTERVAL 402
Rhyme 0:ce97f6d34336 106 #define ATTR_GAS_VALUE 403
Rhyme 0:ce97f6d34336 107 #define ATTR_GAS_THR_MODE 404
Rhyme 0:ce97f6d34336 108 #define ATTR_GAS_THR_HIGH 405
Rhyme 0:ce97f6d34336 109 #define ATTR_GAS_THR_LOW 406
Rhyme 0:ce97f6d34336 110
Rhyme 0:ce97f6d34336 111 /* current trans sensor */
Rhyme 0:ce97f6d34336 112 #define ATTR_CURRENT_PRESENT 500
Rhyme 0:ce97f6d34336 113 #define ATTR_CURRENT_ENABLE 501
Rhyme 0:ce97f6d34336 114 #define ATTR_CURRENT_INTERVAL 502
Rhyme 0:ce97f6d34336 115 #define ATTR_CURRENT_VALUE 503
Rhyme 0:ce97f6d34336 116
Rhyme 0:ce97f6d34336 117 #define ATTR_SOFTWARE_RESET 666
Rhyme 0:ce97f6d34336 118 #define ATTR_DISPLAY_MODE 777
Rhyme 0:ce97f6d34336 119 #define ATTR_MCU_RESET_REASON 999
Rhyme 0:ce97f6d34336 120
Rhyme 0:ce97f6d34336 121 #define ATTR_LED 1024
Rhyme 0:ce97f6d34336 122 #define ATTR_IO0 1025
Rhyme 0:ce97f6d34336 123 #define ATTR_IO1 1026
Rhyme 0:ce97f6d34336 124 #define ATTR_IO2 1028
Rhyme 0:ce97f6d34336 125 #define ATTR_BUTTON 1030
Rhyme 0:ce97f6d34336 126 #define ATTR_IO3 1031
Rhyme 0:ce97f6d34336 127
Rhyme 0:ce97f6d34336 128 #define ATTR_BOOT_LOADER_VER 2001
Rhyme 0:ce97f6d34336 129 #define ATTR_BLE_STACK_VER 2002
Rhyme 0:ce97f6d34336 130 #define ATTR_FW_APP_VER 2003
Rhyme 0:ce97f6d34336 131 #define ATTR_DEVICE_DESC 2004
Rhyme 0:ce97f6d34336 132 #define ATTR_WIFI_VER 2006
Rhyme 0:ce97f6d34336 133
Rhyme 0:ce97f6d34336 134 #define ATTR_OFFLINE_SCHED 59001
Rhyme 0:ce97f6d34336 135 #define ATTR_SECURITY_ENABLED 60000
Rhyme 0:ce97f6d34336 136 #define ATTR_UTC_OFFSET 65001
Rhyme 0:ce97f6d34336 137 #define ATTR_CONFIGURES_SSID 65004
Rhyme 0:ce97f6d34336 138 #define ATTR_WIFI_BARS 65005
Rhyme 0:ce97f6d34336 139 #define ATTR_WIFI_STDY_STATE 65006
Rhyme 0:ce97f6d34336 140
Rhyme 0:ce97f6d34336 141 #define ATTR_COMMAND 65012
Rhyme 0:ce97f6d34336 142 #define ATTR_ASR_STATE 65013
Rhyme 0:ce97f6d34336 143 #define ATTR_LOW_BATTERY 65014
Rhyme 0:ce97f6d34336 144 #define ATTR_LINKED_TIMESTAMP 65015
Rhyme 0:ce97f6d34336 145 #define ATTR_ATTR_ACK 65018
Rhyme 0:ce97f6d34336 146 #define ATTR_REBOOT_REASON 65019
Rhyme 0:ce97f6d34336 147 #define ATTR_BLE_COMMS 65020
Rhyme 0:ce97f6d34336 148 #define ATTR_MCU_INTERFACE 65021
Rhyme 0:ce97f6d34336 149
Rhyme 0:ce97f6d34336 150 #define DISPLAY_MODE_OFF 0
Rhyme 0:ce97f6d34336 151 #define DISPLAY_MODE_GAS 1
Rhyme 0:ce97f6d34336 152 #define DISPLAY_MODE_SUMMARY 2
Rhyme 0:ce97f6d34336 153 #define DISPLAY_MODE_CHART 3
Rhyme 0:ce97f6d34336 154
Rhyme 0:ce97f6d34336 155 typedef struct {
Rhyme 0:ce97f6d34336 156 uint16_t id ;
Rhyme 0:ce97f6d34336 157 char *description ;
Rhyme 0:ce97f6d34336 158 int attribute_type ;
Rhyme 0:ce97f6d34336 159 int size ;
Rhyme 0:ce97f6d34336 160 } af_attribute_type ;
Rhyme 0:ce97f6d34336 161
Rhyme 0:ce97f6d34336 162 /**
Rhyme 0:ce97f6d34336 163 * get_af_attr
Rhyme 0:ce97f6d34336 164 * @param id attribute id value to look up
Rhyme 0:ce97f6d34336 165 * @returns index of the attribute in the af_attribute_type af_attr[]
Rhyme 0:ce97f6d34336 166 */
Rhyme 0:ce97f6d34336 167 int get_af_attr(uint16_t id) ;
Rhyme 0:ce97f6d34336 168
Rhyme 0:ce97f6d34336 169 /**
Rhyme 0:ce97f6d34336 170 * print_af_error
Rhyme 0:ce97f6d34336 171 * @param resultCode return value from afLib function(s)
Rhyme 0:ce97f6d34336 172 */
Rhyme 0:ce97f6d34336 173 void print_af_error(int resultCode) ;
Rhyme 0:ce97f6d34336 174
Rhyme 0:ce97f6d34336 175 /**
Rhyme 0:ce97f6d34336 176 * Callback that allows ASR to request an MCU attribute be changed.
Rhyme 0:ce97f6d34336 177 * You should define this function in your MCU firmware to perform application-specific actions
Rhyme 0:ce97f6d34336 178 * your code must take (e.g., updating the state of the hardware),
Rhyme 0:ce97f6d34336 179 * in light of the attribute value change.
Rhyme 0:ce97f6d34336 180 */
Rhyme 0:ce97f6d34336 181 void attributeChangeRequest(
Rhyme 0:ce97f6d34336 182 const uint8_t requestId,
Rhyme 0:ce97f6d34336 183 const uint16_t attributeId,
Rhyme 0:ce97f6d34336 184 const uint16_t valueLen,
Rhyme 0:ce97f6d34336 185 const uint8_t *value
Rhyme 0:ce97f6d34336 186 ) ;
Rhyme 0:ce97f6d34336 187
Rhyme 0:ce97f6d34336 188 /*
Rhyme 0:ce97f6d34336 189 * Application callback that allows afLib to notify that an attribute has changed.
Rhyme 0:ce97f6d34336 190 * This method will be called in response to a getAttribute call from the application
Rhyme 0:ce97f6d34336 191 * and whenever a ASR module attribute changes.
Rhyme 0:ce97f6d34336 192 */
Rhyme 0:ce97f6d34336 193 void attributeUpdatedReport(
Rhyme 0:ce97f6d34336 194 const uint8_t requestId,
Rhyme 0:ce97f6d34336 195 const uint16_t attributeId,
Rhyme 0:ce97f6d34336 196 const uint16_t valueLen,
Rhyme 0:ce97f6d34336 197 const uint8_t *value
Rhyme 0:ce97f6d34336 198 ) ;
Rhyme 0:ce97f6d34336 199
Rhyme 0:ce97f6d34336 200 extern afLib *afero ;
Rhyme 0:ce97f6d34336 201 #endif /* _AF_ATTRIBUTES_H */