From 8cad456ec8512945442257f98a32c4ec78998005 Mon Sep 17 00:00:00 2001 From: sago35 Date: Fri, 23 Jul 2021 16:36:45 +0900 Subject: [PATCH] WIP rtl8720dn --- adapter_rtl8720dn.go | 28 ++++++++++++++++++++++++++++ gap_rtl8720dn.go | 12 ++++++++++++ gatts_rtl8720dn.go | 17 +++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 adapter_rtl8720dn.go create mode 100644 gap_rtl8720dn.go create mode 100644 gatts_rtl8720dn.go diff --git a/adapter_rtl8720dn.go b/adapter_rtl8720dn.go new file mode 100644 index 0000000..72f53df --- /dev/null +++ b/adapter_rtl8720dn.go @@ -0,0 +1,28 @@ +// +build wioterminal + +package bluetooth + +// Adapter is a dummy adapter: it represents the connection to the (only) +// SoftDevice on the chip. +type Adapter struct { + isDefault bool + scanning bool + charWriteHandlers []charWriteHandler + + connectHandler func(device Addresser, connected bool) +} + +// DefaultAdapter is the default adapter on the current system. On Nordic chips, +// it will return the SoftDevice interface. +// +// Make sure to call Enable() before using it to initialize the adapter. +var DefaultAdapter = &Adapter{isDefault: true, + connectHandler: func(device Addresser, connected bool) { + return + }} + +// Enable configures the BLE stack. It must be called before any +// Bluetooth-related calls (unless otherwise indicated). +func (a *Adapter) Enable() error { + return nil +} diff --git a/gap_rtl8720dn.go b/gap_rtl8720dn.go new file mode 100644 index 0000000..de1cf5c --- /dev/null +++ b/gap_rtl8720dn.go @@ -0,0 +1,12 @@ +// +build wioterminal + +package bluetooth + +// Scan starts a BLE scan. It is stopped by a call to StopScan. A common pattern +// is to cancel the scan when a particular device has been found. +// +// The callback is run on the same goroutine as the Scan function when using a +// SoftDevice. +func (a *Adapter) Scan(callback func(*Adapter, ScanResult)) error { + return nil +} diff --git a/gatts_rtl8720dn.go b/gatts_rtl8720dn.go new file mode 100644 index 0000000..b7fa671 --- /dev/null +++ b/gatts_rtl8720dn.go @@ -0,0 +1,17 @@ +// +build wioterminal + +package bluetooth + +// Characteristic is a single characteristic in a service. It has an UUID and a +// value. +type Characteristic struct { + handle uint16 + permissions CharacteristicPermissions +} + +// charWriteHandler contains a handler->callback mapping for characteristic +// writes. +type charWriteHandler struct { + handle uint16 + callback func(connection Connection, offset int, value []byte) +}