Alejandro Acuña
2024-11-19 72a8eee716de93344f977ab79be7d3bfeb341462
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package art.servers.fleetserver.radio.sepura;
 
import art.servers.fleetserver.Shared;
import art.servers.fleetserver.controller.ControllerRadioSepura;
 
 
public class MOD_10_1243 
{
    
    /** 
     * 7.2.21 +CTSDSR - SDS Received
     * 
     * Description
     *   This unsolicited message carries the contents of a received SDS message
     * 
     * Response
     *   +CTSDSR: <AI service>,[<calling party identity>],[<calling party identity type>],<called party identity>,<called party identity type>,<length>[,<encrypted>]<cr><lf><user data>
     * 
     * Defined values
     *    <AI service> (for Trunked / Direct Mode)
     *      12 SDS type 4
     *      13 Status
     *      108 SDS type 4 (incoming message to MT copied to TE)
     *      109 Status (incoming message to MT copied to TE)
     *      140 SDS Type 4 (outgoing message from MT copied to TE)
     *      141 Status (outgoing message from MT copied to TE)
     * 
     *    <AI service> (for Gateway Mode)
     *      12 SDS type 4 (terminating message)
     *      13 Status (terminating message)
     *      44 SDS type 4 (passing message from DMO to TMO)
     *      45 Status (passing message from DMO to TMO)
     *      76 SDS type 4 (passing message from TMO to DMO)
     *      77 Status (passing message from TMO to DMO)
     * 
     *    <calling party identity>
     *      Calling party identity, format dependant on <calling party identity type >      
     * 
     *    <calling party identity type>
     *      0 SSI
     *      1 TSI
     *      3 PABX external subscriber number
     *      4 E164 external subscriber number    
     * 
     *    <called party identity>
     *      Called party identity, format dependant on <called party identity type >
     * 
     *    <called party identity type>
     *      0 SSI
     *      1 TSI
     * 
     *    <length>
     *      number of bits in the user data.
     * 
     *    <encrypted>
     *      Optional element indicating an encrypted message, set to the value '1'.
     * 
     *    <user data>
     *      Message and SDS-TL header. This is encoded in ASCII Hex
     * 
     *    Example
     *      {0D}{0A}+CTSDSR: 108,214000806014302,1,214000806010005,1,81{0D}{0A}03809BF3B11E401BC8950{0D}{0A}
     */
    
    
    public static CTSDSR CTSDSR(ControllerRadioSepura radio, String command, String data) throws Exception
    {
        String[] parts = command.split(",");
        
        try
        {
            CTSDSR ctsdr = new CTSDSR();
            ctsdr.service = Integer.parseInt(parts[0]);
            ctsdr.callingPartyIdentity = parts[1];
            ctsdr.callingPartyIdentityType =  Integer.parseInt(parts[2]);
            ctsdr.calledPartyIdentity = parts[3];
            ctsdr.calledPartyIdentityType =  Integer.parseInt(parts[4]);
            ctsdr.userData =  data;
            int length = (int)(Math.ceil((double)Integer.parseInt(parts[5]) / 4.0) * 4.0);
 
            if ((data.length() * 4) != length)
            {
                throw new Exception(Shared.configuration.getMessage("Length error") + " [" + command + "]" + "[" + data + "]");
            }
            
            return ctsdr;
        }
        catch (Exception e)
        {
            throw new Exception(Shared.configuration.getMessage("Indication error") + " [" + command + "]" + "[" + data + "]");
        }
    }
    
}