Skip to content

Commit 4c0df28

Browse files
aykevldeadprogram
authored andcommitted
nrf: fix CGo errors after TinyGo update
For details, see: tinygo-org/tinygo#2774
1 parent e758117 commit 4c0df28

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

adapter_sd.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ import (
1010
"unsafe"
1111
)
1212

13+
// #include "ble.h"
14+
// #ifdef NRF51
15+
// #include "nrf_soc.h"
16+
// #else
17+
// #include "nrf_nvic.h"
18+
// #endif
19+
import "C"
20+
1321
var (
1422
ErrNotDefaultAdapter = errors.New("bluetooth: not the default adapter")
1523
)

gattc_sd.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func (d *Device) DiscoverServices(uuids []UUID) ([]DeviceService, error) {
134134

135135
// Store the discovered service.
136136
svc := DeviceService{
137-
uuid: suuid,
137+
uuid: shortUUID(suuid),
138138
connectionHandle: d.connectionHandle,
139139
startHandle: startHandle,
140140
endHandle: endHandle,
@@ -276,7 +276,7 @@ func (s *DeviceService) DiscoverCharacteristics(uuids []UUID) ([]DeviceCharacter
276276
permissions |= CharacteristicIndicatePermission
277277
}
278278

279-
dc := DeviceCharacteristic{uuid: discoveringCharacteristic.uuid}
279+
dc := DeviceCharacteristic{uuid: shortUUID(discoveringCharacteristic.uuid)}
280280
dc.permissions = permissions
281281
dc.valueHandle = foundCharacteristicHandle
282282

gatts_sd.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package bluetooth
88
#define SVCALL_AS_NORMAL_FUNCTION
99
1010
#include "ble_gap.h"
11+
#include "ble_gatts.h"
1112
*/
1213
import "C"
1314

uuid_sd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func (s shortUUID) UUID() UUID {
3939
// IsIn checks the passed in slice of short UUIDs to see if this uuid is in it.
4040
func (s shortUUID) IsIn(uuids []C.ble_uuid_t) bool {
4141
for _, u := range uuids {
42-
if u == s {
42+
if shortUUID(u) == s {
4343
return true
4444
}
4545
}

0 commit comments

Comments
 (0)