diff --git a/dep/zesp32-submodule-zsimpleble-server b/dep/zesp32-submodule-zsimpleble-server index 3e867f5..3f34d34 160000 --- a/dep/zesp32-submodule-zsimpleble-server +++ b/dep/zesp32-submodule-zsimpleble-server @@ -1 +1 @@ -Subproject commit 3e867f54332c6cc7e012f1829630b63e6763bccf +Subproject commit 3f34d34e30e2c8e102d20bcd1eb43864b5a12980 diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index a4b8961..2a6cfee 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -1,2 +1,7 @@ -idf_component_register(SRCS "ble_spp_server_demo.c" - INCLUDE_DIRS ".") +idf_component_register(SRCS # + "../dep/zesp32-submodule-zsimpleble-server/zsimpleble_server.c" + "ble_spp_server_demo.c" + "main.c" + INCLUDE_DIRS # + "../dep/" + ".") diff --git a/main/ble_spp_server_demo.c b/main/ble_spp_server_demo.c index 5b6861c..2ad3de8 100644 --- a/main/ble_spp_server_demo.c +++ b/main/ble_spp_server_demo.c @@ -28,7 +28,7 @@ #define SPP_PROFILE_NUM 1 #define SPP_PROFILE_APP_IDX 0 #define ESP_SPP_APP_ID 0x56 -#define SAMPLE_DEVICE_NAME "ZZH_SPP_SERVER" //The Device Name Characteristics in GAP +#define SAMPLE_DEVICE_NAME "ESP_SPP_SERVER" //The Device Name Characteristics in GAP #define SPP_SVC_INST_ID 0 /// SPP Service @@ -49,7 +49,7 @@ static const uint8_t spp_adv_data[23] = { /* Complete List of 16-bit Service Class UUIDs */ 0x03,0x03,0xF0,0xAB, /* Complete Local Name in advertising */ - 0x0F,0x09, 'Z', 'Z', 'H', '_', 'S', 'P', 'P', '_', 'S', 'E', 'R','V', 'E', 'R' + 0x0F,0x09, 'E', 'S', 'P', '_', 'S', 'P', 'P', '_', 'S', 'E', 'R','V', 'E', 'R' }; static uint16_t spp_mtu_size = 23; @@ -565,8 +565,6 @@ static void gatts_profile_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_ } case ESP_GATTS_MTU_EVT: spp_mtu_size = p_data->mtu.mtu; - ESP_LOGI(GATTS_TABLE_TAG, "===========================SET MTU SIZE %d===========================\n",spp_mtu_size); - break; case ESP_GATTS_CONF_EVT: break; @@ -654,7 +652,7 @@ static void gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_ } while (0); } -void app_main(void) +void ble_spp_server_demo_app_main(void) { esp_err_t ret; esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT(); diff --git a/main/ble_spp_server_demo.h b/main/ble_spp_server_demo.h index 15b3b67..62c378c 100644 --- a/main/ble_spp_server_demo.h +++ b/main/ble_spp_server_demo.h @@ -6,7 +6,6 @@ CONDITIONS OF ANY KIND, either express or implied. */ - #include #include #include @@ -18,34 +17,36 @@ //#define SUPPORT_HEARTBEAT //#define SPP_DEBUG_MODE -#define spp_sprintf(s,...) sprintf((char*)(s), ##__VA_ARGS__) -#define SPP_DATA_MAX_LEN (512) -#define SPP_CMD_MAX_LEN (20) -#define SPP_STATUS_MAX_LEN (20) -#define SPP_DATA_BUFF_MAX_LEN (2*1024) -///Attributes State Machine -enum{ - SPP_IDX_SVC, +#define spp_sprintf(s, ...) sprintf((char*)(s), ##__VA_ARGS__) +#define SPP_DATA_MAX_LEN (512) +#define SPP_CMD_MAX_LEN (20) +#define SPP_STATUS_MAX_LEN (20) +#define SPP_DATA_BUFF_MAX_LEN (2 * 1024) +/// Attributes State Machine +enum { + SPP_IDX_SVC, - SPP_IDX_SPP_DATA_RECV_CHAR, - SPP_IDX_SPP_DATA_RECV_VAL, + SPP_IDX_SPP_DATA_RECV_CHAR, + SPP_IDX_SPP_DATA_RECV_VAL, - SPP_IDX_SPP_DATA_NOTIFY_CHAR, - SPP_IDX_SPP_DATA_NTY_VAL, - SPP_IDX_SPP_DATA_NTF_CFG, + SPP_IDX_SPP_DATA_NOTIFY_CHAR, + SPP_IDX_SPP_DATA_NTY_VAL, + SPP_IDX_SPP_DATA_NTF_CFG, - SPP_IDX_SPP_COMMAND_CHAR, - SPP_IDX_SPP_COMMAND_VAL, + SPP_IDX_SPP_COMMAND_CHAR, + SPP_IDX_SPP_COMMAND_VAL, - SPP_IDX_SPP_STATUS_CHAR, - SPP_IDX_SPP_STATUS_VAL, - SPP_IDX_SPP_STATUS_CFG, + SPP_IDX_SPP_STATUS_CHAR, + SPP_IDX_SPP_STATUS_VAL, + SPP_IDX_SPP_STATUS_CFG, #ifdef SUPPORT_HEARTBEAT - SPP_IDX_SPP_HEARTBEAT_CHAR, - SPP_IDX_SPP_HEARTBEAT_VAL, - SPP_IDX_SPP_HEARTBEAT_CFG, + SPP_IDX_SPP_HEARTBEAT_CHAR, + SPP_IDX_SPP_HEARTBEAT_VAL, + SPP_IDX_SPP_HEARTBEAT_CFG, #endif - SPP_IDX_NB, + SPP_IDX_NB, }; + +void ble_spp_server_demo_app_main(void); diff --git a/main/main.c b/main/main.c new file mode 100644 index 0000000..5e19ad0 --- /dev/null +++ b/main/main.c @@ -0,0 +1,14 @@ +#include "esp_log.h" +#include "esp_system.h" +#include "freertos/FreeRTOS.h" +#include "freertos/event_groups.h" +#include "freertos/task.h" +#include "nvs_flash.h" +#include "string.h" +// +#include "ble_spp_server_demo.h" + +void app_main(void) { + ble_spp_server_demo_app_main(); + return; +} diff --git a/main/zsimpleble_server.c b/main/zsimpleble_server.c deleted file mode 100644 index e69de29..0000000 diff --git a/main/zsimpleble_server.h b/main/zsimpleble_server.h deleted file mode 100644 index e69de29..0000000