1 #ifndef _UART_CLIENT_H 2 #define _UART_CLIENT_H 3 4 #include <aos/ble.h> 5 #include <stdio.h> 6 #include "yoc/uart_profile.h" 7 8 typedef struct client_config { 9 uint8_t conn_def_on; 10 uint8_t auto_conn_mac_size; 11 dev_addr_t *auto_conn_mac; 12 dev_addr_t temp_conn_dev_set; 13 conn_param_t *temp_conn_param; 14 } client_config; 15 16 typedef struct _uart_profile_handler { 17 dev_addr_t peer_addr; 18 uint8_t notify_enabled; 19 uint16_t uart_handle; 20 uint16_t uart_end_handle; 21 uint16_t uart_char_handle; 22 uint16_t uart_ccc_handle; 23 } uart_profile_handler; 24 25 typedef struct _uart_client { 26 client_config client_conf; 27 uart_profile_handler uart_profile; 28 } uart_client; 29 30 typedef struct _ble_uart_client_t { 31 int16_t conn_handle; 32 //uint16_t uart_svc_handle; 33 uart_rx_data_cb uart_recv; 34 ble_event_cb uart_event_callback; 35 conn_param_t *conn_param; 36 uint8_t conn_update_def_on: 1; 37 uint8_t update_param_flag: 1; 38 uint8_t mtu_exchanged: 1; 39 uint16_t mtu; 40 uart_client client_data; 41 } ble_uart_client_t; 42 43 44 uart_handle_t uart_client_init(ble_uart_client_t *service); 45 int uart_client_scan_start(); 46 dev_addr_t *found_dev_get(); 47 int uart_client_conn(dev_addr_t *conn_mac, conn_param_t *conn_param); 48 int uart_client_disconn(uart_handle_t handle); 49 int uart_client_send(uart_handle_t handle, const char *data, int length, bt_uart_send_cb *cb); 50 int uart_client_conn_param_update(uart_handle_t handle, conn_param_t *param); 51 52 #endif 53 54