Skip to content

Instantly share code, notes, and snippets.

@anisbhsl
Created May 30, 2020 15:41
Show Gist options
  • Save anisbhsl/9787ff74466bdd8951be486b6b4b7989 to your computer and use it in GitHub Desktop.
Save anisbhsl/9787ff74466bdd8951be486b6b4b7989 to your computer and use it in GitHub Desktop.
package service
import "github.com/bettercap/gatt"
var (
attrGAPUUID = gatt.UUID16(0x1800)
attrDeviceNameUUID = gatt.UUID16(0x2A00)
attrAppearanceUUID = gatt.UUID16(0x2A01)
attrPeripheralPrivacyUUID = gatt.UUID16(0x2A02)
attrReconnectionAddrUUID = gatt.UUID16(0x2A03)
attrPeferredParamsUUID = gatt.UUID16(0x2A04)
)
var gapCharAppearanceGenericComputer = []byte{0x00, 0x80}
func NewGapService(name string) *gatt.Service {
s := gatt.NewService(attrGAPUUID)
s.AddCharacteristic(attrDeviceNameUUID).SetValue([]byte(name))
s.AddCharacteristic(attrAppearanceUUID).SetValue(gapCharAppearanceGenericComputer)
s.AddCharacteristic(attrPeripheralPrivacyUUID).SetValue([]byte{0x00})
s.AddCharacteristic(attrReconnectionAddrUUID).SetValue([]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00})
s.AddCharacteristic(attrPeferredParamsUUID).SetValue([]byte{0x06, 0x00, 0x06, 0x00, 0x00, 0x00, 0xd0, 0x07})
return s
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment