skraus-dev / cherryrgb-rs

Cherry RGB Keyboard - Multi platform tool to set RGB LEDs for Cherry keyboards
MIT License
40 stars 3 forks source link

RE: Fetch device state #17

Closed skraus-dev closed 1 year ago

skraus-dev commented 1 year ago

The function fetch_device_state (https://github.com/skraus-dev/cherryrgb-rs/blob/master/cherryrgb/src/lib.rs#L246) is currently just replaying captured requests that were sniffed.

Guesses, without having digged deeper into it

Here is a captuire of the transfers:

DEBUG [cherryrgb] >> CONTROL TRANSFER "04010001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
>> Packet { checksum: 1, inner: TransactionStart }

DEBUG [cherryrgb] << INTERRUPT TRANSFER "03050900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
<< Failed to parse, err: bad magic at 0x0: 3

DEBUG [cherryrgb] >> CONTROL TRANSFER "04250003220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
>> Packet { checksum: 37, inner: Unknown3 { unk: 34 } }

DEBUG [cherryrgb] << INTERRUPT TRANSFER "04010001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
<< Packet { checksum: 1, inner: TransactionStart } Checksum valid: Ok(())

DEBUG [cherryrgb] >> CONTROL TRANSFER "043f0007380000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
>> Packet { checksum: 63, inner: Unknown7 { data_len: 56, data_offset: 0 } }

DEBUG [cherryrgb] << INTERRUPT TRANSFER "043f00073800000020002920003520002b200039200200200100a0030020001e20001420000420006420080020003a20001f20001a20001620001d2004002000"
<< Packet { checksum: 63, inner: Unknown7 { data_len: 56, data_offset: 0 } } Checksum valid: Ok(())

DEBUG [cherryrgb] >> CONTROL TRANSFER "04770007383800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
>> Packet { checksum: 119, inner: Unknown7 { data_len: 56, data_offset: 56 } }

DEBUG [cherryrgb] << INTERRUPT TRANSFER "04770007383800003b20002020000820000720001b20000020003c20002120001520000920000620000020003d20002220001720000a20001920008b20003e20"
<< Packet { checksum: 119, inner: Unknown7 { data_len: 56, data_offset: 56 } } Checksum valid: Ok(())

DEBUG [cherryrgb] >> CONTROL TRANSFER "04af0007387000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
>> Packet { checksum: 175, inner: Unknown7 { data_len: 56, data_offset: 112 } }

DEBUG [cherryrgb] << INTERRUPT TRANSFER "04af000738700000002320001c20000b20000520002c20003f20002420001820000d20001120800020004020002520000c20000e20001020008a200041200026"
<< Packet { checksum: 175, inner: Unknown7 { data_len: 56, data_offset: 112 } } Checksum valid: Ok(())

DEBUG [cherryrgb] >> CONTROL TRANSFER "04e7000738a800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
>> Packet { checksum: 231, inner: Unknown7 { data_len: 56, data_offset: 168 } }

DEBUG [cherryrgb] << INTERRUPT TRANSFER "04e7000738a8000020001220000f20003620008820004220002720001320003320003720400020004320002d20002f200034200038a0010020004420002e2000"
<< Packet { checksum: 231, inner: Unknown7 { data_len: 56, data_offset: 168 } } Checksum valid: Ok(())

DEBUG [cherryrgb] >> CONTROL TRANSFER "041f010738e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
>> Packet { checksum: 287, inner: Unknown7 { data_len: 56, data_offset: 224 } }

DEBUG [cherryrgb] << INTERRUPT TRANSFER "041f010738e000003020003220008720006520004520002a20003120002820200020100020004620004920004c20008920000020005020004720004a20004d20"
<< Packet { checksum: 287, inner: Unknown7 { data_len: 56, data_offset: 224 } } Checksum valid: Ok(())

DEBUG [cherryrgb] >> CONTROL TRANSFER "04580007381801000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
>> Packet { checksum: 88, inner: Unknown7 { data_len: 56, data_offset: 280 } }

DEBUG [cherryrgb] << INTERRUPT TRANSFER "0458000738180100000020005220005120004820004b20004e20008520000020004fffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000"
<< Packet { checksum: 88, inner: Unknown7 { data_len: 56, data_offset: 280 } } Checksum valid: Ok(())

DEBUG [cherryrgb] >> CONTROL TRANSFER "048200072a5001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
>> Packet { checksum: 130, inner: Unknown7 { data_len: 42, data_offset: 336 } }

DEBUG [cherryrgb] << INTERRUPT TRANSFER "048200072a500100ffffffffffffffffffffffffff0000ff0000ffffffffffffffffffffffffffffffff0000ffffffffffff0000000000000000000000000000"
<< Packet { checksum: 130, inner: Unknown7 { data_len: 42, data_offset: 336 } } Checksum valid: Ok(())

DEBUG [cherryrgb] >> CONTROL TRANSFER "0453001b380000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
>> Packet { checksum: 83, inner: Unknown1B { data_len: 56, data_offset: 0 } }

DEBUG [cherryrgb] << INTERRUPT TRANSFER "0453001b38000000000102030405060708090a0b0c0d0e0f10111213141516ff18191a1b1cff1e1f202122232425262728292a2b2c2d2e2f3031323334353637"
<< Packet { checksum: 83, inner: Unknown1B { data_len: 56, data_offset: 0 } } Checksum valid: Ok(())

DEBUG [cherryrgb] >> CONTROL TRANSFER "048b001b383800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
>> Packet { checksum: 139, inner: Unknown1B { data_len: 56, data_offset: 56 } }

DEBUG [cherryrgb] << INTERRUPT TRANSFER "048b001b3838000038393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f5051525354555657ff595a5b5cff5e5f6061627bff6500000000000000000000"
<< Packet { checksum: 139, inner: Unknown1B { data_len: 56, data_offset: 56 } } Checksum valid: Ok(())

DEBUG [cherryrgb] >> CONTROL TRANSFER "0499001b0e7000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
>> Packet { checksum: 153, inner: Unknown1B { data_len: 14, data_offset: 112 } }

DEBUG [cherryrgb] << INTERRUPT TRANSFER "0499001b0e7000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
<< Packet { checksum: 153, inner: Unknown1B { data_len: 14, data_offset: 112 } } Checksum valid: Ok(())

DEBUG [cherryrgb] >> CONTROL TRANSFER "04020002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
>> Packet { checksum: 2, inner: TransactionEnd }

DEBUG [cherryrgb] << INTERRUPT TRANSFER "04020002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
<< Packet { checksum: 2, inner: TransactionEnd } Checksum valid: Ok(())
skraus-dev commented 1 year ago

Continuing in issue #19 - as it seems pretty tightly coupled.