Skip to content

value_to_byte is given a float number #19

@grodino

Description

@grodino

Hi pebblers !

While trying to send a notification (via WebSocketTransport), a problem occured.
When the notification is built, it creates some TimelineItem objects and one of them has a float value. So when it is serialised by PebblePacket.serialize(), Field.value_to_byte() is called and this line breaks :

return struct.pack(str(self.endianness or default_endianness) + self.struct_format, value)

In deed, since the endianness is a little indian < (for this case), it can convert only python int value.

Rigth now I just cast the value into an int and it works perfectly but I don't know if the fact that this float is given is actually a lib problem.

Thanks for your help !

PS : If it can help, here is my code

from libpebble2.communication import PebbleConnection
from libpebble2.communication.transports.websocket import WebsocketTransport
from libpebble2.services.notifications import Notifications

pebble = PebbleConnection(WebsocketTransport("ws://192.168.0.13:9000/"))
pebble.connect()
pebble.run_async()

print(pebble.watch_info.serial)

notif = Notifications(pebble)
notif.send_notification(u'Star Wars', u'Luke, I am your father', u'Dark vador')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions