File tree Expand file tree Collapse file tree 15 files changed +30
-56
lines changed Expand file tree Collapse file tree 15 files changed +30
-56
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,6 @@ const debug = false
66// SetConnectHandler sets a handler function to be called whenever the adaptor connects
77// or disconnects. You must call this before you call adaptor.Connect() for centrals
88// or adaptor.Start() for peripherals in order for it to work.
9- func (a * Adapter ) SetConnectHandler (c func (device Addresser , connected bool )) {
9+ func (a * Adapter ) SetConnectHandler (c func (device Address , connected bool )) {
1010 a .connectHandler = c
1111}
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ type Adapter struct {
2424 // used to allow multiple callers to call Connect concurrently.
2525 connectMap sync.Map
2626
27- connectHandler func (device Addresser , connected bool )
27+ connectHandler func (device Address , connected bool )
2828}
2929
3030// DefaultAdapter is the default adapter on the system.
@@ -35,7 +35,7 @@ var DefaultAdapter = &Adapter{
3535 pm : cbgo .NewPeripheralManager (nil ),
3636 connectMap : sync.Map {},
3737
38- connectHandler : func (device Addresser , connected bool ) {
38+ connectHandler : func (device Address , connected bool ) {
3939 return
4040 },
4141}
Original file line number Diff line number Diff line change @@ -19,15 +19,15 @@ type Adapter struct {
1919 cancelChan chan struct {}
2020 defaultAdvertisement * Advertisement
2121
22- connectHandler func (device Addresser , connected bool )
22+ connectHandler func (device Address , connected bool )
2323}
2424
2525// DefaultAdapter is the default adapter on the system. On Linux, it is the
2626// first adapter available.
2727//
2828// Make sure to call Enable() before using it to initialize the adapter.
2929var DefaultAdapter = & Adapter {
30- connectHandler : func (device Addresser , connected bool ) {
30+ connectHandler : func (device Address , connected bool ) {
3131 return
3232 },
3333}
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ func handleEvent() {
4848 switch id {
4949 case C .BLE_GAP_EVT_CONNECTED :
5050 currentConnection .Reg = gapEvent .conn_handle
51- DefaultAdapter .connectHandler (nil , true )
51+ DefaultAdapter .connectHandler (Address {} , true )
5252 case C .BLE_GAP_EVT_DISCONNECTED :
5353 if defaultAdvertisement .isAdvertising .Get () != 0 {
5454 // The advertisement was running but was automatically stopped
@@ -60,7 +60,7 @@ func handleEvent() {
6060 defaultAdvertisement .start ()
6161 }
6262 currentConnection .Reg = C .BLE_CONN_HANDLE_INVALID
63- DefaultAdapter .connectHandler (nil , false )
63+ DefaultAdapter .connectHandler (Address {} , false )
6464 case C .BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST :
6565 // Respond with the default PPCP connection parameters by passing
6666 // nil:
Original file line number Diff line number Diff line change @@ -36,14 +36,14 @@ func handleEvent() {
3636 println ("evt: connected in peripheral role" )
3737 }
3838 currentConnection .Reg = gapEvent .conn_handle
39- DefaultAdapter .connectHandler (nil , true )
39+ DefaultAdapter .connectHandler (Address {} , true )
4040 case C .BLE_GAP_ROLE_CENTRAL :
4141 if debug {
4242 println ("evt: connected in central role" )
4343 }
4444 connectionAttempt .connectionHandle = gapEvent .conn_handle
4545 connectionAttempt .state .Set (2 ) // connection was successful
46- DefaultAdapter .connectHandler (nil , true )
46+ DefaultAdapter .connectHandler (Address {} , true )
4747 }
4848 case C .BLE_GAP_EVT_DISCONNECTED :
4949 if debug {
@@ -66,7 +66,7 @@ func handleEvent() {
6666 // necessary.
6767 C .sd_ble_gap_adv_start (defaultAdvertisement .handle , C .BLE_CONN_CFG_TAG_DEFAULT )
6868 }
69- DefaultAdapter .connectHandler (nil , false )
69+ DefaultAdapter .connectHandler (Address {} , false )
7070 case C .BLE_GAP_EVT_ADV_REPORT :
7171 advReport := gapEvent .params .unionfield_adv_report ()
7272 if debug && & scanReportBuffer .data [0 ] != advReport .data .p_data {
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ func handleEvent() {
3333 println ("evt: connected in peripheral role" )
3434 }
3535 currentConnection .Reg = gapEvent .conn_handle
36- DefaultAdapter .connectHandler (nil , true )
36+ DefaultAdapter .connectHandler (Address {} , true )
3737 case C .BLE_GAP_EVT_DISCONNECTED :
3838 if debug {
3939 println ("evt: disconnected" )
@@ -49,7 +49,7 @@ func handleEvent() {
4949 // necessary.
5050 C .sd_ble_gap_adv_start (defaultAdvertisement .handle , C .BLE_CONN_CFG_TAG_DEFAULT )
5151 }
52- DefaultAdapter .connectHandler (nil , false )
52+ DefaultAdapter .connectHandler (Address {} , false )
5353 case C .BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST :
5454 // We need to respond with sd_ble_gap_data_length_update. Setting
5555 // both parameters to nil will make sure we send the default values.
Original file line number Diff line number Diff line change @@ -49,15 +49,15 @@ type Adapter struct {
4949 scanning bool
5050 charWriteHandlers []charWriteHandler
5151
52- connectHandler func (device Addresser , connected bool )
52+ connectHandler func (device Address , connected bool )
5353}
5454
5555// DefaultAdapter is the default adapter on the current system. On Nordic chips,
5656// it will return the SoftDevice interface.
5757//
5858// Make sure to call Enable() before using it to initialize the adapter.
5959var DefaultAdapter = & Adapter {isDefault : true ,
60- connectHandler : func (device Addresser , connected bool ) {
60+ connectHandler : func (device Address , connected bool ) {
6161 return
6262 }}
6363
Original file line number Diff line number Diff line change @@ -12,14 +12,14 @@ import (
1212type Adapter struct {
1313 watcher * advertisement.BluetoothLEAdvertisementWatcher
1414
15- connectHandler func (device Addresser , connected bool )
15+ connectHandler func (device Address , connected bool )
1616}
1717
1818// DefaultAdapter is the default adapter on the system.
1919//
2020// Make sure to call Enable() before using it to initialize the adapter.
2121var DefaultAdapter = & Adapter {
22- connectHandler : func (device Addresser , connected bool ) {
22+ connectHandler : func (device Address , connected bool ) {
2323 return
2424 },
2525}
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ func main() {
3939 neo .Configure (machine.PinConfig {Mode : machine .PinOutput })
4040 ws = ws2812 .New (neo )
4141
42- adapter .SetConnectHandler (func (d bluetooth.Addresser , c bool ) {
42+ adapter .SetConnectHandler (func (d bluetooth.Address , c bool ) {
4343 connected = c
4444
4545 if ! connected && ! disconnected {
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ func main() {
2121 must ("config adv" , adv .Configure (bluetooth.AdvertisementOptions {
2222 LocalName : "Go Bluetooth" ,
2323 }))
24- adapter .SetConnectHandler (func (device bluetooth.Addresser , connected bool ) {
24+ adapter .SetConnectHandler (func (device bluetooth.Address , connected bool ) {
2525 if connected {
2626 println ("connected, not advertising..." )
2727 advState = false
You can’t perform that action at this time.
0 commit comments