Adapting interfaces

This commit is contained in:
2025-11-29 17:42:42 +01:00
parent ea46430b71
commit 848d2758d7
11 changed files with 264 additions and 564 deletions

View File

@@ -19,13 +19,13 @@ type Device interface {
// Peripheral represents the methods used to manage a peripheral (input or output hardware)
type Peripheral interface {
Connect(context.Context) error // Connect the peripheral
SetEventCallback(func(any)) // Callback is called when an event is emitted from the peripheral
Disconnect(context.Context) error // Disconnect the peripheral
Activate(context.Context) error // Activate the peripheral
Deactivate(context.Context) error // Deactivate the peripheral
AddDevice(Device) error // Add a device to the peripheral
RemoveDevice(Device) error // Remove a device to the peripheral
Connect(context.Context) error // Connect the peripheral
// SetEventCallback(func(any)) // Callback is called when an event is emitted from the peripheral
Disconnect(context.Context) error // Disconnect the peripheral
Activate(context.Context) error // Activate the peripheral
Deactivate(context.Context) error // Deactivate the peripheral
// AddDevice(Device) error // Add a device to the peripheral
// RemoveDevice(Device) error // Remove a device to the peripheral
GetSettings() map[string]any // Get the peripheral settings
SetSettings(context.Context, map[string]any) error // Set a peripheral setting
SetDeviceProperty(context.Context, uint32, byte) error // Update a device property
@@ -45,15 +45,11 @@ type PeripheralInfo struct {
// PeripheralFinder represents how compatible peripheral drivers are implemented
type PeripheralFinder interface {
Initialize() error // Initializes the protocol
OnArrival(cb func(p PeripheralInfo)) // Callback function when a peripheral arrives
OnRemoval(cb func(p PeripheralInfo)) // Callback function when a peripheral goes away
Start(context.Context) error // Start the detection
WaitStop() error // Waiting for finder to close
ForceScan() // Explicitly scans for peripherals
RegisterPeripheral(context.Context, PeripheralInfo) (string, error) // Registers a new peripheral data
UnregisterPeripheral(context.Context, PeripheralInfo) error // Unregisters an existing peripheral
GetPeripheralSettings(string) (map[string]any, error) // Gets the peripheral settings
SetPeripheralSettings(context.Context, string, map[string]any) error // Sets the peripheral settings
GetName() string // Get the name of the finder
Initialize() error // Initializes the protocol
Create(ctx context.Context, peripheralInfo PeripheralInfo) (string, error) // Manually create a peripheral
OnArrival(cb func(context.Context, Peripheral)) // Callback function when a peripheral arrives
OnRemoval(cb func(context.Context, Peripheral)) // Callback function when a peripheral goes away
Start(context.Context) error // Start the detection
WaitStop() error // Waiting for finder to close
GetName() string // Get the name of the finder
}