@ -601,8 +601,15 @@ public class run_device_cfg implements ActionListener, ListSelectionListener {
@@ -601,8 +601,15 @@ public class run_device_cfg implements ActionListener, ListSelectionListener {
} else if ( EM_DEVICE_CFG_TYPE . DEVICE_CFG_SOC_CONSTANT_LAMP = = command )
{
stu = new NetStructs . STU_CFG_SOC_CONSTANT_LAMP_PARAM ( ) ;
} else if ( EM_DEVICE_CFG_TYPE . DEVICE_CFG_HTTP_REVERSE_REGISTER = = command )
{
stu = new NetStructs . STU_CFG_HTTP_REGISTER_PARAM ( ) ;
} else if ( EM_DEVICE_CFG_TYPE . DEVICE_CFG_AUTO_REGISTER = = command )
{
stu = new NetStructs . STU_CFG_AUTO_REGISTER_PARAM ( ) ;
}
return stu ;
}
@ -3770,6 +3777,70 @@ public class run_device_cfg implements ActionListener, ListSelectionListener {
@@ -3770,6 +3777,70 @@ public class run_device_cfg implements ActionListener, ListSelectionListener {
return ftpCfg ;
}
public void getHttpCfg ( NativeLong loginID ) {
int nCommand = EM_DEVICE_CFG_TYPE . DEVICE_CFG_NET_STORAGE_TRANS ;
STU_CFG_NET_STORAGE_TRANS stuCfgNetStorageTrans = getStuCfgNetStorageTrans ( loginID , nCommand ) ;
System . out . println ( "======================" ) ;
System . out . println ( "count=" + stuCfgNetStorageTrans . uItemCount ) ;
for ( int i = 0 ; i < stuCfgNetStorageTrans . uItemCount ; i + + )
{
STU_CFG_NET_STORAGE_TRANS_ITEM stuItem = stuCfgNetStorageTrans . stuItemArray [ i ] ;
String ftpValue = DataUtils . sdk_data_byteArrayToString ( stuItem . szProtocol , GlobalTool . getEncodeType ( ) ) ;
System . out . println ( "-----------------------" ) ;
System . out . println ( "name=" + ftpValue ) ;
System . out . println ( "bOfflineEnable=" + stuItem . bOfflineEnable ) ;
System . out . println ( "address=" + DataUtils . sdk_data_byteArrayToString ( stuItem . szAddress , GlobalTool . getEncodeType ( ) ) ) ;
}
}
public void addHttpCfg ( NativeLong loginID , String szAddress ) {
int nCommand = EM_DEVICE_CFG_TYPE . DEVICE_CFG_NET_STORAGE_TRANS ;
STU_CFG_NET_STORAGE_TRANS stuCfgNetStorageTrans = getStuCfgNetStorageTrans ( loginID , nCommand ) ;
System . out . println ( "========== addHttpCfg ============" ) ;
System . out . println ( JSON . toJSON ( stuCfgNetStorageTrans ) ) ;
System . out . println ( "======================" ) ;
boolean flag = false ;
for ( int i = 0 ; i < stuCfgNetStorageTrans . uItemCount ; i + + )
{
STU_CFG_NET_STORAGE_TRANS_ITEM stuItem = stuCfgNetStorageTrans . stuItemArray [ i ] ;
String ftpValue = DataUtils . sdk_data_byteArrayToString ( stuItem . szProtocol , GlobalTool . getEncodeType ( ) ) ;
if ( "HttpClient" . equalsIgnoreCase ( ftpValue ) ) {
flag = true ;
stuCfgNetStorageTrans . stuItemArray [ i ] . szAddress = DataUtils . sdk_data_stringToByteArray ( szAddress , GlobalTool . getEncodeType ( ) ) ;
stuCfgNetStorageTrans . stuItemArray [ i ] . bOfflineEnable = 1 ;
}
}
if ( ! flag ) {
STU_CFG_NET_STORAGE_TRANS_ITEM httpCfg = new STU_CFG_NET_STORAGE_TRANS_ITEM ( ) ;
httpCfg . szProtocol = DataUtils . sdk_data_stringToByteArray ( "HttpClient" , GlobalTool . getEncodeType ( ) ) ;
httpCfg . szAddress = DataUtils . sdk_data_stringToByteArray ( szAddress , GlobalTool . getEncodeType ( ) ) ;
httpCfg . bOfflineEnable = 1 ;
stuCfgNetStorageTrans . uItemCount = stuCfgNetStorageTrans . uItemCount + 1 ;
stuCfgNetStorageTrans . stuItemArray [ stuCfgNetStorageTrans . uItemCount ] = httpCfg ;
}
IntByReference inBufferSize = new IntByReference ( 0 ) ;
inBufferSize . setValue ( stuCfgNetStorageTrans . size ( ) ) ;
Pointer ptrInBuffer = DataUtils . sdk_data_createPtr ( inBufferSize . getValue ( ) ) ;
DataUtils . sdk_data_structureToPtr ( stuCfgNetStorageTrans , ptrInBuffer , 0 ) ;
boolean bResult2 = NetLib . instance . Net_SetDeviceCfg (
loginID ,
nCommand ,
0 ,
ptrInBuffer ,
inBufferSize . getValue ( ) ,
6000 ) ;
if ( ! bResult2 )
{
int error = NetLib . instance . Net_LastError ( ) ;
String strError = String . format ( "Net_setAutoRegister fail, command = %d, errorCode = %d" , nCommand , error ) ;
System . out . println ( "修改失败" ) ;
System . out . println ( strError ) ;
}
System . out . println ( "执行结束" ) ;
}
//获取自动重启配置
public STU_CFG_AUTO_MAINTAIN getAutoCfg ( NativeLong loginID , int nCommand ) {
@ -3846,4 +3917,226 @@ public class run_device_cfg implements ActionListener, ListSelectionListener {
@@ -3846,4 +3917,226 @@ public class run_device_cfg implements ActionListener, ListSelectionListener {
System . out . println ( stuCfgAutoMaintain ) ;
return R . ok ( ) ;
}
public Map < String , Object > getHttpReverseRegister ( NativeLong loginID ) {
int nCommand = EM_DEVICE_CFG_TYPE . DEVICE_CFG_HTTP_REVERSE_REGISTER ;
NetStructs . STU_CFG_HTTP_REGISTER_PARAM cfg = getCfgHttpReverseRegister ( loginID , nCommand ) ;
System . out . println ( JSON . toJSON ( cfg ) ) ;
// 0:禁用,1:启用
int bEnable = cfg . bEnable ;
//心跳地址
String heartUrl = DataUtils . sdk_data_byteArrayToString ( cfg . szMessageURL , GlobalTool . getEncodeType ( ) ) ;
//推图地址
String pushPicUrl = DataUtils . sdk_data_byteArrayToString ( cfg . szPushPictureURL , GlobalTool . getEncodeType ( ) ) ;
//心跳间隔,单位秒
int heartbeatInterval = cfg . nHeartbeatInterval ;
Map < String , Object > map = new HashMap < > ( ) ;
map . put ( "bEnable" , bEnable ) ;
map . put ( "heartUrl" , heartUrl ) ;
map . put ( "pushPicUrl" , pushPicUrl ) ;
map . put ( "heartbeatInterval" , heartbeatInterval ) ;
return map ;
}
public R setHttpReverseRegister ( NativeLong loginID , int bEnable , String heartUrl , String pushPicUrl , int heartbeatInterval ) {
int nCommand = EM_DEVICE_CFG_TYPE . DEVICE_CFG_HTTP_REVERSE_REGISTER ;
NetStructs . STU_CFG_HTTP_REGISTER_PARAM cfg = getCfgHttpReverseRegister ( loginID , nCommand ) ;
cfg . bEnable = bEnable ;
cfg . szMessageURL = DataUtils . sdk_data_stringToByteArray ( heartUrl , GlobalTool . getEncodeType ( ) ) ; ;
cfg . szPushPictureURL = DataUtils . sdk_data_stringToByteArray ( pushPicUrl , GlobalTool . getEncodeType ( ) ) ; ;
cfg . nHeartbeatInterval = heartbeatInterval ;
IntByReference inBufferSize = new IntByReference ( 0 ) ;
inBufferSize . setValue ( cfg . size ( ) ) ;
Pointer ptrInBuffer = DataUtils . sdk_data_createPtr ( inBufferSize . getValue ( ) ) ;
DataUtils . sdk_data_structureToPtr ( cfg , ptrInBuffer , 0 ) ;
boolean bResult2 = NetLib . instance . Net_SetDeviceCfg (
loginID ,
nCommand ,
0 ,
ptrInBuffer ,
inBufferSize . getValue ( ) ,
6000 ) ;
if ( ! bResult2 )
{
int error = NetLib . instance . Net_LastError ( ) ;
String strError = String . format ( "Net_setHttpReverseRegister fail, command = %d, errorCode = %d" , nCommand , error ) ;
System . out . println ( strError ) ;
return R . error ( 500 , strError ) ;
}
return R . ok ( ) ;
}
public R initHttpReverseRegister ( NativeLong loginID ) {
int nCommand = EM_DEVICE_CFG_TYPE . DEVICE_CFG_HTTP_REVERSE_REGISTER ;
NetStructs . STU_CFG_HTTP_REGISTER_PARAM cfg = getCfgHttpReverseRegister ( loginID , nCommand ) ;
cfg . bEnable = 1 ;
cfg . szMessageURL = DataUtils . sdk_data_stringToByteArray ( "http://121.40.203.197/control-api/api/camera/heart" , GlobalTool . getEncodeType ( ) ) ; ;
cfg . szPushPictureURL = DataUtils . sdk_data_stringToByteArray ( "http://121.40.203.197/control-api/api/getPicJson" , GlobalTool . getEncodeType ( ) ) ; ;
cfg . nHeartbeatInterval = 50 ;
IntByReference inBufferSize = new IntByReference ( 0 ) ;
inBufferSize . setValue ( cfg . size ( ) ) ;
Pointer ptrInBuffer = DataUtils . sdk_data_createPtr ( inBufferSize . getValue ( ) ) ;
DataUtils . sdk_data_structureToPtr ( cfg , ptrInBuffer , 0 ) ;
boolean bResult2 = NetLib . instance . Net_SetDeviceCfg (
loginID ,
nCommand ,
0 ,
ptrInBuffer ,
inBufferSize . getValue ( ) ,
6000 ) ;
if ( ! bResult2 )
{
int error = NetLib . instance . Net_LastError ( ) ;
String strError = String . format ( "Net_setHttpReverseRegister fail, command = %d, errorCode = %d" , nCommand , error ) ;
System . out . println ( strError ) ;
return R . error ( 500 , strError ) ;
}
return R . ok ( ) ;
}
public R clearHttpReverseRegister ( NativeLong loginID ) {
int nCommand = EM_DEVICE_CFG_TYPE . DEVICE_CFG_HTTP_REVERSE_REGISTER ;
NetStructs . STU_CFG_HTTP_REGISTER_PARAM cfg = getCfgHttpReverseRegister ( loginID , nCommand ) ;
cfg . bEnable = 1 ;
cfg . szMessageURL = new byte [ 256 ] ; ;
cfg . szPushPictureURL = new byte [ 256 ] ;
cfg . nHeartbeatInterval = 50 ;
IntByReference inBufferSize = new IntByReference ( 0 ) ;
inBufferSize . setValue ( cfg . size ( ) ) ;
Pointer ptrInBuffer = DataUtils . sdk_data_createPtr ( inBufferSize . getValue ( ) ) ;
DataUtils . sdk_data_structureToPtr ( cfg , ptrInBuffer , 0 ) ;
boolean bResult2 = NetLib . instance . Net_SetDeviceCfg (
loginID ,
nCommand ,
0 ,
ptrInBuffer ,
inBufferSize . getValue ( ) ,
6000 ) ;
if ( ! bResult2 )
{
int error = NetLib . instance . Net_LastError ( ) ;
String strError = String . format ( "Net_setHttpReverseRegister fail, command = %d, errorCode = %d" , nCommand , error ) ;
System . out . println ( strError ) ;
return R . error ( 500 , strError ) ;
}
return R . ok ( ) ;
}
public NetStructs . STU_CFG_HTTP_REGISTER_PARAM getCfgHttpReverseRegister ( NativeLong loginID , int nCommand ) {
IntByReference outBufferSize = new IntByReference ( 0 ) ;
IntByReference nReturnSize = new IntByReference ( 0 ) ;
Pointer ptrOutBuffer = initStuData ( nCommand , outBufferSize ) ;
boolean bResult = NetLib . instance . Net_GetDeviceCfg (
loginID ,
nCommand ,
0 ,
ptrOutBuffer ,
outBufferSize . getValue ( ) ,
nReturnSize ,
6000 ) ;
if ( ! bResult )
{
int error = NetLib . instance . Net_LastError ( ) ;
String strError = String . format ( "Net_HttpReverseRegisterCfg fail, command = %d, errorCode = %d" , nCommand , error ) ;
System . out . println ( strError ) ;
return null ;
}
NetStructs . STU_CFG_HTTP_REGISTER_PARAM cfg = new NetStructs . STU_CFG_HTTP_REGISTER_PARAM ( ) ;
DataUtils . sdk_data_ptrToStructure ( ptrOutBuffer , cfg ) ;
return cfg ;
}
public Map < String , Object > getAutoRegister ( NativeLong loginID ) {
int nCommand = EM_DEVICE_CFG_TYPE . DEVICE_CFG_AUTO_REGISTER ;
STU_CFG_AUTO_REGISTER_PARAM cfg = getAutoRegister ( loginID , nCommand ) ;
System . out . println ( JSON . toJSON ( cfg ) ) ;
// 0:禁用,1:启用
// int bEnable = cfg.bEnable;
// //服务器地址
// String serverAddress = DataUtils.sdk_data_byteArrayToString(cfg.szServerAddress, GlobalTool.getEncodeType());
// //端口号
// int port = cfg.nPort;
// Map<String, Object> map = new HashMap<>();
// map.put("bEnable",bEnable);
// map.put("serverAddress",serverAddress);
// map.put("port",port);
// return map;
return null ;
}
public R setAutoRegister ( NativeLong loginID , int bEnable , String serverAddress , int port ) {
int nCommand = EM_DEVICE_CFG_TYPE . DEVICE_CFG_AUTO_REGISTER ;
NetStructs . STU_CFG_AUTO_REGISTER_PARAM cfg = getAutoRegister ( loginID , nCommand ) ;
cfg . bEnable = bEnable ;
cfg . szServerAddress = DataUtils . sdk_data_stringToByteArray ( serverAddress , GlobalTool . getEncodeType ( ) ) ; ;
cfg . nPort = port ;
IntByReference inBufferSize = new IntByReference ( 0 ) ;
inBufferSize . setValue ( cfg . size ( ) ) ;
Pointer ptrInBuffer = DataUtils . sdk_data_createPtr ( inBufferSize . getValue ( ) ) ;
DataUtils . sdk_data_structureToPtr ( cfg , ptrInBuffer , 0 ) ;
boolean bResult2 = NetLib . instance . Net_SetDeviceCfg (
loginID ,
nCommand ,
0 ,
ptrInBuffer ,
inBufferSize . getValue ( ) ,
6000 ) ;
if ( ! bResult2 )
{
int error = NetLib . instance . Net_LastError ( ) ;
String strError = String . format ( "Net_setAutoRegister fail, command = %d, errorCode = %d" , nCommand , error ) ;
System . out . println ( strError ) ;
return R . error ( 500 , strError ) ;
}
return R . ok ( ) ;
}
public STU_CFG_AUTO_REGISTER_PARAM getAutoRegister ( NativeLong loginID , int nCommand ) {
IntByReference outBufferSize = new IntByReference ( 0 ) ;
IntByReference nReturnSize = new IntByReference ( 0 ) ;
Pointer ptrOutBuffer = initStuData ( nCommand , outBufferSize ) ;
boolean bResult = NetLib . instance . Net_GetDeviceCfg (
loginID ,
nCommand ,
0 ,
ptrOutBuffer ,
outBufferSize . getValue ( ) ,
nReturnSize ,
6000 ) ;
if ( ! bResult )
{
int error = NetLib . instance . Net_LastError ( ) ;
String strError = String . format ( "Net_AutoRegisterCfg fail, command = %d, errorCode = %d" , nCommand , error ) ;
System . out . println ( strError ) ;
return null ;
}
STU_CFG_AUTO_REGISTER_PARAM cfg = new STU_CFG_AUTO_REGISTER_PARAM ( ) ;
DataUtils . sdk_data_ptrToStructure ( ptrOutBuffer , cfg ) ;
return cfg ;
}
}