Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

question: other lights #48

Open
orrpan opened this issue Jan 17, 2019 · 5 comments
Open

question: other lights #48

orrpan opened this issue Jan 17, 2019 · 5 comments

Comments

@orrpan
Copy link

orrpan commented Jan 17, 2019

I'm almost done implementing an other bulb, the functions are of the same but other byte arrays and a little other stuff. For a later pull request, do you prefer a new ....lib.py file so that the repo becomes a more of a python bulbblue package or trying smashing everything into one?

I still have decoding the read response packages and the timer functions.

@orrpan orrpan changed the title other lights question: other lights Jan 17, 2019
@orrpan orrpan closed this as completed Jan 17, 2019
@Betree
Copy link
Owner

Betree commented Jan 17, 2019

Hi @orrpan, having other bulbs supported would be really interesting if you can re-use the existing code to do it 🙂 Can you provide more info about the manufacturer / model?

@orrpan orrpan reopened this Jan 17, 2019
@orrpan
Copy link
Author

orrpan commented Jan 17, 2019

Okey, I’ll make another lib file. Model and brand is unknown, it’s the onces with speaker and rgb light. The most “name” of them that I have figured out is the app name, “My Light”.

I still have the decoding of sound and alarm left.

But all colors, on/off, brightness, effects and white is done (and the algorithm for generating their checksum)

Edit: I’ve not decoded the responses when action is sent. Also when connected it is possible to tigger the bulb to send all current values, this will be done when everything else is done

@orrpan
Copy link
Author

orrpan commented Jan 18, 2019

@Betree I figured out all checksums. Was really easy all bytearrays (2-byte addition) has to be a total value ((256* no_of_byte_in_msg/2)-1), so the "checksum" is the diff that is missing (((256* no_of_byte_in_msg/2)-1)-(msg_sum_2_byte_additon)) mod 256 .

I do have some problem with receiving, the handler 0x000e is the one to read from (with gatttool) but it does not give me any value. I can see in my wireshark log how a response is sent from the bulb at this handler (after an wirte request is done), but it does not seems to stored as "last message".

Any good guesses? I've tried gattool --listen, to see if any response will arrive but no luck. It seems like the answer is sent directly but I'm too slow/not synced to read it.

Snippet from wireshark

No. Time        Source          Destination     Protocol Length Value        Info
1   0.000000    localhost ()    remote ()       ATT      18     55aa000516e5 Sent Write Request, Handle: 0x000c (Unknown)
2   0.014610    controller      host            HCI_EVT  8                   Rcvd Number of Completed Packets
3   0.051736    remote ()       localhost ()    ATT      10                  Rcvd Write Response, Handle: 0x000c (Unknown)
4   0.053509    localhost ()    remote ()       ATT      12                  Sent Read Request, Handle: 0x000e (Unknown)
5   0.070489    controller      host            HCI_EVT  8                   Rcvd Number of Completed Packets
6   0.108053    remote ()       localhost ()    ATT      16     55aa00851764 Rcvd Read Response, Handle: 0x000e (Unknown)

Edit: It is not really necessary to get the response for every packet but for the current status if bulb is disconnected and connected would be good

@orrpan
Copy link
Author

orrpan commented Jan 18, 2019

The whole No 4, Sent Read Req

No.     Time           Source                Destination           Protocol Length Value      Info
      4 0.053509       localhost ()          remote ()             ATT      12                Sent Read Request, Handle: 0x000e (Unknown)

Frame 4: 12 bytes on wire (96 bits), 12 bytes captured (96 bits)
    Encapsulation type: Bluetooth H4 with linux header (99)
    Arrival Time: Jan 17, 2019 17:50:51.082293000 CET
    [Time shift for this packet: 0.000000000 seconds]
    Epoch Time: 1547743851.082293000 seconds
    [Time delta from previous captured frame: 0.001773000 seconds]
    [Time delta from previous displayed frame: 0.001773000 seconds]
    [Time since reference or first frame: 0.053509000 seconds]
    Frame Number: 4
    Frame Length: 12 bytes (96 bits)
    Capture Length: 12 bytes (96 bits)
    [Frame is marked: False]
    [Frame is ignored: False]
    Point-to-Point Direction: Sent (0)
    [Protocols in frame: bluetooth:hci_h4:bthci_acl:btl2cap:btatt]
Bluetooth
    [Source: 00:00:00_00:00:00 (00:00:00:00:00:00)]
    [Destination: 00:00:00_00:00:00 (00:00:00:00:00:00)]
Bluetooth HCI H4
    [Direction: Sent (0x00)]
    HCI Packet Type: ACL Data (0x02)
Bluetooth HCI ACL Packet
    .... 0000 0000 1111 = Connection Handle: 0x00f
    ..00 .... .... .... = PB Flag: First Non-automatically Flushable Packet (0)
    00.. .... .... .... = BC Flag: Point-To-Point (0)
    Data Total Length: 7
    Data
    [Expert Info (Error/Protocol): Frame is out of any "connection handle" session]
        [Frame is out of any "connection handle" session]
        [Severity level: Error]
        [Group: Protocol]
    [Source BD_ADDR: 00:00:00_00:00:00 (00:00:00:00:00:00)]
    [Source Device Name: ]
    [Source Role: Unknown (0)]
    [Destination BD_ADDR: 00:00:00_00:00:00 (00:00:00:00:00:00)]
    [Destination Device Name: ]
    [Destination Role: Unknown (0)]
    [Current Mode: Unknown (-1)]
Bluetooth L2CAP Protocol
    Length: 3
    CID: Attribute Protocol (0x0004)
Bluetooth Attribute Protocol
    Opcode: Read Request (0x0a)
        0... .... = Authentication Signature: False
        .0.. .... = Command: False
        ..00 1010 = Method: Read Request (0x0a)
    Handle: 0x000e (Unknown)
    [Response in Frame: 6]

0000  02 0f 00 07 00 03 00 04 00 0a 0e 00               ............

@orrpan
Copy link
Author

orrpan commented Jan 25, 2019

Up and running, shell works (besides getting any feedback from the bulb...) repo
Home Assistant kinda works, rgb does not for some reason. repo
Don't know if I should just have an own fork or try to merge it, what do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants