#include "nimble/ble.h" #include "host/ble_hs.h" #include "configuration.h" #define C_WL_MODE_BLE 0b100 #define ENVIRONMENTAL_SENSING_UUID 0x181A #define ES_MEASUREMENT_UUID 0x290C; #define CHAR_CO2_UUID 0x0C39 #define CHAR_TEMP_UUID 0x2A6E #define CHAR_HUM_UUID 0x2A6F #define DEFAULT_NAME "CO2_ble" #define DEFAULT_NAME_LEN 7 #define NIMBLE_LOG_TAG "NIMBLE" uint16_t es_hrm_handle; uint16_t conn_handle; uint8_t notify_state; struct ble_hs_adv_fields adv_fields = { .flags = BLE_HS_ADV_F_DISC_GEN | BLE_HS_ADV_F_BREDR_UNSUP, .tx_pwr_lvl_is_present = 1, .tx_pwr_lvl = BLE_HS_ADV_TX_PWR_LVL_AUTO, .name = (uint8_t*)DEFAULT_NAME, .name_len = DEFAULT_NAME_LEN, .name_is_complete = 1, }; struct ble_gap_adv_params adv_params = { .conn_mode = BLE_GAP_CONN_MODE_UND, .disc_mode = BLE_GAP_DISC_MODE_GEN, }; struct ble_gatt_svc_def gatt_svr_svcs[] = { { // Environmental sensing service .type = BLE_GATT_SVC_TYPE_PRIMARY, .uuid = BLE_UUID16_DECLARE(ENVIRONMENTAL_SENSING_UUID), .characteristics = (struct ble_gatt_chr_def[]){ // CO2 { .uuid = BLE_UUID16_DECLARE(CHAR_CO2_UUID), .access_cb = gatt_svr_chr_access_co2, //.val_handle = &es_hrm_handle, .flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_NOTIFY, }, // TEMP { .uuid = BLE_UUID16_DECLARE(CHAR_TEMP_UUID), .access_cb = gatt_svr_chr_access_temp, .flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_NOTIFY, }, // HUMIDITY { .uuid = BLE_UUID16_DECLARE(CHAR_HUM_UUID), .access_cb = gatt_svr_chr_access_hum, .flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_NOTIFY, }, { 0 }, }, }, { 0 }, }; int ble_gap_event(struct ble_gap_event *event, void* arg); void initBle(configuration_data_t* main_conf);