I find I’m a little afraid to use AP=1 mode because of the special characters. In AP=2 mode you just escape everything, peachy. I can do that, but it’s killing me. What is AP=1 mode for then?
Does AP=1 mode escape everything for you?
The docs don’t really say, but they imply that in AP=1 mode you don’t worry about the escaping, it just happens or do applications crash if the packet length happens to be 0x11 or 0x7e? How about if the payload contains 0x7e?
If you don’t need to use mode 2, just use mode 1 and trust it. It works just fine. There’s no escape mechanism (explicit or implicit) because none is needed.
You’d need mode 2 if you were using software flow control because then the XON (0x11) and XOFF (0x13) characters have special meanings so they can’t be allowed to appear in the data stream - hence the need to escape them. The escape character is 0x7d, so that needs to be escaped too.
In mode 2 the 0x7e packet header character is also escaped if it appears within the packet or as the checksum. That’s so that if you miss part of a packet or the packet gets corrupted in some way you can still recognise the start of the next packet.