Skip to content

Commit ad04b6a

Browse files
committed
familiarization demo code
part 3
1 parent 84be8ac commit ad04b6a

File tree

5 files changed

+30
-5
lines changed

5 files changed

+30
-5
lines changed

.vscode/settings.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
22
"idf.adapterTargetName": "esp32",
33
"idf.port": "/dev/ttyUSB0",
4-
"idf.flashType": "UART"
4+
"idf.flashType": "UART",
5+
"files.associations": {
6+
"regex": "cpp"
7+
}
58
}

links

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ github.com/espressif/esp-idf/blob/master/examples/bluetooth/nimble/bleprph/main/
55
mynewt.apache.org/latest/network/ble_hs/ble_att.html
66
docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/bluetooth/nimble.index.html
77
https://iotespresso.com/esp32-nimble-how-to-send-notifications/
8+
https://embeddedartistry.com/blog/2017/05/01/mixing-c-and-c-extern-c/

main/gap.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ static void bleprhp_advertise(void){
3535

3636
/*Begin advertising*/
3737
memset(&adv_params, 0, sizeof(adv_params));
38-
//TODO
38+
//undirected-connectable
3939
adv_params.conn_mode = BLE_GAP_CONN_MODE_UND;
40+
//general-discoverable
4041
adv_params.disc_mode = BLE_GAP_DISC_MODE_GEN;
4142
rc = ble_gap_adv_start(bleprhp_addr_type, NULL, BLE_HS_FOREVER, &adv_params, bleprhp_gap_event, NULL);
4243
if (rc != 0){
@@ -62,7 +63,7 @@ static int bleprhp_gap_event(struct ble_gap_event *event, void *arg){
6263
bleprhp_advertise();
6364
break;
6465
case BLE_GAP_EVENT_ADV_COMPLETE:
65-
//TODO
66+
//means advertising has been completed because connection has been established
6667
ESP_LOGI(tag, "adv complete\n");
6768
bleprhp_advertise();
6869
break;

main/gatt.cpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,27 @@ int gatt_svr_init(void){
77
ble_svc_gatt_init();
88

99
//TODO
10-
rc = ble_gatts_count_cfg(gatt_svr_srvcs);
10+
/*Adjusts a host configuration object's settings to accommodate the specified
11+
service definition array. This function adds the counts to the appropriate
12+
fields in the supplied configuration object without clearing them first, so
13+
it can be called repeatedly with different inputs to calculate totals. Be
14+
sure to zero the GATT server settings prior to the first call to this
15+
function.*/
16+
/*rc = ble_gatts_count_cfg(gatt_svr_svcs);
17+
if (rc != 0) {
18+
return rc;
19+
}*/
1120

21+
/*
22+
Queues a set of service definitions for registration. All services queued
23+
in this manner get registered when ble_gatts_start() is called.
24+
*/
25+
/*rc = ble_gatts_add_svcs(gatt_svr_svcs);
26+
if (rc != 0) {
27+
return rc;
28+
}*/
29+
30+
ble_gatts_start();
31+
32+
return 0;
1233
}

main/main.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ extern "C" void app_main(void)
3737
/*Security Manager Remote Key Distribution Mask*/
3838
ble_hs_cfg.sm_their_key_dist = 1;
3939

40-
//TODO
4140
rc = gatt_svr_init();
4241
assert(rc == 0);
4342

0 commit comments

Comments
 (0)