| 1 | package service |
| 2 | |
| 3 | import ( |
| 4 | "log" |
| 5 | |
| 6 | "github.com/paypal/gatt" |
| 7 | ) |
| 8 | |
| 9 | var ( |
| 10 | attrGATTUUID = gatt.UUID16(0x1801) |
| 11 | attrServiceChangedUUID = gatt.UUID16(0x2A05) |
| 12 | ) |
| 13 | |
| 14 | // NOTE: OS X provides GAP and GATT services, and they can't be customized. |
| 15 | // For Linux/Embedded, however, this is something we want to fully control. |
| 16 | func NewGattService() *gatt.Service { |
| 17 | s := gatt.NewService(attrGATTUUID) |
| 18 | s.AddCharacteristic(attrServiceChangedUUID).HandleNotifyFunc( |
| 19 | func(r gatt.Request, n gatt.Notifier) { |
| 20 | go func() { |
| 21 | log.Printf("TODO: indicate client when the services are changed") |
| 22 | }() |
| 23 | }) |
| 24 | return s |
| 25 | } |