1| Supported Targets | ESP32-C3 | ESP32-S3 | 2| ----------------- | -------- | -------- | 3 4# ESP-IDF BLE50 Security Server Example 5 6This example shows how to use the APIs to connect in secure manner with peer device and use encryption for data exchange. 7 8To test this example, you can run [ble50_security_client_demo](../ble50_security_client), which starts scanning, connects to and starts encryption with `ble50_sec_gattc_demo` automatically. 9 10Please, check this [tutorial](tutorial/ble50_security_server_Example_Walkthrough.md) for more information about this example. 11 12## How to Use Example 13 14Before project configuration and build, be sure to set the correct chip target using: 15 16```bash 17idf.py set-target <chip_name> 18``` 19There are some important points for this demo: 201.`esp_ble_gap_set_security_param` should be used to set the security parameters in the initial stage; 212.`esp_ble_set_encryption` should be used to start encryption with peer device. If the peer device initiates the encryption, 22 `esp_ble_gap_security_rsp` should be used to send security response to the peer device when `ESP_GAP_BLE_SEC_REQ_EVT` is received. 233.The `ble50_sec_gattc_demo` will receive a `ESP_GAP_BLE_AUTH_CMPL_EVT` once the encryption procedure has completed. 24 25### Hardware Required 26 27* A development board with ESP32-C3 SoC, ESP32-S3 and BLE5.0 supoorted chips. (e.g., ESP32-C3-DevKitC-1, etc.) 28* A USB cable for Power supply and programming 29 30See [Development Boards](https://www.espressif.com/en/products/devkits) for more information about it. 31 32### Build and Flash 33 34Run `idf.py -p PORT flash monitor` to build, flash and monitor the project. 35 36(To exit the serial monitor, type ``Ctrl-]``.) 37 38See the [Getting Started Guide](https://idf.espressif.com/) for full steps to configure and use ESP-IDF to build projects. 39 40## Example Output 41 42``` 43I (363) BTDM_INIT: BT controller compile version [3e61eea] 44I (373) coexist: coexist rom version 8459080 45I (373) phy_init: phy_version 500,985899c,Apr 19 2021,16:05:08 46I (493) system_api: Base MAC address is not set 47I (493) system_api: read default base MAC address from EFUSE 48I (493) BTDM_INIT: Bluetooth MAC: 7c:df:a1:40:01:c5 49 50I (503) SEC_GATTS_DEMO: app_main init bluetooth 51I (523) SEC_GATTS_DEMO: ESP_GATTS_REG_EVT 52I (523) SEC_GATTS_DEMO: The number handle = 8 53I (523) SEC_GATTS_DEMO: ESP_GAP_BLE_SET_LOCAL_PRIVACY_COMPLETE_EVT, tatus = 0 54I (523) SEC_GATTS_DEMO: ESP_GAP_BLE_EXT_ADV_SET_PARAMS_COMPLETE_EVT status 0 55I (533) SEC_GATTS_DEMO: ESP_GAP_BLE_EXT_ADV_DATA_SET_COMPLETE_EVT status 0 56I (543) SEC_GATTS_DEMO: ESP_GAP_BLE_EXT_ADV_START_COMPLETE_EVT, status = 0 57 58``` 59## Troubleshooting 60 61For any technical queries, please open an [issue](https://github.com/espressif/esp-idf/issues) on GitHub. We will get back to you soon. 62