21
21
BLEClientDis clientDis;
22
22
BLEClientUart clientUart;
23
23
24
- void setup ()
24
+ void setup ()
25
25
{
26
26
Serial.begin (115200 );
27
27
28
28
Serial.println (" Bluefruit52 Central BLEUART Example" );
29
29
Serial.println (" -----------------------------------" );
30
30
31
- // up to 1 peripheral conn and 1 central conn
31
+ // Enable both peripheral and central
32
32
Bluefruit.begin (true , true );
33
33
Bluefruit.setName (" Bluefruit52" );
34
34
@@ -39,7 +39,7 @@ void setup()
39
39
clientUart.begin ();
40
40
clientUart.setRxCallback (uart_rx_callback);
41
41
42
- // Increase BLink rate to different from PrPh advertising mode
42
+ // Increase Blink rate to different from PrPh advertising mode
43
43
Bluefruit.setConnLedInterval (250 );
44
44
45
45
// Callbacks for Central
@@ -51,6 +51,10 @@ void setup()
51
51
Bluefruit.Central .startScanning ();
52
52
}
53
53
54
+ /* *
55
+ * Callback invoked when scanner pick up an advertising data
56
+ * @param report Structural advertising data
57
+ */
54
58
void scan_callback (ble_gap_evt_adv_report_t * report)
55
59
{
56
60
// Check if advertising contain BleUart service
@@ -65,6 +69,10 @@ void scan_callback(ble_gap_evt_adv_report_t* report)
65
69
}
66
70
}
67
71
72
+ /* *
73
+ * Callback invoked when an connection is established
74
+ * @param conn_handle
75
+ */
68
76
void connect_callback (uint16_t conn_handle)
69
77
{
70
78
Serial.println (" Connected" );
@@ -110,6 +118,11 @@ void connect_callback(uint16_t conn_handle)
110
118
}
111
119
}
112
120
121
+ /* *
122
+ * Callback invoked when a connection is dropped
123
+ * @param conn_handle
124
+ * @param reason
125
+ */
113
126
void disconnect_callback (uint16_t conn_handle, uint8_t reason)
114
127
{
115
128
(void ) conn_handle;
0 commit comments