Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
ublox.h
00001 /** 00002 ******************************************************************************** 00003 * @file bluetooth.h 00004 * @brief Header file containing API for bluetooth.c 00005 * 00006 ******************************************************************************** 00007 * @author TTP 00008 * @copyright (c) 2017 TTP (The Technology Partnership) plc 00009 * 00010 ******************************************************************************** 00011 */ 00012 00013 #ifndef BLUETOOTH_H 00014 #define BLUETOOTH_H 00015 00016 //-------- Includes ----------------------------------------------------------// 00017 00018 //-------- Defines -----------------------------------------------------------// 00019 00020 #define SEND_BLE_RESPONSE 0 00021 #define DO_NOT_SEND_BLE_RESPONSE 1 00022 00023 #define UBLOX_BLE_NAME_BYTES 24 00024 #define UBLOX_BLE_FW_VERSION_LEN_BYTES 9 00025 00026 #define UBLOX_DEFAULT_1_BAUD_RATE 115200 00027 #define UBLOX_DEFAULT_2_BAUD_RATE 230400 00028 #define UBLOX_MICRO_BAUD_RATE 230400 //115200 //230400 00029 00030 //-------- Constants & enums -------------------------------------------------// 00031 00032 /** 00033 * @brief Enumeration of the different modes of the Bluetooth state machine 00034 */ 00035 typedef enum 00036 { 00037 UBLOX_IN_CMD_MODE = 0, ///<0 00038 UBLOX_IN_DATA_MODE = 1, ///<1 00039 UBLOX_IN_EDM_MODE = 2, 00040 UBLOX_IN_UPGRADE_MODE = 3, 00041 00042 } ublox_modes_e; 00043 00044 typedef enum 00045 { 00046 //NC = Not Connected 00047 //C = Connected 00048 //A = Active 00049 //NA = Not Active 00050 //E = Error 00051 //NE = No Error 00052 00053 BLE_LINK_A = 0x01, 00054 BLE_LINK_NA = 0x00, 00055 00056 BLE_PEER_C = 0x02, 00057 BLE_PEER_NC = 0x00, 00058 00059 WIFI_LINK_A = 0x04, 00060 WIFI_LINK_NA = 0x00, 00061 00062 WIFI_STATION_C = 0x08, 00063 WIFI_STATION_NC = 0x00, 00064 00065 CLOUD_E = 0x10, 00066 CLOUD_NE = 0x00, 00067 00068 CAP_E = 0x20, 00069 CAP_NE = 0x00 00070 00071 } comms_led_state_e; 00072 00073 /** 00074 * @brief Enumeration of the User to Base Unit BLE primitives. 00075 * Primitives here imply the first byte of a message that is transmitted 00076 */ 00077 typedef enum 00078 { 00079 START_PCR = 'a', ///<a - 0x61 - 97(d) 00080 STOP_PCR = 'b', ///<b - 0x62 - 98(d) 00081 GET_BU_SOFTWARE_DETAILS = 'c', ///<c - 0x63 - 99(d) 00082 GET_CURRENT_PCR_STATE = 'd', ///<d - 0x64 - 100(d) 00083 GET_HEALTH_SENSOR_READINGS = 'e', ///<e - 0x65 - 101(d) 00084 HANDLE_PICTURES = 'f', ///<f - 0x66 - 102(d) 00085 SET_PCR_LED_INTENSITY = 'o', ///<o - 0x6F - 111(d) 00086 RESET_MICRO = '*', ///<* - 0x2a - 42(d) 00087 BLE_HANDSHAKE = '@', ///<@ - 0x40 - 100(d) 00088 TOGGLE_BU_SAFETY_CHECKS = 'z', ///<z - 0x7a - 122(d) 00089 EPOCH_TIMESTAMP = '%', ///<% - 0x25 - 37(d) 00090 ODIN_CHIP_CONTROL = '/' ///</ - 0X2F - 47(d) 00091 00092 } user_to_bu_ble_primitives_e; 00093 00094 /** 00095 * @brief Enumeration of the Base Unit BLE to User primitives. 00096 * Primitives here imply the first byte of a message that is transmitted 00097 */ 00098 typedef enum 00099 { 00100 PCR_STARTED = 'A', ///<A - 0x41 - 65(d) 00101 BASE_UNIT_DETAILS = 'B', ///<B - 0x42 - 66(d) 00102 PCR_CURRENT_STATE = 'C', ///<C - 0x43 - 67(d) 00103 TRIGGER_CAMERA = 'D', ///<D - 0x44 - 68(d) 00104 SENSOR_READINGS = 'E', ///<E - 0x45 - 69(d) 00105 TIMESTAMP_RESPONSE = 'F', ///<F - 0x46 - 70(d) 00106 WIFI_CONFIG_RESP = 'G', ///<G - 0x47 00107 00108 START_OF_BLE_MESSAGE = 'X', ///<X - 0x58 - 88(d) 00109 00110 BASE_UNIT_NOTIFICATION = 'Y', ///<Y - 0x59 - 89(d) 00111 BASE_UNIT_ERROR = 'Z', ///<Z - 0x5A - 90(d) 00112 00113 } bu_to_user_ble_primitives_e; 00114 00115 //-------- Structs & typedefs ------------------------------------------------// 00116 00117 00118 //-------- Global variables --------------------------------------------------// 00119 00120 00121 //-------- Global function prototypes ----------------------------------------// 00122 00123 extern void initialise_ublox_module(void); 00124 extern void reset_ublox_module(void); 00125 extern UART_HandleTypeDef* get_uart3_address(void); 00126 00127 extern uint8_t* get_uart3_tx_buffer(void); 00128 extern void MX_UART3_Init(void); 00129 extern void MX_UART3_DeInit(void); 00130 extern void change_uart3_baud_rate(uint32_t baud_rate); 00131 00132 extern uint8_t is_ublox_module_configured(void); 00133 00134 extern HAL_StatusTypeDef write_bytes_to_ublox_uart3(uint8_t *p_buffer, uint16_t len_bytes); 00135 extern void process_uart3_interrupt_rx_data(void); 00136 extern void process_ublox_uart3_rx_msgs(void); 00137 00138 extern void transmit_picture_req_to_ble_user(uint8_t cycle_no, uint8_t cam_pic_id); 00139 extern void transmit_base_unit_error(uint8_t system_error); 00140 extern void transmit_base_unit_notification(uint8_t system_notification); 00141 00142 extern void process_start_pcr_req(uint8_t output_choice); 00143 extern void process_stop_pcr_req(uint8_t output_choice); 00144 extern void get_bu_software_details(uint8_t output_choice); 00145 extern void get_current_pcr_state(uint8_t output_choice); 00146 extern void transmit_health_sensor_readings(void); 00147 00148 extern void transmit_ublox_config_msg(void); 00149 00150 extern void read_one_byte_from_uart3(void); 00151 00152 extern void change_ublox_current_mode(uint8_t mode); 00153 00154 extern void reset_ublox_rx_buffer(void); 00155 00156 extern void process_ublox_at_event_pkt(const uint8_t* rx_data, uint16_t len_bytes); 00157 00158 extern void set_wifi_link_conn_status(uint8_t status); 00159 00160 extern uint8_t is_wifi_link_connected(void); 00161 00162 extern void set_ble_chan_conn_status(uint8_t status); 00163 00164 extern uint8_t is_ble_chan_connected(void); 00165 00166 extern void set_ble_peer_status(uint8_t status); 00167 00168 extern void set_ble_chan_id(uint8_t chan_id); 00169 00170 extern uint8_t get_ble_chan_id(void); 00171 00172 extern void set_ble_peer_id(uint8_t peer_id); 00173 00174 extern uint8_t get_ble_peer_id(void); 00175 00176 extern uint8_t is_ble_peer_connected(void); 00177 00178 extern uint8_t is_wifi_chan_connected(void); 00179 00180 extern uint8_t is_wifi_peer_connected(void); 00181 00182 extern void set_wifi_chan_id(uint8_t chan_id); 00183 00184 extern uint8_t get_wifi_chan_id(void); 00185 00186 extern void set_wifi_peer_id(uint8_t peer_id); 00187 00188 extern uint8_t get_wifi_peer_id(void); 00189 00190 extern void set_wifi_chan_conn_status(uint8_t status); 00191 00192 extern void set_wifi_peer_status(uint8_t status); 00193 00194 extern void process_ublox_data_event_pkt(const uint8_t* rx_data, uint16_t len_bytes); 00195 00196 extern void send_message_over_ble(const uint8_t* p_message, uint8_t len_bytes); 00197 00198 extern uint8_t update_ublox_firmware(void); 00199 00200 extern uint8_t configure_wifi_link(void); 00201 00202 extern uint8_t activate_wifi_link(void); 00203 00204 extern uint8_t deactivate_wifi_link(void); 00205 00206 extern uint8_t store_wifi_ssid(const char *ssid); 00207 00208 extern uint8_t store_wifi_pwd(const char *pwd); 00209 00210 extern uint8_t write_wifi_details_to_sd(void); 00211 00212 extern uint8_t store_web_addr(const char *web_addr); 00213 00214 extern uint8_t write_web_addr_to_sd(void); 00215 00216 extern const uint8_t* get_ublox_fw_ver_bytes(void); 00217 00218 extern void set_comms_indicator_leds(); 00219 00220 extern void set_cloud_conn_error_status(uint8_t status); 00221 00222 extern void set_capsule_conn_error_status(uint8_t status); 00223 00224 extern void set_wifi_link_active_status(uint8_t status); 00225 00226 extern void read_wifi_details_from_sd(void); 00227 00228 extern void read_cloud_details_from_sd(void); 00229 00230 extern void print_wifi_details(void); 00231 00232 extern void print_cloud_details(void); 00233 00234 //----------------------------------------------------------------------------// 00235 00236 #endif /* BLUETOOTH_H */ 00237
Generated on Wed Jul 13 2022 05:40:26 by
1.7.2