Ankermgmt / ankermake-m5-protocol

Ankermake M5 protocol specifications and libraries *NOT AFFILIATED WITH ANKER*
GNU General Public License v3.0
161 stars 34 forks source link

Changing mqtt padding from zeros to bytes #134

Closed mtoner23 closed 10 months ago

mtoner23 commented 10 months ago

closes #131

Starting with the new firmware releases to anker make printers in the past few weeks, MQTT no longer connects. There is a field in the mqtt msg that expects 11 zeroes. these 11 bytes are no longer all zeroes. I switched the protocol to expect just bytes here since we did nothing with the zeroes to begin with this should be a backwards compatible change.

Pasted below is a snippet from my terminal printing out the padding field. you'll see 2 bytes in the middle of the 11 that are no longer zeros.

[*] Padding: 0x0 0x0 0x0 0x3c 0x11 0x0 0x0 0x0 0x0 0x0 0x0
[*] Padding: 0x0 0x0 0x0 0x95 0x15 0x0 0x0 0x0 0x0 0x0 0x0
[*] Padding: 0x0 0x0 0x0 0xc6 0x20 0x0 0x0 0x0 0x0 0x0 0x0
[*] Padding: 0x0 0x0 0x0 0x5c 0x1d 0x0 0x0 0x0 0x0 0x0 0x0
[*] Padding: 0x0 0x0 0x0 0xa9 0x18 0x0 0x0 0x0 0x0 0x0 0x0
[*] Padding: 0x0 0x0 0x0 0xfa 0xf 0x0 0x0 0x0 0x0 0x0 0x0
[*] Padding: 0x0 0x0 0x0 0x99 0x21 0x0 0x0 0x0 0x0 0x0 0x0
[*] Padding: 0x0 0x0 0x0 0xd6 0x15 0x0 0x0 0x0 0x0 0x0 0x0
[*] Padding: 0x0 0x0 0x0 0x4c 0x9 0x0 0x0 0x0 0x0 0x0 0x0
[*] Padding: 0x0 0x0 0x0 0x3d 0x13 0x0 0x0 0x0 0x0 0x0 0x0
[*] Padding: 0x0 0x0 0x0 0xe3 0xb 0x0 0x0 0x0 0x0 0x0 0x0

Screenshot showing all green on the web ui after my change

image
billyjbryant commented 10 months ago

Can you show the MQTT messages being parsed in the console logs?

mtoner23 commented 10 months ago

If it just leave the printer idling i think it only sends this one mqtt message every 2ish seconds here is output when i run the webserver with -v (post my fix) lmk if you are looking for something else or want me to print other packets

 [*] TOPIC [/phone/maker/AK7ZRG0C35700792/notice]
[D] 4d41b1000501020546c00100c1b9666532333433313666622d336465322d313033382d386237632d66336331346438313835633300000000152000000000000085e2082730b92bc66416309ebde740eca31e05d400a89fc06f72baae857637b7ba677e648ebb884fa5c314bb6f961cf2783e3ec459efd74296d3832f05279e560f8c2bb6299b1c70898e545fc297d7bead290b4fabedfe4867d341a14e15e20299f7993fc2d21b0415fa6146b997c7567a
[D] MQTT message: {'commandType': 1003, 'currentTemp': 2078, 'targetTemp': 0}
[D] MQTT message: {'commandType': 1004, 'currentTemp': 2023, 'targetTemp': 0}
mtoner23 commented 10 months ago

If i undo my changes so mqtt messages can't be parsed here is the new error debug log i added

[E] Failed to decode mqtt message
 Exception: expected set() but found {43}
 Message : 0x4d 0x41 0xb1 0x00 0x05 0x01 0x02 0x05 0x46 0xc0 0x01 0x00 0xa5 0xba 0x66 0x65 0x32 0x33 0x34 0x33 0x31 0x36 0x66 0x62 0x2d 0x33 0x64 0x65 0x32 0x2d 0x31 0x30 0x33 0x38 0x2d 0x38 0x62 0x37 0x63 0x2d 0x66 0x33 0x63 0x31 0x34 0x64 0x38 0x31 0x38 0x35 0x63 0x33 0x00 0x00 0x00 0x00 0x2b 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x85 0xe2 0x08 0x27 0x30 0xb9 0x2b 0xc6 0x64 0x16 0x30 0x9e 0xbd 0xe7 0x40 0xec 0xa3 0x1e 0x05 0xd4 0x00 0xa8 0x9f 0xc0 0x6f 0x72 0xba 0xae 0x85 0x76 0x37 0xb7 0x34 0xc4 0x54 0xe0 0xb4 0x8c 0x1d 0x8c 0x6f 0x03 0x27 0x66 0xd7 0x57 0x17 0x35 0xdf 0x79 0x2a 0x9b 0x3d 0x49 0x22 0x5b 0x76 0x1d 0x10 0x70 0xe2 0x77 0x4f 0xc9 0xba 0xfa 0xd9 0xa1 0x94 0x65 0xf7 0xcf 0x28 0x25 0x90 0x94 0xcc 0xc5 0xc5 0x1b 0x79 0xff 0xdf 0xef 0x05 0xd2 0xb4 0x34 0x77 0xa2 0xde 0x74 0x0f 0x12 0xab 0xd1 0x5b 0x82 0x3f 0xa0 0x6f 0x2b 0x67 0xd5 0xad 0xcb 0xaf 0x1b 0x1f 0xd1 0xab 0xc1 0x9b
mtoner23 commented 10 months ago

Im not familiar with github pull requests, let me know what else i need to do to submit this change

mtoner23 commented 10 months ago

@chrivers can I get your approval here? Are you the only person with write permissions on PRs?

chrivers commented 10 months ago

Sorry for the delay - happy to see @just-trey could step in to help with this :)

I just looked at the MR, and it seems pretty reasonable.

I think this might break sending mqtt messages, since .padding is now a required field without a default value.

Has anyone tried sending an mqtt message with this patch merged?

billyjbryant commented 10 months ago

@chrivers I'll test that this week, need to re-set up my printer

BowlesCR commented 10 months ago

I've pulled from source and confirm the MQTT errors are gone.

I'm still able to remote print and control HD/SD and light on/off -- although I'm not an expert on whether those commands are MQTT or PPPP.

billyjbryant commented 10 months ago

@BowlesCR Are you also able to see the status of both the printer and the active print?

BowlesCR commented 10 months ago

I am, yes. All the stats on the homepage load correctly. Layer count showed 0/0 for several seconds after loading the page, but my guess is that's normal while it waits for the next layer change message.

mtoner23 commented 10 months ago

Hey, good thinking, i think this does indeed break sending mqtt messages. i can push up a fix for that. it changes the constructor for the mqtt message.