USSD encode/decode review
The 3GPP USSD operations performed by ModemManager require the input user-provided command to be ENCODED in a given encoding, and the network-originated responses DECODED from a given encoding.
Right now, the different protocol implementations doing these operations are quite different and assume different things. E.g.:
- MBIM: The
ussd_encode()
andussd_decode()
methods inmm-broadband-modem-mbim.c
assume that we need to support both UCS-2 and packed GSM-7 encodings. - QMI: The
ussd_encode()
andussd_decode()
methods inmm-broadband-modem-qmi.c
assume that we need to support both UCS-2 and ASCII encodings. - AT: The
modem_3gpp_ussd_encode()
method inmm-broadband-modem.c
says that we need to encode the string passed to the modem in the specific charset configured in the modem (AT+CSCS) but in HEX representation, BUT then we provide also hint of what the encoding to use in the network should be (either UCS-2 or ASCII). - AT: The
modem_3gpp_ussd_decode()
method inmm-broadband-modem.c
expects the modem-returned string in HEX representation and encoded in the specific charset configured in the modem (AT+CSCS). - Huawei: The
encode()
anddecode()
methods in mm-broadband-modem-huawei.c assume the strings passed from/to the modem are packed GSM-7 in HEX representation, regardless of what the charset configured in the modem is.
This all seems a mess. E.g. open questions:
- Could it be that the QMI implementation should really expect GSM-7 instead of ASCII, to be in line with the others?
- Should the Huawei implementation also support UCS-2 at least for the responses that cannot be encoded in GSM-7?
- Is it really that Huawei uses packed GSM-7 unconditionally regardless of the current configured charset?
- Does the logic in the AT implementation of the decoding make sense?; i.e. are we really providing the charset hint to use in the network communication in the correct way. E.g. if the modem configured charset is UCS2 but the text can be encoded in GSM-7, we would be running AT+CUSD with the user string in HEX formatted UCS-2 but then saying that the hint is GSM-7. Really?
We should give a look at all this, looking at:
- the 3GPP specs for USSD (TS 22.090, TS 24.090, TS 24.390)
- the generic 3GPP +CUSD spec (TS 27.007)
- the cell broadcast data coding scheme specs (TS 23.038)