1 #ifndef _PY_MODBLE_H_ 2 #define _PY_MODBLE_H_ 3 4 #include <aos/ble.h> 5 #include <atomic.h> 6 #include <ble_netconfig.h> 7 #include <bluetooth/bluetooth.h> 8 #include <bluetooth/gatt.h> 9 #include <bluetooth/uuid.h> 10 #include <netmgr.h> 11 #include <netmgr_wifi.h> 12 13 #include "ulog/ulog.h" 14 15 // #define WIFI_DEV_PATH "/dev/wifi0" 16 17 // typedef struct amp_wifi_info { 18 // char ssid[128]; 19 // char mac[6]; 20 // char ip[16]; 21 // int rssi; 22 // } amp_wifi_info_t; 23 24 // enum ble_err { 25 // BLE_ERR_NONE = 0, 26 // BLE_ERR_NET_DEV = -1, 27 // BLE_ERR_NET_IFCONFIG, 28 // BLE_ERR_NET_AP_CNT_INVALID, 29 // BLE_ERR_NET_CONFIG, 30 // BLE_ERROR_NET_AP_CNT_INVALID, 31 // }; 32 33 enum ble_event { 34 BLE_EVENT_NET_STATUS = 0, 35 BLE_EVENT_CHARA_WRITTEN, 36 BLE_EVENT_MAX 37 }; 38 39 typedef struct { 40 char *dev_name; 41 uint16_t conn_num_max; 42 } amp_bt_host_adapter_init_t; 43 44 typedef struct { 45 int32_t type; 46 char *adv_data; 47 char *scan_rsp_data; 48 int32_t interval_min; 49 int32_t interval_max; 50 int32_t channel_map; 51 } amp_bt_host_adapter_adv_start_t; 52 53 typedef struct { 54 int32_t type; 55 uint16_t interval; 56 uint16_t window; 57 } amp_bt_host_adapter_scan_start_t; 58 59 typedef struct { 60 const char *char_uuid; 61 const char *permission; 62 const char *descr_uuid; 63 const char *descr_type; 64 } amp_bt_host_adapter_gatt_chars_t; 65 66 typedef struct { 67 char *s_uuid; 68 uint32_t attr_cnt; 69 amp_bt_host_adapter_gatt_chars_t *chars; 70 } amp_bt_host_adapter_gatts_srvc_t; 71 72 typedef struct { 73 size_t len; 74 uint8_t *data; 75 } amp_bt_gatts_adapter_usr_data_t; 76 77 // GAP 78 int py_bt_host_adapter_init(amp_bt_host_adapter_init_t *init); 79 int bt_host_adapter_start_adv(amp_bt_host_adapter_adv_start_t *adv_param); 80 int bt_host_adapter_stop_adv(void); 81 // GATTS 82 void native_bt_host_gatts_handle_write(uint8_t data[], size_t len); 83 int bt_gatts_adapter_add_service(amp_bt_host_adapter_gatts_srvc_t *srvc); 84 int bt_gatts_adapter_update_chars(char *uuid, uint8_t *data, size_t len); 85 86 #endif 87