Skip to content

added security levels to CharacteristicConfig with linux implementation#413

Open
gkong wants to merge 1 commit intotinygo-org:devfrom
gkong:dev
Open

added security levels to CharacteristicConfig with linux implementation#413
gkong wants to merge 1 commit intotinygo-org:devfrom
gkong:dev

Conversation

@gkong
Copy link

@gkong gkong commented Feb 28, 2026

This commit adds a new type - SecurityLevel - and adds instances of it to CharacteristicConfig, for each of: read, write, notify, and indicate.

The default (zero) value is no encryption, so existing user code should be unaffected.

A godoc-visible comment notes that setting a non-default value may result in the peer initiating a pairing operation.

This commit includes a linux implementation which has been tested on Alpine linux. It passes smoketest-linux. If user code specifies a non-default SecurityLevel on any other platform, it will be silently ignored.

Here is a working example CharacteristicConfig which includes a non-default security level:
{
Handle: &rxChx,
UUID: rxUUID,
Flags: bluetooth.CharacteristicWritePermission |
bluetooth.CharacteristicWriteWithoutResponsePermission,
WriteSecurity: bluetooth.SecurityEncryptedAuthenticated,
WriteEvent: func(client bluetooth.Connection, offset int, value []byte) {
fmt.Printf("RX (%d bytes): %s\n", len(value), string(value))
},
}

@gkong
Copy link
Author

gkong commented Feb 28, 2026

i forgot to mention - this pull request addresses issue #72 for the linux platform.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant