提交 95b76b50 authored 作者: wangqiang's avatar wangqiang

apq-iot client

上级 7d53a11c
...@@ -559,7 +559,8 @@ public class MqttServiceImpl implements MqttService, MqttHandler, MqttClientCall ...@@ -559,7 +559,8 @@ public class MqttServiceImpl implements MqttService, MqttHandler, MqttClientCall
if (null != clientSecurityByMac) { if (null != clientSecurityByMac) {
mqttClientConfig.setUsername(clientSecurityByMac.getAccessToken()); mqttClientConfig.setUsername(clientSecurityByMac.getAccessToken());
} else { } else {
mqttClientConfig.setUsername("no user please reg"); log.info("no user please reg");
mqttClientConfig.setUsername("");
} }
} else { } else {
mqttClientConfig.setUsername(connection.getSecurity().getAccessToken()); mqttClientConfig.setUsername(connection.getSecurity().getAccessToken());
...@@ -594,6 +595,19 @@ public class MqttServiceImpl implements MqttService, MqttHandler, MqttClientCall ...@@ -594,6 +595,19 @@ public class MqttServiceImpl implements MqttService, MqttHandler, MqttClientCall
} }
private void connectTbClient() throws InterruptedException, ExecutionException { private void connectTbClient() throws InterruptedException, ExecutionException {
// 获取client username
String username = tbClient.getClientConfig().getUsername();
if (StrUtil.isBlank(username)) {
MqttClientSecurityConfiguration clientSecurityByMac = getClientSecurityByMac();
if (null == clientSecurityByMac) {
log.info("no user please reg");
log.info("Priusisiot Gateway connection failed. Reconnecting in [{}] milliseconds", connection.getRetryInterval());
Thread.sleep(connection.getRetryInterval());
connectTbClient();
} else {
tbClient.getClientConfig().setUsername(clientSecurityByMac.getAccessToken());
}
}
Promise<MqttConnectResult> connectResult = (Promise<MqttConnectResult>) tbClient.connect(connection.getHost(), connection.getPort()); Promise<MqttConnectResult> connectResult = (Promise<MqttConnectResult>) tbClient.connect(connection.getHost(), connection.getPort());
connectResult.addListener(future -> { connectResult.addListener(future -> {
if (future.isSuccess()) { if (future.isSuccess()) {
...@@ -629,7 +643,8 @@ public class MqttServiceImpl implements MqttService, MqttHandler, MqttClientCall ...@@ -629,7 +643,8 @@ public class MqttServiceImpl implements MqttService, MqttHandler, MqttClientCall
if (null != clientSecurityByMac) { if (null != clientSecurityByMac) {
mqttClientConfig.setUsername(clientSecurityByMac.getAccessToken()); mqttClientConfig.setUsername(clientSecurityByMac.getAccessToken());
} else { } else {
mqttClientConfig.setUsername("no user please reg"); log.info("no user please reg");
mqttClientConfig.setUsername("");
} }
} else { } else {
if (!StringUtils.isEmpty(connection.getSecurity().getAccessToken())) { if (!StringUtils.isEmpty(connection.getSecurity().getAccessToken())) {
......
...@@ -2,11 +2,4 @@ apq: ...@@ -2,11 +2,4 @@ apq:
iot-gateway: 192.168.124.19:7002 iot-gateway: 192.168.124.19:7002
PC_HOST: 192.168.124.6 PC_HOST: 192.168.124.6
vnc-repeater: 120.24.236.245:5500 vnc-repeater: 120.24.236.245:5500
#apq:
# iot-gateway: 192.168.6.23:7033
#PC_HOST: 192.168.6.23
#vnc-repeater: 192.168.6.29:5500
#apq:
# iot-gateway: 10.2.68.40:7033
#PC_HOST: 10.2.68.40
#vnc-repeater: 10.2.68.41:5500
\ No newline at end of file
apq:
iot-gateway: 10.2.68.40:7033
PC_HOST: 10.2.68.40
vnc-repeater: 10.2.68.41:5500
\ No newline at end of file
#apq:
# iot-gateway: 192.168.6.23:7033
#PC_HOST: 192.168.6.23
#vnc-repeater: 192.168.6.29:5500
apq: apq:
iot-gateway: 192.168.6.23:7033 iot-gateway: 120.24.236.245:7033
PC_HOST: 192.168.6.23 PC_HOST: 120.24.184.117
\ No newline at end of file vnc-repeater: 120.24.236.245:5500
; Script generated by the Inno Setup Script Wizard. ; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "阿普奇检测客户端" #define MyAppName "阿普奇检测客户端"
#define MyAppVersion "V1.0" #define MyAppVersion "V1.0"
#define MyAppPublisher "阿普奇" #define MyAppPublisher "阿普奇"
#define MyAppURL "https://www.apq.com/" #define MyAppURL "https://www.apq.com/"
#define MyAppDirName "apq-client" #define MyAppDirName "apq-client"
#define MyAppEnName "apq-client" #define MyAppEnName "apq-client"
...@@ -52,7 +52,7 @@ VersionInfoVersion=1.0.0.1 ...@@ -52,7 +52,7 @@ VersionInfoVersion=1.0.0.1
Name: "chinese"; MessagesFile: "compiler:Languages/Chinese.isl" Name: "chinese"; MessagesFile: "compiler:Languages/Chinese.isl"
[Files] [Files]
Source: "../apq-client/*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs; Source: "../apq-client/*"; Excludes: "bak"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs;
Source: "../../java/jre/jre/*"; DestDir: "{app}/jre"; Flags: ignoreversion recursesubdirs createallsubdirs; Source: "../../java/jre/jre/*"; DestDir: "{app}/jre"; Flags: ignoreversion recursesubdirs createallsubdirs;
Source: "../../client/*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs; Source: "../../client/*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs;
; NOTE: Don't use "Flags: ignoreversion" on any shared system files ; NOTE: Don't use "Flags: ignoreversion" on any shared system files
......
...@@ -52,7 +52,7 @@ VersionInfoVersion=1.0.0.1 ...@@ -52,7 +52,7 @@ VersionInfoVersion=1.0.0.1
Name: "chinese"; MessagesFile: "compiler:Languages/Chinese.isl" Name: "chinese"; MessagesFile: "compiler:Languages/Chinese.isl"
[Files] [Files]
Source: "../apq-client/*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs; Source: "../apq-client/*"; Excludes: "bak"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs;
Source: "../../java/jre/jre/*"; DestDir: "{app}/jre"; Flags: ignoreversion recursesubdirs createallsubdirs; Source: "../../java/jre/jre/*"; DestDir: "{app}/jre"; Flags: ignoreversion recursesubdirs createallsubdirs;
Source: "../../client/*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs; Source: "../../client/*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs;
; NOTE: Don't use "Flags: ignoreversion" on any shared system files ; NOTE: Don't use "Flags: ignoreversion" on any shared system files
......
...@@ -9,14 +9,18 @@ net stop apq-client-service ...@@ -9,14 +9,18 @@ net stop apq-client-service
"%~dp0apq-client-service.exe" uninstall "%~dp0apq-client-service.exe" uninstall
@ECHO Stopping apq-other-service ... @ECHO Stopping apq-other-service ...
sc config apq-control-service start= DISABLED
sc config apq-info-service start= DISABLED
sc config apq-register-service start= DISABLED
net stop apq-control-service net stop apq-control-service
net stop apq-info-service net stop apq-info-service
net stop apq-register-service net stop apq-register-service
@ECHO Uninstalling apq-other-service ... :: @ECHO Uninstalling apq-other-service ...
sc delete apq-control-service :: sc delete apq-control-service
sc delete apq-info-service :: sc delete apq-info-service
sc delete apq-register-service :: sc delete apq-register-service
@ECHO DONE. @ECHO DONE.
......
...@@ -8,6 +8,10 @@ setlocal ENABLEEXTENSIONS ...@@ -8,6 +8,10 @@ setlocal ENABLEEXTENSIONS
"%~dp0apq-client-service.exe" start "%~dp0apq-client-service.exe" start
@ECHO running apq-other-service ... @ECHO running apq-other-service ...
sc config apq-control-service start= AUTO
sc config apq-info-service start= AUTO
sc config apq-register-service start= AUTO
net start apq-control-service net start apq-control-service
net start apq-info-service net start apq-info-service
net start apq-register-service net start apq-register-service
......
...@@ -10,4 +10,5 @@ ...@@ -10,4 +10,5 @@
<startargument>-Dplatform=windows</startargument> <startargument>-Dplatform=windows</startargument>
<startargument>-jar</startargument> <startargument>-jar</startargument>
<startargument>%BASE%\apq-pc-client-0.0.1-SNAPSHOT-boot.jar</startargument> <startargument>%BASE%\apq-pc-client-0.0.1-SNAPSHOT-boot.jar</startargument>
<startargument>--spring.profiles.active=test</startargument>
</service> </service>
...@@ -9,14 +9,18 @@ net stop apq-client-service ...@@ -9,14 +9,18 @@ net stop apq-client-service
"%~dp0apq-client-service.exe" uninstall "%~dp0apq-client-service.exe" uninstall
@ECHO Stopping apq-other-service ... @ECHO Stopping apq-other-service ...
sc config apq-control-service start= DISABLED
sc config apq-info-service start= DISABLED
sc config apq-register-service start= DISABLED
net stop apq-control-service net stop apq-control-service
net stop apq-info-service net stop apq-info-service
net stop apq-register-service net stop apq-register-service
@ECHO Uninstalling apq-other-service ... :: @ECHO Uninstalling apq-other-service ...
sc delete apq-control-service :: sc delete apq-control-service
sc delete apq-info-service :: sc delete apq-info-service
sc delete apq-register-service :: sc delete apq-register-service
@ECHO DONE. @ECHO DONE.
......
...@@ -8,6 +8,10 @@ setlocal ENABLEEXTENSIONS ...@@ -8,6 +8,10 @@ setlocal ENABLEEXTENSIONS
"%~dp0apq-client-service.exe" start "%~dp0apq-client-service.exe" start
@ECHO running apq-other-service ... @ECHO running apq-other-service ...
sc config apq-control-service start= AUTO
sc config apq-info-service start= AUTO
sc config apq-register-service start= AUTO
net start apq-control-service net start apq-control-service
net start apq-info-service net start apq-info-service
net start apq-register-service net start apq-register-service
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#define MyAppDirName "apq-control" #define MyAppDirName "apq-control"
#define MyAppEnName "apq-control" #define MyAppEnName "apq-control"
#define MyAppExeName "apq-control.exe" #define MyAppExeName "apq-control.exe"
#define MyAppReBootName "service\启动服务R.bat"
[Setup] [Setup]
; 注: AppId的值为单独标识该应用程序。 ; 注: AppId的值为单独标识该应用程序。
...@@ -75,7 +74,6 @@ Type: dirifempty; Name: "{app}" ...@@ -75,7 +74,6 @@ Type: dirifempty; Name: "{app}"
;操作注册表 ;操作注册表
[Registry] [Registry]
Root: HKLM; Subkey: "Software\{#MyAppEnName}"; Flags: uninsdeletekey; Root: HKLM; Subkey: "Software\{#MyAppEnName}"; Flags: uninsdeletekey;
Root: HKCU; Subkey: "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"; ValueType: string; ValueName: "{#MyAppEnName}"; ValueData: "{app}\{#MyAppReBootName}"; Flags: uninsdeletevalue;
[Code] [Code]
......
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "阿普奇硬件检测程序"
#define MyAppVersion "V1.0"
#define MyAppPublisher "阿普奇"
#define MyAppURL "https://www.apq.com/"
#define MyAppDirName "apq-control"
#define MyAppEnName "apq-control"
#define MyAppExeName "apq-control.exe"
#define MyAppReBootName "service\启动服务R.bat"
[Setup]
; 注: AppId的值为单独标识该应用程序。
; 不要为其他安装程序使用相同的AppId值。
; (生成新的GUID,点击 工具|在IDE中生成GUID。)
ChangesEnvironment=yes
DisableDirPage=no
AppId={{1394783A-5D3C-48CD-8470-E2DFBB844E42}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppVerName={#MyAppName}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppDirName}
DefaultGroupName={#MyAppName}
SetupIconFile=logo.ico
;安装包文件输出目录
OutputDir=..\dist\
;安装包文件名
OutputBaseFilename={#MyAppName}
;压缩文件
Compression=lzma
SolidCompression=yes
;以管理员权限运行
PrivilegesRequired=admin
UninstallDisplayIcon={app}/{#MyAppExeName}
//CreateUninstallRegKey=no
//UpdateUninstallLogAppName=no
VersionInfoVersion=1.0.0.0
[Languages]
Name: "chinesesimp"; MessagesFile: "compiler:Languages/Chinese.isl"
[Files]
Source: "../apq-control/*"; Excludes: "bak"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs;
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
//[Tasks]
//Name: "startupicon"; Description: "开机启动"; GroupDescription: "{cm:AdditionalIcons}";
[Icons]
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
[Run]
Filename: "{app}\service\启动服务.bat"; Flags: runhidden;
;卸载后执行的操作(停止、删除各种服务)
[UninstallRun]
Filename: "{app}\service\删除服务.bat"; Flags: runhidden;
;卸载后删除目录所有文件,删除空目录
[UninstallDelete]
Type: filesandordirs; Name: "{app}\*"
Type: dirifempty; Name: "{app}"
;操作注册表
[Registry]
Root: HKLM; Subkey: "Software\{#MyAppEnName}"; Flags: uninsdeletekey;
Root: HKCU; Subkey: "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"; ValueType: string; ValueName: "{#MyAppEnName}"; ValueData: "{app}\{#MyAppReBootName}"; Flags: uninsdeletevalue;
[Code]
function CheckProcessRunning( aProcName,
aProcDesc: string ): boolean;
var
ShellResult: boolean;
ResultCode: integer;
cmd: string;
sl: TStringList;
f: string;
d: string;
cmd2: string;
f2: string;
sl2: TStringList;
begin
cmd := 'for /f "delims=," %%i ' +
'in (''tasklist /FI "IMAGENAME eq ' + aProcName + '" /FO CSV'') ' +
'do if "%%~i"=="' + aProcName + '" exit 1';
f := 'CheckProc.cmd';
cmd2 := 'taskkill -f -t -im ' + aProcName;
f2 := 'KillProc.cmd';
d := AddBackSlash( ExpandConstant( '{tmp}' ));
sl := TStringList.Create;
sl.Add( cmd );
sl.Add( 'exit /0' );
sl.SaveToFile( d + f );
sl.Free;
sl2 := TStringList.Create;
sl2.Add( cmd2 );
sl2.Add( 'exit /0' );
sl2.SaveToFile( d + f2 );
sl2.Free;
Result := true;
while ( Result ) do
begin
ResultCode := 1;
ShellResult := Exec( f,
'',
d,
SW_HIDE,
ewWaitUntilTerminated,
ResultCode );
Result := ResultCode > 0;
if Result then
begin
Msgbox('已关闭正在运行' + aProcDesc + '客户端!', mbInformation, MB_OK);
ShellResult := Exec( f2,
'',
d,
SW_HIDE,
ewWaitUntilTerminated,
ResultCode );
end;
end;
DeleteFile( d + f );
DeleteFile( d + f2 );
end;
// Perform some initializations. Return False to abort setup
function InitializeSetup: Boolean;
begin
// Do not use any user defined vars in here such as {app}
// Result := not ( CheckProcessRunning( 'apq-control-service.exe', 'apq-control-service' ));
Result := not ( CheckProcessRunning( 'apq-control.exe', 'apq客户端插件' ));
end;
\ No newline at end of file
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "阿普奇硬件检测程序"
#define MyAppVersion "V1.0"
#define MyAppPublisher "阿普奇"
#define MyAppURL "https://www.apq.com/"
#define MyAppDirName "apq-control"
#define MyAppEnName "apq-control"
#define MyAppExeName "apq-control.exe"
[Setup]
; 注: AppId的值为单独标识该应用程序。
; 不要为其他安装程序使用相同的AppId值。
; (生成新的GUID,点击 工具|在IDE中生成GUID。)
ChangesEnvironment=yes
DisableDirPage=no
AppId={{1394783A-5D3C-48CD-8470-E2DFBB844E42}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppVerName={#MyAppName}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppDirName}
DefaultGroupName={#MyAppName}
SetupIconFile=logo.ico
;安装包文件输出目录
OutputDir=..\dist\
;安装包文件名
OutputBaseFilename={#MyAppName}
;压缩文件
Compression=lzma
SolidCompression=yes
;以管理员权限运行
PrivilegesRequired=admin
UninstallDisplayIcon={app}/{#MyAppExeName}
//CreateUninstallRegKey=no
//UpdateUninstallLogAppName=no
VersionInfoVersion=1.0.0.0
[Languages]
Name: "chinesesimp"; MessagesFile: "compiler:Languages/Chinese.isl"
[Files]
Source: "../apq-control/*"; Excludes: "bak"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs;
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
//[Tasks]
//Name: "startupicon"; Description: "开机启动"; GroupDescription: "{cm:AdditionalIcons}";
[Icons]
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
[Run]
Filename: "{app}\service\启动服务.bat"; Flags: runhidden;
;卸载后执行的操作(停止、删除各种服务)
[UninstallRun]
Filename: "{app}\service\删除服务.bat"; Flags: runhidden;
;卸载后删除目录所有文件,删除空目录
[UninstallDelete]
Type: filesandordirs; Name: "{app}\*"
Type: dirifempty; Name: "{app}"
;操作注册表
[Registry]
Root: HKLM; Subkey: "Software\{#MyAppEnName}"; Flags: uninsdeletekey;
[Code]
function CheckProcessRunning( aProcName,
aProcDesc: string ): boolean;
var
ShellResult: boolean;
ResultCode: integer;
cmd: string;
sl: TStringList;
f: string;
d: string;
cmd2: string;
f2: string;
sl2: TStringList;
begin
cmd := 'for /f "delims=," %%i ' +
'in (''tasklist /FI "IMAGENAME eq ' + aProcName + '" /FO CSV'') ' +
'do if "%%~i"=="' + aProcName + '" exit 1';
f := 'CheckProc.cmd';
cmd2 := 'taskkill -f -t -im ' + aProcName;
f2 := 'KillProc.cmd';
d := AddBackSlash( ExpandConstant( '{tmp}' ));
sl := TStringList.Create;
sl.Add( cmd );
sl.Add( 'exit /0' );
sl.SaveToFile( d + f );
sl.Free;
sl2 := TStringList.Create;
sl2.Add( cmd2 );
sl2.Add( 'exit /0' );
sl2.SaveToFile( d + f2 );
sl2.Free;
Result := true;
while ( Result ) do
begin
ResultCode := 1;
ShellResult := Exec( f,
'',
d,
SW_HIDE,
ewWaitUntilTerminated,
ResultCode );
Result := ResultCode > 0;
if Result then
begin
Msgbox('已关闭正在运行' + aProcDesc + '客户端!', mbInformation, MB_OK);
ShellResult := Exec( f2,
'',
d,
SW_HIDE,
ewWaitUntilTerminated,
ResultCode );
end;
end;
DeleteFile( d + f );
DeleteFile( d + f2 );
end;
// Perform some initializations. Return False to abort setup
function InitializeSetup: Boolean;
begin
// Do not use any user defined vars in here such as {app}
// Result := not ( CheckProcessRunning( 'apq-control-service.exe', 'apq-control-service' ));
Result := not ( CheckProcessRunning( 'apq-control.exe', 'apq客户端插件' ));
end;
\ No newline at end of file
cd /d "%~dp0" @ECHO OFF
start apq-control -Xms256m -Xmx256m -Dfile.encoding=utf-8 -jar "%~dp0\apq-pc-control-1.0-SNAPSHOT-boot.jar"
echo start apq control service setlocal ENABLEEXTENSIONS
exit
\ No newline at end of file @ECHO Installing apq-control-service ...
"%~dp0apq-control-service.exe" install
@ECHO running apq-control-service ...
"%~dp0apq-control-service.exe" start
@ECHO DONE.
:END
\ No newline at end of file
cd /d "%~dp0" @ECHO OFF
setlocal enabledelayedexpansion setlocal enabledelayedexpansion
for /F "TOKENS=1,2,*" %%a in ('jps -m ^| findstr apq-pc-control') do set SPID=%%a @ECHO Stopping apq-control-service ...
TASKKILL /F /PID %SPID% net stop apq-control-service
@ECHO Uninstalling apq-control-service ...
"%~dp0apq-control-service.exe" uninstall
@ECHO DONE.
echo 删除服务完毕 :END
exit \ No newline at end of file
\ No newline at end of file
cd /d "%~dp0" @ECHO OFF
::start xx.exe
for /F "TOKENS=1,2,*" %%a in ('jps -m ^| findstr apq-pc-control') do set SPID=%%a setlocal ENABLEEXTENSIONS
TASKKILL /F /PID %SPID%
start apq-control -Xms256m -Xmx256m -Dfile.encoding=utf-8 -jar "%~dp0\apq-pc-control-1.0-SNAPSHOT-boot.jar" @ECHO Installing apq-control-service ...
echo start apq control service "%~dp0apq-control-service.exe" install
exit @ECHO running apq-control-service ...
\ No newline at end of file "%~dp0apq-control-service.exe" start
@ECHO DONE.
:END
\ No newline at end of file
@ECHO OFF
setlocal ENABLEEXTENSIONS
@ECHO Installing apq-control-service ...
"%~dp0apq-control-service.exe" install
@ECHO running apq-control-service ...
"%~dp0apq-control-service.exe" start
@ECHO DONE.
:END
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论