afLib 1.3 which is supporting both SPI and UART

Dependencies:   vt100 mbed afLib_1_3

Committer:
Rhyme
Date:
Mon Apr 23 06:15:26 2018 +0000
Revision:
0:87662653a3c6
First UART working version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Rhyme 0:87662653a3c6 1 #ifndef _AF_ATTRIBUTES_H_
Rhyme 0:87662653a3c6 2 #define _AF_ATTRIBUTES_H_
Rhyme 0:87662653a3c6 3
Rhyme 0:87662653a3c6 4 #include "mbed.h"
Rhyme 0:87662653a3c6 5 #include "afLib.h"
Rhyme 0:87662653a3c6 6
Rhyme 0:87662653a3c6 7 /**
Rhyme 0:87662653a3c6 8 * af_attributes.h
Rhyme 0:87662653a3c6 9 *
Rhyme 0:87662653a3c6 10 */
Rhyme 0:87662653a3c6 11
Rhyme 0:87662653a3c6 12 #define ATTRIBUTE_TYPE_SINT8 2
Rhyme 0:87662653a3c6 13 #define ATTRIBUTE_TYPE_SINT16 3
Rhyme 0:87662653a3c6 14 #define ATTRIBUTE_TYPE_SINT32 4
Rhyme 0:87662653a3c6 15 #define ATTRIBUTE_TYPE_SINT64 5
Rhyme 0:87662653a3c6 16 #define ATTRIBUTE_TYPE_BOOLEAN 1
Rhyme 0:87662653a3c6 17 #define ATTRIBUTE_TYPE_UTF8S 20
Rhyme 0:87662653a3c6 18 #define ATTRIBUTE_TYPE_BYTES 21
Rhyme 0:87662653a3c6 19 #define ATTRIBUTE_TYPE_FIXED_15_16 6
Rhyme 0:87662653a3c6 20
Rhyme 0:87662653a3c6 21 #define afSUCCESS 0 // Operation completed successfully
Rhyme 0:87662653a3c6 22 #define afERROR_NO_SUCH_ATTRIBUTE -1 // Request was made for unknown attribute id
Rhyme 0:87662653a3c6 23 #define afERROR_BUSY -2 // Request already in progress, try again
Rhyme 0:87662653a3c6 24 #define afERROR_INVALID_COMMAND -3 // Command could not be parsed
Rhyme 0:87662653a3c6 25 #define afERROR_QUEUE_OVERFLOW -4 // Queue is full
Rhyme 0:87662653a3c6 26 #define afERROR_QUEUE_UNDERFLOW -5 // Queue is empty
Rhyme 0:87662653a3c6 27 #define afERROR_INVALID_PARAM -6 // Bad input parameter
Rhyme 0:87662653a3c6 28
Rhyme 0:87662653a3c6 29 #define AF_SYSTEM_COMMAND 65012
Rhyme 0:87662653a3c6 30 #define AF_SYSTEM_ASR_STATE 65013
Rhyme 0:87662653a3c6 31 #define AF_SYSTEM_LINKED_TIMESTAMP 65015
Rhyme 0:87662653a3c6 32
Rhyme 0:87662653a3c6 33 #define MODULE_STATE_REBOOTED 0
Rhyme 0:87662653a3c6 34 #define MODULE_STATE_LINKED 1
Rhyme 0:87662653a3c6 35 #define MODULE_STATE_UPDATING 2
Rhyme 0:87662653a3c6 36 #define MOUDLE_STATE_UPDATE_READY 3
Rhyme 0:87662653a3c6 37
Rhyme 0:87662653a3c6 38 #define MODULE_COMMAND_NONE 0
Rhyme 0:87662653a3c6 39 #define MODULE_COMMAND_REBOOT 1
Rhyme 0:87662653a3c6 40
Rhyme 0:87662653a3c6 41 #define ATTR_SOFTWARE_RESET 666
Rhyme 0:87662653a3c6 42 #define ATTR_MCU_RESET_REASON 999
Rhyme 0:87662653a3c6 43
Rhyme 0:87662653a3c6 44 #define ATTR_LED 1024
Rhyme 0:87662653a3c6 45 #define ATTR_IO0 1025
Rhyme 0:87662653a3c6 46 #define ATTR_IO1 1026
Rhyme 0:87662653a3c6 47 #define ATTR_IO2 1028
Rhyme 0:87662653a3c6 48 #define ATTR_BUTTON 1030
Rhyme 0:87662653a3c6 49 #define ATTR_IO3 1031
Rhyme 0:87662653a3c6 50
Rhyme 0:87662653a3c6 51 #define ATTR_BOOT_LOADER_VER 2001
Rhyme 0:87662653a3c6 52 #define ATTR_BLE_STACK_VER 2002
Rhyme 0:87662653a3c6 53 #define ATTR_FW_APP_VER 2003
Rhyme 0:87662653a3c6 54 #define ATTR_DEVICE_DESC 2004
Rhyme 0:87662653a3c6 55 #define ATTR_WIFI_VER 2006
Rhyme 0:87662653a3c6 56
Rhyme 0:87662653a3c6 57 #define ATTR_OFFLINE_SCHED 59001
Rhyme 0:87662653a3c6 58 #define ATTR_SECURITY_ENABLED 60000
Rhyme 0:87662653a3c6 59 #define ATTR_UTC_OFFSET 65001
Rhyme 0:87662653a3c6 60 #define ATTR_CONFIGURES_SSID 65004
Rhyme 0:87662653a3c6 61 #define ATTR_WIFI_BARS 65005
Rhyme 0:87662653a3c6 62 #define ATTR_WIFI_STDY_STATE 65006
Rhyme 0:87662653a3c6 63
Rhyme 0:87662653a3c6 64 #define ATTR_COMMAND 65012
Rhyme 0:87662653a3c6 65 #define ATTR_ASR_STATE 65013
Rhyme 0:87662653a3c6 66 #define ATTR_LOW_BATTERY 65014
Rhyme 0:87662653a3c6 67 #define ATTR_LINKED_TIMESTAMP 65015
Rhyme 0:87662653a3c6 68 #define ATTR_ATTR_ACK 65018
Rhyme 0:87662653a3c6 69 #define ATTR_REBOOT_REASON 65019
Rhyme 0:87662653a3c6 70 #define ATTR_BLE_COMMS 65020
Rhyme 0:87662653a3c6 71 #define ATTR_MCU_INTERFACE 65021
Rhyme 0:87662653a3c6 72
Rhyme 0:87662653a3c6 73 #define DISPLAY_MODE_OFF 0
Rhyme 0:87662653a3c6 74 #define DISPLAY_MODE_GAS 1
Rhyme 0:87662653a3c6 75 #define DISPLAY_MODE_SUMMARY 2
Rhyme 0:87662653a3c6 76 #define DISPLAY_MODE_CHART 3
Rhyme 0:87662653a3c6 77
Rhyme 0:87662653a3c6 78 typedef struct {
Rhyme 0:87662653a3c6 79 uint16_t id ;
Rhyme 0:87662653a3c6 80 char *description ;
Rhyme 0:87662653a3c6 81 int attribute_type ;
Rhyme 0:87662653a3c6 82 int size ;
Rhyme 0:87662653a3c6 83 } af_attribute_type ;
Rhyme 0:87662653a3c6 84
Rhyme 0:87662653a3c6 85 /**
Rhyme 0:87662653a3c6 86 * get_af_attr
Rhyme 0:87662653a3c6 87 * @param id attribute id value to look up
Rhyme 0:87662653a3c6 88 * @returns index of the attribute in the af_attribute_type af_attr[]
Rhyme 0:87662653a3c6 89 */
Rhyme 0:87662653a3c6 90 int get_af_attr(uint16_t id) ;
Rhyme 0:87662653a3c6 91
Rhyme 0:87662653a3c6 92 /**
Rhyme 0:87662653a3c6 93 * print_af_error
Rhyme 0:87662653a3c6 94 * @param resultCode return value from afLib function(s)
Rhyme 0:87662653a3c6 95 */
Rhyme 0:87662653a3c6 96 void print_af_error(int resultCode) ;
Rhyme 0:87662653a3c6 97
Rhyme 0:87662653a3c6 98 /**
Rhyme 0:87662653a3c6 99 * Callback that allows ASR to request an MCU attribute be changed.
Rhyme 0:87662653a3c6 100 * You should define this function in your MCU firmware to perform application-specific actions
Rhyme 0:87662653a3c6 101 * your code must take (e.g., updating the state of the hardware),
Rhyme 0:87662653a3c6 102 * in light of the attribute value change.
Rhyme 0:87662653a3c6 103 */
Rhyme 0:87662653a3c6 104 bool attributeChangeRequest(
Rhyme 0:87662653a3c6 105 const uint8_t requestId,
Rhyme 0:87662653a3c6 106 const uint16_t attributeId,
Rhyme 0:87662653a3c6 107 const uint16_t valueLen,
Rhyme 0:87662653a3c6 108 const uint8_t *value
Rhyme 0:87662653a3c6 109 ) ;
Rhyme 0:87662653a3c6 110
Rhyme 0:87662653a3c6 111 /*
Rhyme 0:87662653a3c6 112 * Application callback that allows afLib to notify that an attribute has changed.
Rhyme 0:87662653a3c6 113 * This method will be called in response to a getAttribute call from the application
Rhyme 0:87662653a3c6 114 * and whenever a ASR module attribute changes.
Rhyme 0:87662653a3c6 115 */
Rhyme 0:87662653a3c6 116 void attributeUpdatedReport(
Rhyme 0:87662653a3c6 117 const uint8_t requestId,
Rhyme 0:87662653a3c6 118 const uint16_t attributeId,
Rhyme 0:87662653a3c6 119 const uint16_t valueLen,
Rhyme 0:87662653a3c6 120 const uint8_t *value
Rhyme 0:87662653a3c6 121 ) ;
Rhyme 0:87662653a3c6 122
Rhyme 0:87662653a3c6 123 extern afLib *afero ;
Rhyme 0:87662653a3c6 124 #endif /* _AF_ATTRIBUTES_H */