Added a GPIO to power on/off for external I2C sensor(s) (with LEDs)

Dependencies:   UniGraphic mbed vt100

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers af_attributes.h Source File

af_attributes.h

00001 #ifndef _AF_ATTRIBUTES_H_
00002 #define _AF_ATTRIBUTES_H_
00003 
00004 #include "mbed.h"
00005 #include "afLib.h"
00006 
00007 /**
00008  * af_attributes.h
00009  *
00010  */
00011 
00012 #define ATTRIBUTE_TYPE_SINT8                                       2
00013 #define ATTRIBUTE_TYPE_SINT16                                      3
00014 #define ATTRIBUTE_TYPE_SINT32                                      4
00015 #define ATTRIBUTE_TYPE_SINT64                                      5
00016 #define ATTRIBUTE_TYPE_BOOLEAN                                     1
00017 #define ATTRIBUTE_TYPE_UTF8S                                      20
00018 #define ATTRIBUTE_TYPE_BYTES                                      21
00019 #define ATTRIBUTE_TYPE_FIXED_15_16                                 6
00020 
00021 #define afSUCCESS                    0    // Operation completed successfully
00022 #define afERROR_NO_SUCH_ATTRIBUTE   -1    // Request was made for unknown attribute id
00023 #define afERROR_BUSY                -2    // Request already in progress, try again
00024 #define afERROR_INVALID_COMMAND     -3    // Command could not be parsed
00025 #define afERROR_QUEUE_OVERFLOW      -4    // Queue is full
00026 #define afERROR_QUEUE_UNDERFLOW     -5    // Queue is empty
00027 #define afERROR_INVALID_PARAM       -6    // Bad input parameter
00028 
00029 #define AF_SYSTEM_COMMAND            65012
00030 #define AF_SYSTEM_ASR_STATE          65013
00031 #define AF_SYSTEM_LINKED_TIMESTAMP   65015
00032 
00033 #define MODULE_STATE_REBOOTED                 0
00034 #define MODULE_STATE_LINKED                   1
00035 #define MODULE_STATE_UPDATING                 2
00036 #define MOUDLE_STATE_UPDATE_READY             3
00037 
00038 #define MODULE_COMMAND_NONE                   0
00039 #define MODULE_COMMAND_REBOOT                 1
00040 
00041 #define ATTR_SENSE_VAL               1
00042 #define ATTR_ACCEL_PRESENT           100
00043 #define ATTR_ACCEL_ENABLE            101
00044 #define ATTR_ACCEL_INTERVAL          102 
00045 #define ATTR_ACCEL_VALUE             103
00046 
00047 #define ATTR_COLOR0_PRESENT          200
00048 #define ATTR_COLOR0_ENABLE           201
00049 #define ATTR_COLOR0_INTERVAL         202
00050 #define ATTR_COLOR0_TRIGMODE         203
00051 #define ATTR_COLOR0_ITIME            204
00052 #define ATTR_COLOR0_CALIBRATE        205
00053 #define ATTR_COLOR0_PWM_R            206
00054 #define ATTR_COLOR0_PWM_G            207
00055 #define ATTR_COLOR0_PWM_B            208
00056 #define ATTR_COLOR0_PWM_PERIOD       209
00057 #define ATTR_COLOR0_PWM_TARGET       210
00058 #define ATTR_COLOR0_R_VALUE          211
00059 #define ATTR_COLOR0_G_VALUE          212
00060 #define ATTR_COLOR0_B_VALUE          213
00061 
00062 #define ATTR_COLOR1_PRESENT          220
00063 #define ATTR_COLOR1_ENABLE           221
00064 #define ATTR_COLOR1_INTERVAL         222
00065 #define ATTR_COLOR1_TRIGMODE         223
00066 #define ATTR_COLOR1_ITIME            224
00067 #define ATTR_COLOR1_CALIBRATE        225
00068 #define ATTR_COLOR1_PWM_R            226
00069 #define ATTR_COLOR1_PWM_G            227
00070 #define ATTR_COLOR1_PWM_B            228
00071 #define ATTR_COLOR1_PWM_PERIOD       229
00072 #define ATTR_COLOR1_PWM_TARGET       230
00073 #define ATTR_COLOR1_R_VALUE          231
00074 #define ATTR_COLOR1_G_VALUE          232
00075 #define ATTR_COLOR1_B_VALUE          233
00076 
00077 /* temperature sensor LM75B with color0 */
00078 #define ATTR_TEMP0_PRESENT           300
00079 #define ATTR_TEMP0_ENABLE            301
00080 #define ATTR_TEMP0_INTERVAL          302
00081 #define ATTR_TEMP0_VALUE             303
00082 
00083 /* temperature sensor AT502-11 (before) */
00084 #define ATTR_TEMP1_PRESENT           310
00085 #define ATTR_TEMP1_ENABLE            311
00086 #define ATTR_TEMP1_INTERVAL          312
00087 #define ATTR_TEMP1_VALUE             313
00088 
00089 /* temperature sensor AT502-11 (after) */
00090 #define ATTR_TEMP2_PRESENT           320
00091 #define ATTR_TEMP2_ENABLE            321
00092 #define ATTR_TEMP2_INTERVAL          322
00093 #define ATTR_TEMP2_VALUE             323
00094 
00095 /* temperature sensor LM75B with color1 */
00096 #define ATTR_TEMP3_PRESENT           330
00097 #define ATTR_TEMP3_ENABLE            331
00098 #define ATTR_TEMP3_INTERVAL          332
00099 #define ATTR_TEMP3_VALUE             333
00100 
00101 /* gas pressure sensor */
00102 /* gas pressure sensor */
00103 #define ATTR_GAS_PRESENT            400
00104 #define ATTR_GAS_ENABLE             401
00105 #define ATTR_GAS_INTERVAL           402
00106 #define ATTR_GAS_VALUE              403
00107 #define ATTR_GAS_THR_MODE           404
00108 #define ATTR_GAS_THR_HIGH           405
00109 #define ATTR_GAS_THR_LOW            406
00110 
00111 /* current trans sensor */
00112 #define ATTR_CURRENT_PRESENT         500
00113 #define ATTR_CURRENT_ENABLE          501
00114 #define ATTR_CURRENT_INTERVAL        502
00115 #define ATTR_CURRENT_VALUE           503
00116 
00117 #define ATTR_SOFTWARE_RESET          666
00118 #define ATTR_DISPLAY_MODE            777
00119 #define ATTR_MCU_RESET_REASON        999
00120 
00121 #define ATTR_LED                 1024
00122 #define ATTR_IO0                 1025
00123 #define ATTR_IO1                 1026
00124 #define ATTR_IO2                 1028
00125 #define ATTR_BUTTON              1030
00126 #define ATTR_IO3                 1031
00127 
00128 #define ATTR_BOOT_LOADER_VER     2001
00129 #define ATTR_BLE_STACK_VER       2002
00130 #define ATTR_FW_APP_VER          2003
00131 #define ATTR_DEVICE_DESC         2004
00132 #define ATTR_WIFI_VER            2006
00133 
00134 #define ATTR_OFFLINE_SCHED      59001
00135 #define ATTR_SECURITY_ENABLED   60000
00136 #define ATTR_UTC_OFFSET         65001
00137 #define ATTR_CONFIGURES_SSID    65004
00138 #define ATTR_WIFI_BARS          65005
00139 #define ATTR_WIFI_STDY_STATE    65006
00140 
00141 #define ATTR_COMMAND            65012
00142 #define ATTR_ASR_STATE          65013
00143 #define ATTR_LOW_BATTERY        65014
00144 #define ATTR_LINKED_TIMESTAMP   65015
00145 #define ATTR_ATTR_ACK           65018
00146 #define ATTR_REBOOT_REASON      65019
00147 #define ATTR_BLE_COMMS          65020
00148 #define ATTR_MCU_INTERFACE      65021
00149 
00150 #define DISPLAY_MODE_OFF        0
00151 #define DISPLAY_MODE_GAS        1
00152 #define DISPLAY_MODE_SUMMARY    2
00153 #define DISPLAY_MODE_CHART      3
00154 
00155 typedef struct {
00156     uint16_t id ;
00157     char *description ;
00158     int attribute_type ;
00159     int size ;
00160 } af_attribute_type ;
00161 
00162 /**
00163  * get_af_attr
00164  * @param id attribute id value to look up
00165  * @returns index of the attribute in the af_attribute_type af_attr[]
00166  */
00167 int get_af_attr(uint16_t id) ;
00168 
00169 /**
00170  * print_af_error
00171  * @param resultCode return value from afLib function(s)
00172  */
00173 void print_af_error(int resultCode) ;
00174 
00175 /**
00176  * Callback that allows ASR to request an MCU attribute be changed. 
00177  * You should define this function in your MCU firmware to perform application-specific actions 
00178  * your code must take (e.g., updating the state of the hardware), 
00179  * in light of the attribute value change.
00180 */
00181 void attributeChangeRequest(
00182     const uint8_t   requestId, 
00183     const uint16_t  attributeId,
00184     const uint16_t  valueLen,
00185     const uint8_t   *value
00186 ) ;
00187 
00188 /*
00189  * Application callback that allows afLib to notify that an attribute has changed. 
00190  * This method will be called in response to a getAttribute call from the application 
00191  * and whenever a ASR module attribute changes.
00192  */
00193 void attributeUpdatedReport(
00194     const uint8_t   requestId,
00195     const uint16_t  attributeId,
00196     const uint16_t  valueLen,
00197     const uint8_t   *value
00198 ) ;
00199 
00200 extern afLib *afero ; 
00201 #endif /* _AF_ATTRIBUTES_H */