Created
May 30, 2020 15:41
-
-
Save anisbhsl/9787ff74466bdd8951be486b6b4b7989 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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