要注重的是校验位的计算,是所有Musical Data 异或后的值,然后拆分转换而来得,假如checksum计算不正确则手机接收后是些非法字符的普通消息。下面的文档中算法很具体。
Header: L35& This is a constant string for all musical tone SMS. [By using 'Send As SMS' option user can send composed Ringer Tone to other compatible Motorola phone. To differentiate Music SMS from Normal SMS, special header is attached.] Tempo Value: This is either 1 or 2 or 3 or 4 followed by a space(e.g. “2 “). Default is 2. Musical Data : It consists of 1 or more notes, subject to a maximum of 35 Notes , the format of which is given below. Delimiter : && This rePResents the end of musical notes in the tone. Checksum : Two bytes. The algorithm for calculation of the checksum is given below.
Step1: Calculate one byte XOR sum of the all the bytes of the musical data starting after the space in the tempo value(not including space) till the && (not inclusive of &&). Let us say this is XY. Step 2: Separate X and Y into two bytes X0 and 0Y. Step 3: Take 0Y and add hex 30. This becomes 3Y. Call this byte 1. Step 4: Take X0 and shift right by 4 bits. This becomes 0X. Step 5: Add hex 30 to 0X. This becomes 3X. Call this byte 2. Step 6: Two byte checksum is <byte 2><byte1>