added local time characteristic #4
@ -33,6 +33,7 @@ const (
|
||||
MotionValChar = "00030002-78fc-48fe-8e23-433b3a1942d0"
|
||||
FirmwareVerChar = "00002a26-0000-1000-8000-00805f9b34fb"
|
||||
CurrentTimeChar = "00002a2b-0000-1000-8000-00805f9b34fb"
|
||||
LocalTimeChar = "00002a0f-0000-1000-8000-00805f9b34fb"
|
||||
BatteryLvlChar = "00002a19-0000-1000-8000-00805f9b34fb"
|
||||
HeartRateChar = "00002a37-0000-1000-8000-00805f9b34fb"
|
||||
FSTransferChar = "adaf0200-4669-6c65-5472-616e73666572"
|
||||
@ -47,6 +48,7 @@ var charNames = map[string]string{
|
||||
MotionValChar: "Motion Values",
|
||||
FirmwareVerChar: "Firmware Version",
|
||||
CurrentTimeChar: "Current Time",
|
||||
LocalTimeChar: "Local Time",
|
||||
BatteryLvlChar: "Battery Level",
|
||||
HeartRateChar: "Heart Rate",
|
||||
FSTransferChar: "Filesystem Transfer",
|
||||
@ -62,6 +64,7 @@ type Device struct {
|
||||
motionValChar *gatt.GattCharacteristic1
|
||||
fwVersionChar *gatt.GattCharacteristic1
|
||||
currentTimeChar *gatt.GattCharacteristic1
|
||||
localTimeChar *gatt.GattCharacteristic1
|
||||
battLevelChar *gatt.GattCharacteristic1
|
||||
heartRateChar *gatt.GattCharacteristic1
|
||||
fsVersionChar *gatt.GattCharacteristic1
|
||||
@ -406,6 +409,8 @@ func (i *Device) resolveChars() error {
|
||||
i.fwVersionChar = char
|
||||
case CurrentTimeChar:
|
||||
i.currentTimeChar = char
|
||||
case LocalTimeChar:
|
||||
i.localTimeChar = char
|
||||
case BatteryLvlChar:
|
||||
i.battLevelChar = char
|
||||
case HeartRateChar:
|
||||
@ -711,6 +716,23 @@ func (i *Device) SetTime(t time.Time) error {
|
||||
return i.currentTimeChar.WriteValue(buf.Bytes(), nil)
|
||||
}
|
||||
|
||||
// SetTimezone sets the watch's timezone information using the Local Time Service
|
||||
func (i *Device) SetTimezone(t time.Time) error {
|
||||
if err := i.checkStatus(i.localTimeChar, LocalTimeChar); err != nil {
|
||||
return err
|
||||
}
|
||||
_, offset := t.Zone()
|
||||
dst := 0
|
||||
if t.IsDST() {
|
||||
dst = 3600
|
||||
offset = offset - 3600
|
||||
}
|
||||
buf := &bytes.Buffer{}
|
||||
binary.Write(buf, binary.LittleEndian, uint8(offset / 3600 * 4))
|
||||
binary.Write(buf, binary.LittleEndian, uint8(dst / 3600 * 4))
|
||||
return i.localTimeChar.WriteValue(buf.Bytes(), nil)
|
||||
}
|
||||
|
||||
// Notify sends a notification to InfiniTime via
|
||||
// the Alert Notification Service (ANS)
|
||||
func (i *Device) Notify(title, body string) error {
|
||||
|
Reference in New Issue
Block a user