Commit a2bea34ac114e5b37dfb3b61612dc2e2a9112bd9

Authored by lawrencehj
1 parent 616e1be0

增加上级平台查询DeviceInfo和DeviceStatus的响应功能

src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommanderForPlatform.java
... ... @@ -42,4 +42,23 @@ public interface ISIPCommanderForPlatform {
42 42 * @return
43 43 */
44 44 boolean catalogQuery(DeviceChannel channel, ParentPlatform parentPlatform, String sn, String fromTag, int size);
  45 +
  46 + /**
  47 + * 向上级回复DeviceInfo查询信息
  48 + * @param parentPlatform 平台信息
  49 + * @param sn
  50 + * @param fromTag
  51 + * @return
  52 + */
  53 + boolean deviceInfoResponse(ParentPlatform parentPlatform, String sn, String fromTag);
  54 +
  55 + /**
  56 + * 向上级回复DeviceStatus查询信息
  57 + * @param parentPlatform 平台信息
  58 + * @param sn
  59 + * @param fromTag
  60 + * @return
  61 + */
  62 + boolean deviceStatusResponse(ParentPlatform parentPlatform, String sn, String fromTag);
  63 +
45 64 }
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java
... ... @@ -118,7 +118,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
118 118 try {
119 119  
120 120 StringBuffer keepaliveXml = new StringBuffer(200);
121   - keepaliveXml.append("<?xml version=\"1.0\"?>\r\n");//" encoding=\"GB2312\"?>\r\n");
  121 + keepaliveXml.append("<?xml version=\"1.0\"?>\r\n");
122 122 keepaliveXml.append("<Notify>\r\n");
123 123 keepaliveXml.append("<CmdType>Keepalive</CmdType>\r\n");
124 124 keepaliveXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n");
... ... @@ -217,4 +217,72 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
217 217 }
218 218 return true;
219 219 }
  220 +
  221 + /**
  222 + * 向上级回复DeviceInfo查询信息
  223 + * @param parentPlatform 平台信息
  224 + * @param sn
  225 + * @param fromTag
  226 + * @return
  227 + */
  228 + @Override
  229 + public boolean deviceInfoResponse(ParentPlatform parentPlatform, String sn, String fromTag) {
  230 + if (parentPlatform == null) {
  231 + return false;
  232 + }
  233 + try {
  234 + StringBuffer deviceInfoXml = new StringBuffer(600);
  235 + deviceInfoXml.append("<?xml version=\"1.0\" encoding=\"GB2312\"?>\r\n");
  236 + deviceInfoXml.append("<Response>\r\n");
  237 + deviceInfoXml.append("<CmdType>DeviceInfo</CmdType>\r\n");
  238 + deviceInfoXml.append("<SN>" +sn + "</SN>\r\n");
  239 + deviceInfoXml.append("<DeviceID>" + parentPlatform.getDeviceGBId() + "</DeviceID>\r\n");
  240 + deviceInfoXml.append("<DeviceName>GB28181 Video Platform</DeviceName>\r\n");
  241 + deviceInfoXml.append("<Manufacturer>Manufacturer</Manufacturer>\r\n");
  242 + deviceInfoXml.append("<Model>wvp-28181</Model>\r\n");
  243 + deviceInfoXml.append("<Firmware>2.0.202103</Firmware>\r\n");
  244 + deviceInfoXml.append("<Result>OK</Result>\r\n");
  245 + deviceInfoXml.append("</Response>\r\n");
  246 + Request request = headerProviderPlarformProvider.createMessageRequest(parentPlatform, deviceInfoXml.toString(), fromTag);
  247 + transmitRequest(parentPlatform, request);
  248 +
  249 + } catch (SipException | ParseException | InvalidArgumentException e) {
  250 + e.printStackTrace();
  251 + return false;
  252 + }
  253 + return true;
  254 + }
  255 +
  256 + /**
  257 + * 向上级回复DeviceStatus查询信息
  258 + * @param parentPlatform 平台信息
  259 + * @param sn
  260 + * @param fromTag
  261 + * @return
  262 + */
  263 + @Override
  264 + public boolean deviceStatusResponse(ParentPlatform parentPlatform, String sn, String fromTag) {
  265 + if (parentPlatform == null) {
  266 + return false;
  267 + }
  268 + try {
  269 + StringBuffer deviceStatusXml = new StringBuffer(600);
  270 + deviceStatusXml.append("<?xml version=\"1.0\" encoding=\"GB2312\"?>\r\n");
  271 + deviceStatusXml.append("<Response>\r\n");
  272 + deviceStatusXml.append("<CmdType>DeviceStatus</CmdType>\r\n");
  273 + deviceStatusXml.append("<SN>" +sn + "</SN>\r\n");
  274 + deviceStatusXml.append("<DeviceID>" + parentPlatform.getDeviceGBId() + "</DeviceID>\r\n");
  275 + deviceStatusXml.append("<Result>OK</Result>\r\n");
  276 + deviceStatusXml.append("<Online>ONLINE</Online>\r\n");
  277 + deviceStatusXml.append("<Status>OK</Status>\r\n");
  278 + deviceStatusXml.append("</Response>\r\n");
  279 + Request request = headerProviderPlarformProvider.createMessageRequest(parentPlatform, deviceStatusXml.toString(), fromTag);
  280 + transmitRequest(parentPlatform, request);
  281 +
  282 + } catch (SipException | ParseException | InvalidArgumentException e) {
  283 + e.printStackTrace();
  284 + return false;
  285 + }
  286 + return true;
  287 + }
220 288 }
... ...