Code Monkey home page Code Monkey logo

Comments (5)

Betree avatar Betree commented on May 21, 2024

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?

from magicblue.

orrpan avatar orrpan commented on May 21, 2024

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

from magicblue.

orrpan avatar orrpan commented on May 21, 2024

@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

from magicblue.

orrpan avatar orrpan commented on May 21, 2024

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               ............

from magicblue.

orrpan avatar orrpan commented on May 21, 2024

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?

from magicblue.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.