+CMGL: 0,1,“”,48\r\n07912180958739F1040B917120069876F000009140503223218A21D4F29C0E6A97E7F3F0B90CA2BF41412A68F86EB7C36E32885A9ED3CB72\r\n
+CMGL: 1,1,“”,40\r\n07912180958739F1040B917120069876F000009140503223438A17D4F29C9E769F4141EA6AD83C3241C377BB1D769341\r\n
+CMGL: 2,1,“”,38\r\n07912180958739F1040B917120069876F000009140503233048A15D272980C0AB3D9A069730A6A97E7F3F0B93C07\r\n
OK
Do not split at \n (or more precisely to \r\n), split at +CMGL:
Array obtained afer filtering out the last two characters (\r\n) and the end OK at the same time:
0,1,“”,48\r\n07912180958739F1040B917120069876F000009140503223218A21D4F29C0E6A97E7F3F0B90CA2BF41412A68F86EB7C36E32885A9ED3CB72
1,1,“”,40\r\n07912180958739F1040B917120069876F000009140503223438A17D4F29C9E769F4141EA6AD83C3241C377BB1D769341
2,1,“”,38\r\n07912180958739F1040B917120069876F000009140503233048A15D272980C0AB3D9A069730A6A97E7F3F0B93C07
Using :toarray on each line can be possible have one
array of arrays: on each array the 1st value (0) is the index number, the 2nd (1) the message status, the 3rd (2) the used memory, and on the 4th (3) the PDU message.
and now is possible to create a function that replace the PDU with one array with converted PDU contents.
the PDU start with the DECIMAL number total PDU length, the \r\n and the hex code of the PDU. The length of the hex code is the double of the decimal number that represent each hex pair.
example of one SMS array inside the main array
48\r\n07912180958739F1040B917120069876F000009140503223218A21D4F29C0E6A97E7F3F0B90CA2BF41412A68F86EB7C36E32885A9ED3CB72
==>>
+12085978931 ; SMS-DELIVER ; +17026089670 ; GSM-7 ; 19-04-05 23:32:12 TZ GMT-7 ; 21 ; “Test message to AT Command Tester”
07 91 2180958739F1 (sms center, length [7 x 2 bytes] and international format, F is a filler without value)
PDU HEADER: 04 (SMS-DELIVER)
TP-OA: 0B 91 7120069876F0 (sender number length [B = 11 characters] and international format, F is a filler without value)
TP-PID: 00 (message class 0)
TP-DCS: 00 (message text on GSM-7 format)
TP-SCTS 9140503223218A (date and time) (19-04-05 23:32:12 TZ GMT-7 [negative timezone and 28 “times” 15 minutes = 420 minutes = 7 hours ] )
TP-UDL: 21 (message lenght on septept, because is on GSM-7 format. Are octects if the mesage is on UCS-2)
TP-UD: D4F29C0E6A97E7F3F0B90CA2BF41412A68F86EB7C36E32885A9ED3CB72
(message encoded on octect, but internally is on septept for GSM-7, is on octect if is ASCII-8 or UCS-2)
Decode the GSM-7 or eventually the UCS-2 part is easy with my already existent functions.
Function to convert Hex GSM7 to CP1252 string (for decode the PDU message part on GSM7)
http://forum.mikrotik.com/t/rextended-fragments-of-snippets/151033/1
Function to convert UCS-2 to UTF-8 (for decode the PDU message part on UCS-2)
http://forum.mikrotik.com/t/convert-any-text-to-unicode/164329/18