345 lines
9.0 KiB
Java
345 lines
9.0 KiB
Java
package com.safemobile.lib;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import com.safemobile.lib.radio.Channel;
|
|
import com.safemobile.lib.radio.Emerg;
|
|
import com.safemobile.lib.radio.IncCall;
|
|
import com.safemobile.lib.radio.RadioGW;
|
|
import com.safemobile.lib.radio.RadioStatus;
|
|
import com.safemobile.lib.radio.SUstatus;
|
|
import com.safemobile.lib.radio.Zone;
|
|
import com.safemobile.lib.radio.Zone_and_channel;
|
|
|
|
public class RadioMSG extends TCPmsg {
|
|
|
|
public int rOpcode;
|
|
public String payload="";
|
|
public ArrayList<RadioGW> RadioGWList=null;
|
|
|
|
//zone and channel;
|
|
public Zone_and_channel zac= null;
|
|
|
|
//radio status
|
|
public RadioStatus rStatus = null;
|
|
|
|
//SU stauts
|
|
public SUstatus suStatus = null;
|
|
|
|
//Incomming call
|
|
public IncCall incCall = null;
|
|
|
|
//Emerg
|
|
public Emerg emerg = null;
|
|
|
|
// Contacts list
|
|
public ArrayList<Contact> contacts;
|
|
|
|
|
|
public RadioMSG(TCPmsg tcp) {
|
|
super(tcp);
|
|
String date4parsing = super.data;
|
|
|
|
String[] arr = date4parsing.split("#");
|
|
|
|
rOpcode = Integer.parseInt(arr[0]);
|
|
payload = arr[1];
|
|
|
|
switch(rOpcode)
|
|
{
|
|
case 200:
|
|
{
|
|
RadioGWList = new ArrayList<RadioGW>();
|
|
String[] tempArr = payload.split(";");
|
|
|
|
int count = 0;
|
|
for(int i =0; i<tempArr.length;i++)
|
|
{
|
|
String[] oneRadio = tempArr[i].split("&");
|
|
|
|
if(oneRadio.length<5)
|
|
continue;
|
|
RadioGW rgw = new RadioGW();
|
|
|
|
rgw.ID = Integer.parseInt(oneRadio[0]);
|
|
rgw.GW_ID = Integer.parseInt(oneRadio[1]);
|
|
rgw.IMEI = oneRadio[2];
|
|
rgw.IP = oneRadio[3];
|
|
|
|
String zonelistStr =oneRadio[4];
|
|
String[] zoneArr = zonelistStr.split("@");
|
|
for(int j =0; j<zoneArr.length;j++)
|
|
{
|
|
Zone zon = new Zone();
|
|
String[] oneZoneArr = zoneArr[j].split(":");
|
|
|
|
//TODO check what this values are from SD
|
|
zon.dbID = Integer.parseInt(oneZoneArr[0]);
|
|
zon.id = Integer.parseInt(oneZoneArr[1]);
|
|
zon.ZoneName = oneZoneArr[2];
|
|
String channelListStr = oneZoneArr[3];
|
|
|
|
String[] channelArr = channelListStr.split(",");
|
|
for(int k =0; k < channelArr.length; k++)
|
|
{
|
|
Channel chn = new Channel();
|
|
String[] oneChnArr = channelArr[k].split("/");
|
|
chn.dbID = Integer.parseInt(oneChnArr[0]);
|
|
chn.id = Integer.parseInt(oneChnArr[1]);
|
|
chn.chName = oneChnArr[2];
|
|
|
|
//add channel to zone
|
|
zon.channelList.add(chn);
|
|
}
|
|
|
|
//add zone to radio GW
|
|
rgw.zoneList.add(zon);
|
|
}
|
|
|
|
RadioGWList.add(rgw);
|
|
count++;
|
|
}
|
|
count +=this.RadioGWList.size();
|
|
SM.Debug("radio","RadioGWList size:" +this.RadioGWList.size() + " total:" +count);
|
|
break;
|
|
}
|
|
case OperationCodes.CHANNEL_BRDCST:
|
|
{
|
|
try {
|
|
zac = new Zone_and_channel();
|
|
String[] tempArr = payload.split("&");
|
|
|
|
String[] gwID_and_rgwID = tempArr[0].split("/");
|
|
zac.gwID = Integer.parseInt(gwID_and_rgwID[0]);
|
|
zac.rgwID = Integer.parseInt(gwID_and_rgwID[1]);
|
|
|
|
String[] zoneNr_and_channelNr = tempArr[1].split("/");
|
|
zac.zoneNr = Integer.parseInt(zoneNr_and_channelNr[0]);
|
|
zac.channelNr = Integer.parseInt(zoneNr_and_channelNr[1]);
|
|
} catch (Exception e) {
|
|
SM.Debug("Cmd 204 error:"+e.toString());
|
|
}
|
|
break;
|
|
}
|
|
|
|
case OperationCodes.RADIO_STATUS_REP:
|
|
{
|
|
try {
|
|
rStatus = new RadioStatus();
|
|
String[] tempArr = payload.split("&");
|
|
|
|
if(tempArr.length == 4 || tempArr.length == 5) {
|
|
rStatus.status = 1;
|
|
rStatus.incCall.callStatus = Integer.parseInt(tempArr[0]);
|
|
rStatus.incCall.callType = Integer.parseInt(tempArr[1]);
|
|
rStatus.incCall.Imei = Integer.parseInt(tempArr[2]);
|
|
rStatus.incCall.callerID = Integer.parseInt(tempArr[2]);
|
|
rStatus.incCall.groupId = Integer.parseInt(tempArr[3]);
|
|
rStatus.incCall.callDestID = Integer.parseInt(tempArr[3]);
|
|
|
|
if(tempArr.length == 5)
|
|
rStatus.incCall.userID = Integer.parseInt(tempArr[4]);
|
|
}
|
|
else {
|
|
String[] gwID_and_rgwID = tempArr[0].split("/");
|
|
rStatus.gwID = Integer.parseInt(gwID_and_rgwID[0]);
|
|
rStatus.rgwID = Integer.parseInt(gwID_and_rgwID[1]);
|
|
rStatus.status = Integer.parseInt(tempArr[1]);
|
|
}
|
|
} catch (Exception e) {
|
|
SM.Debug("Cmd 199 error:"+e.toString());
|
|
}
|
|
break;
|
|
}
|
|
|
|
case 250:
|
|
{
|
|
try {
|
|
suStatus = new SUstatus();
|
|
String[] tempArr = payload.split("&");
|
|
|
|
suStatus.imei = Integer.parseInt(tempArr[0]);
|
|
|
|
suStatus.status = Integer.parseInt(tempArr[1]);
|
|
} catch (Exception e) {
|
|
SM.Debug("Cmd 250 error:"+e.toString());
|
|
}
|
|
break;
|
|
}
|
|
|
|
case 125:
|
|
case OperationCodes.CALL_STATUS_BRDCST:
|
|
{
|
|
try {
|
|
incCall = new IncCall();
|
|
incCall.opCode = rOpcode;
|
|
String[] tempArr = payload.split("&");
|
|
|
|
String[] gwID_and_rgwID_imei = tempArr[0].split("/");
|
|
incCall.gwID = Integer.parseInt(gwID_and_rgwID_imei[0]);
|
|
incCall.rgwID = Integer.parseInt(gwID_and_rgwID_imei[1]);
|
|
incCall.Imei = Long.parseLong(gwID_and_rgwID_imei[2]);
|
|
|
|
incCall.callStatus = Integer.parseInt(tempArr[1]);
|
|
incCall.callType = Integer.parseInt(tempArr[2]);
|
|
incCall.groupId = Integer.parseInt(tempArr[3]);
|
|
incCall.userID = Integer.parseInt(tempArr[4]);
|
|
} catch (Exception e) {
|
|
SM.Debug("Cmd 125, 126 error:"+e.toString());
|
|
}
|
|
break;
|
|
}
|
|
|
|
case 121:
|
|
case 122:
|
|
case 123:
|
|
{
|
|
try {
|
|
incCall = new IncCall();
|
|
incCall.opCode = rOpcode;
|
|
|
|
incCall.callStatus = Integer.parseInt(payload.substring(payload.length()-1, payload.length()));
|
|
|
|
} catch (Exception e) {
|
|
SM.Debug("Cmd 121, 122, 123 error:"+e.toString());
|
|
}
|
|
/*
|
|
try {
|
|
System.out.println("############ tmpARR: " + payload );
|
|
incCall = new IncCall();
|
|
incCall.opCode = rOpcode;
|
|
String[] tempArr = payload.split("&");
|
|
|
|
String[] gwID_and_rgwID_imei = tempArr[0].split("/");
|
|
incCall.gwID = Integer.parseInt(gwID_and_rgwID_imei[0]);
|
|
incCall.rgwID = Integer.parseInt(gwID_and_rgwID_imei[1]);
|
|
|
|
incCall.callStatus = Integer.parseInt(tempArr[1]);
|
|
|
|
incCall.callType = Integer.parseInt(tempArr[2]);
|
|
|
|
incCall.groupId = Integer.parseInt(tempArr[3]);
|
|
} catch (Exception e) {
|
|
SM.Debug("Cmd 121, 122, 123 error:"+e.toString());
|
|
}
|
|
*/
|
|
break;
|
|
}
|
|
|
|
case 115:
|
|
case 116:
|
|
case 117:
|
|
{
|
|
|
|
try {
|
|
incCall = new IncCall();
|
|
incCall.opCode = rOpcode;
|
|
|
|
incCall.callStatus = Integer.parseInt(payload.substring(payload.length()-1, payload.length()));
|
|
|
|
} catch (Exception e) {
|
|
SM.Debug("Cmd 115,116,117 error:"+e.toString());
|
|
}
|
|
break;
|
|
|
|
/*
|
|
try {
|
|
incCall = new IncCall();
|
|
String[] tempArr = payload.split("&");
|
|
incCall.opCode = rOpcode;
|
|
String[] gwID_and_rgwID_imei = tempArr[0].split("/");
|
|
incCall.gwID = Integer.parseInt(gwID_and_rgwID_imei[0]);
|
|
incCall.rgwID = Integer.parseInt(gwID_and_rgwID_imei[1]);
|
|
|
|
incCall.callStatus = 3;
|
|
|
|
incCall.callType = Integer.parseInt(tempArr[2]);
|
|
|
|
incCall.groupId = Integer.parseInt(tempArr[3]);
|
|
} catch (Exception e) {
|
|
SM.Debug("Cmd 115, 116, 117 error:"+e.toString());
|
|
}
|
|
|
|
break;
|
|
*/
|
|
}
|
|
|
|
case OperationCodes.CALL_TYPE_REP:
|
|
{
|
|
|
|
try {
|
|
incCall = new IncCall();
|
|
incCall.opCode = rOpcode;
|
|
String[] tempArr = payload.split("/");
|
|
incCall.callType = Integer.parseInt(tempArr[0]);
|
|
incCall.callStatus = Integer.parseInt(tempArr[1]);
|
|
|
|
SM.Debug("GOT CHANGE CALL TYPE MSG", incCall.opCode + " # " + incCall.callType + " # " + incCall.callStatus);
|
|
} catch (Exception e) {
|
|
SM.Debug("Cmd 115,116,117 error:"+e.toString());
|
|
}
|
|
break;
|
|
}
|
|
|
|
case 172:
|
|
{
|
|
|
|
try {
|
|
incCall = new IncCall();
|
|
incCall.opCode = rOpcode;
|
|
String[] tempArr = payload.split("/");
|
|
incCall.mic = new Mic();
|
|
incCall.mic.mic_type = Integer.parseInt(tempArr[0]);
|
|
incCall.mic.signal_type = Integer.parseInt(tempArr[1]);
|
|
incCall.mic.mic_state = Integer.parseInt(tempArr[2]);
|
|
incCall.mic.mic_gain = Integer.parseInt(tempArr[3]);
|
|
|
|
SM.Debug("GOT Mic state changed", incCall.opCode + " # " + incCall.mic.mic_state);
|
|
} catch (Exception e) {
|
|
SM.Debug("Cmd 172 error:"+e.toString());
|
|
}
|
|
break;
|
|
}
|
|
|
|
case OperationCodes.EMERGENCY_REP:
|
|
{
|
|
try {
|
|
emerg = new Emerg();
|
|
String[] tempArr = payload.split("/");
|
|
|
|
emerg.function = Integer.parseInt(tempArr[0]);
|
|
emerg.status = Integer.parseInt(tempArr[1]);
|
|
|
|
// emerg.userID = Integer.parseInt(tempArr[2]);
|
|
} catch (Exception e) {
|
|
SM.Debug("Cmd 230 error:"+e.toString());
|
|
}
|
|
break;
|
|
}
|
|
|
|
/*
|
|
case OperationCodes.CONTACTS_REP:
|
|
{
|
|
try
|
|
{
|
|
SM.Debug("Parsing Contacts");
|
|
contacts = Contact.parseTCPMsg(payload);
|
|
}
|
|
catch(Exception ex)
|
|
{
|
|
SM.Exception("Exception parse Contacts", ex.toString());
|
|
}
|
|
break;
|
|
}
|
|
*/
|
|
|
|
default:
|
|
break;
|
|
}
|
|
|
|
//SM.Debug("RadioMSG", "Done parsing");
|
|
|
|
}
|
|
|
|
}
|