diff --git a/.cproject b/.cproject index 55e6828..32dc3ef 100644 --- a/.cproject +++ b/.cproject @@ -14,27 +14,28 @@ - + + + + + @@ -91,41 +96,42 @@ - + + + + + diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/deployment.xml b/.idea/deployment.xml new file mode 100644 index 0000000..a5120ee --- /dev/null +++ b/.idea/deployment.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..53624c9 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,18 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/other.xml b/.idea/other.xml new file mode 100644 index 0000000..8fe5a6c --- /dev/null +++ b/.idea/other.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.metadata/.lock b/.metadata/.lock new file mode 100644 index 0000000..e69de29 diff --git a/.metadata/.log b/.metadata/.log new file mode 100644 index 0000000..91e2b0a --- /dev/null +++ b/.metadata/.log @@ -0,0 +1,1292 @@ +!SESSION 2024-04-25 11:26:26.165 ----------------------------------------------- +eclipse.buildId=4.24.0.I20220607-0700 +java.version=17.0.3 +java.vendor=Eclipse Adoptium +BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=zh_CN +Framework arguments: -product org.eclipse.epp.package.cpp.product +Command-line arguments: -os linux -ws gtk -arch x86_64 -product org.eclipse.epp.package.cpp.product + +!ENTRY org.eclipse.linuxtools.docker.editor.ls 4 0 2024-04-25 11:26:26.982 +!MESSAGE FrameworkEvent ERROR +!STACK 0 +org.osgi.framework.BundleException: Could not resolve module: org.eclipse.linuxtools.docker.editor.ls [823] + Unresolved requirement: Require-Bundle: org.eclipse.lsp4e; bundle-version="0.11.0" + -> Bundle-SymbolicName: org.eclipse.lsp4e; bundle-version="0.15.0.202211292024"; singleton:="true" + org.eclipse.lsp4e [843] + Unresolved requirement: Require-Bundle: org.eclipse.lsp4j; bundle-version="[0.19.0,0.20.0)" + -> Bundle-SymbolicName: org.eclipse.lsp4j; bundle-version="0.19.0.v20221118-0359" + org.eclipse.lsp4j [846] + Unresolved requirement: Import-Package: com.google.gson; version="[2.9.1,2.10.0)" + -> Export-Package: com.google.gson; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1"; uses:="com.google.gson.internal,com.google.gson.reflect,com.google.gson.stream" + com.google.gson [620] + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.messages; version="[0.19.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc.messages; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.0.v20230517-2120"; version="0.21.0"; uses:="org.eclipse.lsp4j.jsonrpc.validation" + org.eclipse.lsp4j.jsonrpc [848] + Unresolved requirement: Import-Package: com.google.gson.internal; version="[2.9.1,2.11.0)" + -> Export-Package: com.google.gson.internal; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1"; x-internal:="true"; uses:="com.google.gson,com.google.gson.reflect,com.google.gson.stream" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc + -> Export-Package: org.eclipse.lsp4j.jsonrpc; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.1.v20230829-0012"; version="0.21.1"; uses:="com.google.gson,org.eclipse.lsp4j.jsonrpc.json,org.eclipse.lsp4j.jsonrpc.messages" + org.eclipse.lsp4j.jsonrpc [847] + Unresolved requirement: Import-Package: com.google.gson.annotations; version="[2.9.1,2.11.0)" + -> Export-Package: com.google.gson.annotations; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.messages + -> Export-Package: org.eclipse.lsp4j.jsonrpc.messages; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.0.v20230517-2120"; version="0.21.0"; uses:="org.eclipse.lsp4j.jsonrpc.validation" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.json.adapters + -> Export-Package: org.eclipse.lsp4j.jsonrpc.json.adapters; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.0.v20230517-2120"; version="0.21.0"; uses:="com.google.gson,com.google.gson.reflect,com.google.gson.stream,org.eclipse.lsp4j.jsonrpc.json,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Import-Package: com.google.gson; version="[2.9.1,2.11.0)" + -> Export-Package: com.google.gson; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1"; uses:="com.google.gson.internal,com.google.gson.reflect,com.google.gson.stream" + Unresolved requirement: Import-Package: com.google.gson.stream; version="[2.9.1,2.11.0)" + -> Export-Package: com.google.gson.stream; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1" + Unresolved requirement: Import-Package: com.google.gson.reflect; version="[2.9.1,2.11.0)" + -> Export-Package: com.google.gson.reflect; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.json + -> Export-Package: org.eclipse.lsp4j.jsonrpc.json; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.19.0.v20221118-0359"; version="0.19.0"; uses:="com.google.gson,org.eclipse.lsp4j.jsonrpc,org.eclipse.lsp4j.jsonrpc.messages" + org.eclipse.lsp4j.jsonrpc [849] + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.json.adapters + -> Export-Package: org.eclipse.lsp4j.jsonrpc.json.adapters; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.0.v20230517-2120"; version="0.21.0"; uses:="com.google.gson,com.google.gson.reflect,com.google.gson.stream,org.eclipse.lsp4j.jsonrpc.json,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Import-Package: com.google.gson; version="[2.9.1,2.10.0)" + -> Export-Package: com.google.gson; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1"; uses:="com.google.gson.internal,com.google.gson.reflect,com.google.gson.stream" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.services + -> Export-Package: org.eclipse.lsp4j.jsonrpc.services; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.1.v20230829-0012"; version="0.21.1"; uses:="org.eclipse.lsp4j.jsonrpc,org.eclipse.lsp4j.jsonrpc.json" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc + -> Export-Package: org.eclipse.lsp4j.jsonrpc; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.1.v20230829-0012"; version="0.21.1"; uses:="com.google.gson,org.eclipse.lsp4j.jsonrpc.json,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Import-Package: com.google.gson.annotations; version="[2.9.1,2.10.0)" + -> Export-Package: com.google.gson.annotations; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.messages + -> Export-Package: org.eclipse.lsp4j.jsonrpc.messages; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.0.v20230517-2120"; version="0.21.0"; uses:="org.eclipse.lsp4j.jsonrpc.validation" + Unresolved requirement: Import-Package: com.google.gson.reflect; version="[2.9.1,2.10.0)" + -> Export-Package: com.google.gson.reflect; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1" + Unresolved requirement: Import-Package: com.google.gson.stream; version="[2.9.1,2.10.0)" + -> Export-Package: com.google.gson.stream; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.validation + -> Export-Package: org.eclipse.lsp4j.jsonrpc.validation; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.19.0.v20221118-0359"; version="0.19.0"; uses:="org.eclipse.lsp4j.jsonrpc,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Import-Package: com.google.gson; version="[2.9.1,2.11.0)" + -> Export-Package: com.google.gson; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1"; uses:="com.google.gson.internal,com.google.gson.reflect,com.google.gson.stream" + Unresolved requirement: Import-Package: com.google.gson.stream; version="[2.9.1,2.11.0)" + -> Export-Package: com.google.gson.stream; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.services + -> Export-Package: org.eclipse.lsp4j.jsonrpc.services; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.1.v20230829-0012"; version="0.21.1"; uses:="org.eclipse.lsp4j.jsonrpc,org.eclipse.lsp4j.jsonrpc.json" + Unresolved requirement: Import-Package: com.google.gson.reflect; version="[2.9.1,2.11.0)" + -> Export-Package: com.google.gson.reflect; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.json + -> Export-Package: org.eclipse.lsp4j.jsonrpc.json; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.19.0.v20221118-0359"; version="0.19.0"; uses:="com.google.gson,org.eclipse.lsp4j.jsonrpc,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.validation + -> Export-Package: org.eclipse.lsp4j.jsonrpc.validation; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.19.0.v20221118-0359"; version="0.19.0"; uses:="org.eclipse.lsp4j.jsonrpc,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Import-Package: com.google.gson.annotations; version="[2.9.1,2.11.0)" + -> Export-Package: com.google.gson.annotations; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.validation; version="[0.19.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc.validation; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.19.0.v20221118-0359"; version="0.19.0"; uses:="org.eclipse.lsp4j.jsonrpc,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.json.adapters; version="[0.19.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc.json.adapters; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.19.0.v20221118-0359"; version="0.19.0"; uses:="com.google.gson,com.google.gson.reflect,com.google.gson.stream,org.eclipse.lsp4j.jsonrpc.json,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Import-Package: com.google.common.base; version="[30.1.0,31.0.0)" + -> Export-Package: com.google.common.base; bundle-symbolic-name="com.google.guava"; bundle-version="30.1.0.v20210127-2300"; version="30.1.0"; uses:="com.google.errorprone.annotations,org.checkerframework.checker.nullness.qual" + com.google.guava [1027] + Unresolved requirement: Import-Package: com.google.errorprone.annotations; version="[3.0.0,4.0.0)"; resolution:="optional" + Unresolved requirement: Import-Package: com.google.errorprone.annotations.concurrent; version="[3.0.0,4.0.0)"; resolution:="optional" + Unresolved requirement: Import-Package: javax.crypto; version="[3.0.0,4.0.0)"; resolution:="optional" + Unresolved requirement: Import-Package: javax.crypto.spec; version="[3.0.0,4.0.0)"; resolution:="optional" + Unresolved requirement: Import-Package: org.checkerframework.checker.nullness.qual; version="[3.5.0,4.0.0)"; resolution:="optional" + Unresolved requirement: Import-Package: org.eclipse.lsp4j + -> Export-Package: org.eclipse.lsp4j; bundle-symbolic-name="org.eclipse.lsp4j"; bundle-version="0.14.0.v20220526-1518"; version="0.14.0.v20220526-1518"; uses:="com.google.gson.annotations,org.eclipse.lsp4j.adapters,org.eclipse.lsp4j.jsonrpc.messages,org.eclipse.lsp4j.jsonrpc.validation,org.eclipse.xtext.xbase.lib" + org.eclipse.lsp4j [1069] + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc; version="[0.14.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.1.v20230829-0012"; version="0.21.1"; uses:="com.google.gson,org.eclipse.lsp4j.jsonrpc.json,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Import-Package: com.google.gson.reflect; version="[2.8.9,2.9.0)" + -> Export-Package: com.google.gson.reflect; bundle-symbolic-name="com.google.gson"; bundle-version="2.8.9.v20220111-1409"; version="2.8.9" + com.google.gson [1026] + Unresolved requirement: Import-Package: com.google.gson.internal.sql; version="[2.8.0,3.0.0)" + -> Export-Package: com.google.gson.internal.sql; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1"; x-internal:="true"; uses:="com.google.gson,com.google.gson.internal.bind" + Unresolved requirement: Import-Package: com.google.gson.annotations; version="[2.8.0,3.0.0)" + -> Export-Package: com.google.gson.annotations; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1" + Unresolved requirement: Import-Package: com.google.gson.reflect; version="[2.8.0,3.0.0)" + -> Export-Package: com.google.gson.reflect; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1" + Unresolved requirement: Import-Package: com.google.gson.internal.reflect; version="[2.8.0,3.0.0)" + -> Export-Package: com.google.gson.internal.reflect; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1"; x-internal:="true"; uses:="com.google.gson" + Unresolved requirement: Import-Package: com.google.gson.internal.bind.util; version="[2.8.0,3.0.0)" + -> Export-Package: com.google.gson.internal.bind.util; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1"; x-internal:="true" + Unresolved requirement: Import-Package: com.google.gson.internal; version="[2.8.0,3.0.0)" + -> Export-Package: com.google.gson.internal; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1"; x-internal:="true"; uses:="com.google.gson,com.google.gson.reflect,com.google.gson.stream" + Unresolved requirement: Import-Package: com.google.gson.stream; version="[2.8.9,2.9.0)" + -> Export-Package: com.google.gson.stream; bundle-symbolic-name="com.google.gson"; bundle-version="2.8.9.v20220111-1409"; version="2.8.9" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.json; version="[0.14.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc.json; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.19.0.v20221118-0359"; version="0.19.0"; uses:="com.google.gson,org.eclipse.lsp4j.jsonrpc,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.messages; version="[0.14.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc.messages; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.0.v20230517-2120"; version="0.21.0"; uses:="org.eclipse.lsp4j.jsonrpc.validation" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.validation; version="[0.14.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc.validation; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.19.0.v20221118-0359"; version="0.19.0"; uses:="org.eclipse.lsp4j.jsonrpc,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.services; version="[0.14.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.services; bundle-symbolic-name="org.eclipse.lsp4j"; bundle-version="0.21.1.v20230829-0012"; version="0.21.1"; uses:="org.eclipse.lsp4j,org.eclipse.lsp4j.adapters,org.eclipse.lsp4j.jsonrpc.json,org.eclipse.lsp4j.jsonrpc.messages,org.eclipse.lsp4j.jsonrpc.services" + org.eclipse.lsp4j [844] + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.json.adapters; version="[0.21.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc.json.adapters; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.0.v20230517-2120"; version="0.21.0"; uses:="com.google.gson,com.google.gson.reflect,com.google.gson.stream,org.eclipse.lsp4j.jsonrpc.json,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Import-Package: com.google.gson.stream; version="[2.9.1,2.11.0)" + -> Export-Package: com.google.gson.stream; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.util + -> Export-Package: org.eclipse.lsp4j.util; bundle-symbolic-name="org.eclipse.lsp4j"; bundle-version="0.19.0.v20221118-0359"; version="0.19.0"; uses:="org.eclipse.lsp4j" + Unresolved requirement: Import-Package: com.google.gson.annotations; version="[2.9.1,2.11.0)" + -> Export-Package: com.google.gson.annotations; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1" + Unresolved requirement: Import-Package: com.google.gson.reflect; version="[2.9.1,2.11.0)" + -> Export-Package: com.google.gson.reflect; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.validation; version="[0.21.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc.validation; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.0.v20230517-2120"; version="0.21.0"; uses:="org.eclipse.lsp4j.jsonrpc,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc; version="[0.21.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.1.v20230829-0012"; version="0.21.1"; uses:="com.google.gson,org.eclipse.lsp4j.jsonrpc.json,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Import-Package: org.eclipse.lsp4j + -> Export-Package: org.eclipse.lsp4j; bundle-symbolic-name="org.eclipse.lsp4j"; bundle-version="0.14.0.v20220526-1518"; version="0.14.0.v20220526-1518"; uses:="com.google.gson.annotations,org.eclipse.lsp4j.adapters,org.eclipse.lsp4j.jsonrpc.messages,org.eclipse.lsp4j.jsonrpc.validation,org.eclipse.xtext.xbase.lib" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.json; version="[0.21.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc.json; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.1.v20230829-0012"; version="0.21.1"; uses:="com.google.gson,org.eclipse.lsp4j.jsonrpc,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Import-Package: com.google.gson; version="[2.9.1,2.11.0)" + -> Export-Package: com.google.gson; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1"; uses:="com.google.gson.internal,com.google.gson.reflect,com.google.gson.stream" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.adapters + -> Export-Package: org.eclipse.lsp4j.adapters; bundle-symbolic-name="org.eclipse.lsp4j"; bundle-version="0.21.0.v20230517-2120"; version="0.21.0"; uses:="com.google.gson,com.google.gson.reflect,com.google.gson.stream,org.eclipse.lsp4j,org.eclipse.lsp4j.jsonrpc.messages" + org.eclipse.lsp4j [845] + Unresolved requirement: Import-Package: com.google.gson.annotations; version="[2.9.1,2.11.0)" + -> Export-Package: com.google.gson.annotations; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1" + Unresolved requirement: Import-Package: com.google.gson.reflect; version="[2.9.1,2.11.0)" + -> Export-Package: com.google.gson.reflect; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc; version="[0.21.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.1.v20230829-0012"; version="0.21.1"; uses:="com.google.gson,org.eclipse.lsp4j.jsonrpc.json,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.json; version="[0.21.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc.json; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.1.v20230829-0012"; version="0.21.1"; uses:="com.google.gson,org.eclipse.lsp4j.jsonrpc,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Import-Package: com.google.gson; version="[2.9.1,2.11.0)" + -> Export-Package: com.google.gson; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1"; uses:="com.google.gson.internal,com.google.gson.reflect,com.google.gson.stream" + Unresolved requirement: Import-Package: com.google.gson.stream; version="[2.9.1,2.11.0)" + -> Export-Package: com.google.gson.stream; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1" + Unresolved requirement: Import-Package: org.eclipse.lsp4j + -> Export-Package: org.eclipse.lsp4j; bundle-symbolic-name="org.eclipse.lsp4j"; bundle-version="0.14.0.v20220526-1518"; version="0.14.0.v20220526-1518"; uses:="com.google.gson.annotations,org.eclipse.lsp4j.adapters,org.eclipse.lsp4j.jsonrpc.messages,org.eclipse.lsp4j.jsonrpc.validation,org.eclipse.xtext.xbase.lib" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.services + -> Export-Package: org.eclipse.lsp4j.services; bundle-symbolic-name="org.eclipse.lsp4j"; bundle-version="0.21.1.v20230829-0012"; version="0.21.1"; uses:="org.eclipse.lsp4j,org.eclipse.lsp4j.adapters,org.eclipse.lsp4j.jsonrpc.json,org.eclipse.lsp4j.jsonrpc.messages,org.eclipse.lsp4j.jsonrpc.services" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.validation; version="[0.21.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc.validation; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.0.v20230517-2120"; version="0.21.0"; uses:="org.eclipse.lsp4j.jsonrpc,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.json.adapters; version="[0.21.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc.json.adapters; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.0.v20230517-2120"; version="0.21.0"; uses:="com.google.gson,com.google.gson.reflect,com.google.gson.stream,org.eclipse.lsp4j.jsonrpc.json,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.messages; version="[0.21.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc.messages; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.0.v20230517-2120"; version="0.21.0"; uses:="org.eclipse.lsp4j.jsonrpc.validation" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.util + -> Export-Package: org.eclipse.lsp4j.util; bundle-symbolic-name="org.eclipse.lsp4j"; bundle-version="0.19.0.v20221118-0359"; version="0.19.0"; uses:="org.eclipse.lsp4j" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.services; version="[0.21.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc.services; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.0.v20230517-2120"; version="0.21.0"; uses:="org.eclipse.lsp4j.jsonrpc,org.eclipse.lsp4j.jsonrpc.json" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.messages; version="[0.21.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc.messages; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.0.v20230517-2120"; version="0.21.0"; uses:="org.eclipse.lsp4j.jsonrpc.validation" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.services; version="[0.21.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc.services; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.0.v20230517-2120"; version="0.21.0"; uses:="org.eclipse.lsp4j.jsonrpc,org.eclipse.lsp4j.jsonrpc.json" + Unresolved requirement: Import-Package: com.google.gson; version="[2.8.9,2.9.0)" + -> Export-Package: com.google.gson; bundle-symbolic-name="com.google.gson"; bundle-version="2.8.9.v20220111-1409"; version="2.8.9"; uses:="com.google.gson.internal,com.google.gson.reflect,com.google.gson.stream" + Unresolved requirement: Import-Package: com.google.common.base; version="[14.0.0,31.0.0)" + -> Export-Package: com.google.common.base; bundle-symbolic-name="com.google.guava"; bundle-version="30.1.0.v20210127-2300"; version="30.1.0"; uses:="com.google.errorprone.annotations,org.checkerframework.checker.nullness.qual" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.util; version="[0.14.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.util; bundle-symbolic-name="org.eclipse.lsp4j"; bundle-version="0.19.0.v20221118-0359"; version="0.19.0"; uses:="org.eclipse.lsp4j" + Unresolved requirement: Import-Package: org.eclipse.xtext.xbase.lib.util; version="[2.24.0,3.0.0)" + -> Export-Package: org.eclipse.xtext.xbase.lib.util; bundle-symbolic-name="org.eclipse.xtext.xbase.lib"; bundle-version="2.29.0.v20221121-0915"; version="2.29.0" + org.eclipse.xtext.xbase.lib [943] + Unresolved requirement: Require-Bundle: com.google.guava; bundle-version="[30.1.0,31.0.0)"; visibility:="reexport" + -> Bundle-SymbolicName: com.google.guava; bundle-version="30.1.0.v20210127-2300" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.services; version="[0.14.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc.services; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.1.v20230829-0012"; version="0.21.1"; uses:="org.eclipse.lsp4j.jsonrpc,org.eclipse.lsp4j.jsonrpc.json" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.adapters; version="[0.14.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.adapters; bundle-symbolic-name="org.eclipse.lsp4j"; bundle-version="0.21.0.v20230517-2120"; version="0.21.0"; uses:="com.google.gson,com.google.gson.reflect,com.google.gson.stream,org.eclipse.lsp4j,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Import-Package: com.google.gson.annotations; version="[2.8.9,2.9.0)" + -> Export-Package: com.google.gson.annotations; bundle-symbolic-name="com.google.gson"; bundle-version="2.8.9.v20220111-1409"; version="2.8.9" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.json.adapters; version="[0.14.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc.json.adapters; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.0.v20230517-2120"; version="0.21.0"; uses:="com.google.gson,com.google.gson.reflect,com.google.gson.stream,org.eclipse.lsp4j.jsonrpc.json,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Import-Package: org.eclipse.xtext.xbase.lib; version="[2.24.0,3.0.0)" + -> Export-Package: org.eclipse.xtext.xbase.lib; bundle-symbolic-name="org.eclipse.xtext.xbase.lib"; bundle-version="2.29.0.v20221121-0915"; version="2.29.0" + Unresolved requirement: Import-Package: com.google.gson.reflect; version="[2.9.1,2.10.0)" + -> Export-Package: com.google.gson.reflect; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc; version="[0.19.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.1.v20230829-0012"; version="0.21.1"; uses:="com.google.gson,org.eclipse.lsp4j.jsonrpc.json,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Import-Package: com.google.gson.annotations; version="[2.9.1,2.10.0)" + -> Export-Package: com.google.gson.annotations; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.services; version="[0.19.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc.services; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.0.v20230517-2120"; version="0.21.0"; uses:="org.eclipse.lsp4j.jsonrpc,org.eclipse.lsp4j.jsonrpc.json" + Unresolved requirement: Import-Package: org.eclipse.xtext.xbase.lib.util; version="[2.28.0,3.0.0)" + -> Export-Package: org.eclipse.xtext.xbase.lib.util; bundle-symbolic-name="org.eclipse.xtext.xbase.lib"; bundle-version="2.29.0.v20221121-0915"; version="2.29.0" + Unresolved requirement: Import-Package: com.google.gson.stream; version="[2.9.1,2.10.0)" + -> Export-Package: com.google.gson.stream; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.adapters + -> Export-Package: org.eclipse.lsp4j.adapters; bundle-symbolic-name="org.eclipse.lsp4j"; bundle-version="0.21.0.v20230517-2120"; version="0.21.0"; uses:="com.google.gson,com.google.gson.reflect,com.google.gson.stream,org.eclipse.lsp4j,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.services + -> Export-Package: org.eclipse.lsp4j.services; bundle-symbolic-name="org.eclipse.lsp4j"; bundle-version="0.21.1.v20230829-0012"; version="0.21.1"; uses:="org.eclipse.lsp4j,org.eclipse.lsp4j.adapters,org.eclipse.lsp4j.jsonrpc.json,org.eclipse.lsp4j.jsonrpc.messages,org.eclipse.lsp4j.jsonrpc.services" + Unresolved requirement: Import-Package: org.eclipse.xtext.xbase.lib; version="[2.28.0,3.0.0)" + -> Export-Package: org.eclipse.xtext.xbase.lib; bundle-symbolic-name="org.eclipse.xtext.xbase.lib"; bundle-version="2.29.0.v20221121-0915"; version="2.29.0" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.json; version="[0.19.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc.json; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.19.0.v20221118-0359"; version="0.19.0"; uses:="com.google.gson,org.eclipse.lsp4j.jsonrpc,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Require-Bundle: org.eclipse.mylyn.wikitext; bundle-version="3.0.40" + -> Bundle-SymbolicName: org.eclipse.mylyn.wikitext; bundle-version="3.0.42.20220107230029" + org.eclipse.mylyn.wikitext [361] + Unresolved requirement: Import-Package: org.jsoup; version="[1.14.0,2.0.0)" + -> Export-Package: org.jsoup; bundle-symbolic-name="org.jsoup"; bundle-version="1.14.3.v20211012-1727"; version="1.14.3"; uses:="javax.annotation,javax.net.ssl,org.jsoup.nodes,org.jsoup.parser,org.jsoup.safety" + org.jsoup [1113] + Unresolved requirement: Import-Package: javax.annotation.meta; resolution:="optional" + Unresolved requirement: Import-Package: com.google.common.collect; version="[30.1.0,31.0.0)" + -> Export-Package: com.google.common.collect; bundle-symbolic-name="com.google.guava"; bundle-version="30.1.0.v20210127-2300"; version="30.1.0"; uses:="com.google.common.base,com.google.errorprone.annotations,org.checkerframework.checker.nullness.qual" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser.builder + -> Export-Package: org.eclipse.mylyn.wikitext.parser.builder; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.46.202301111837"; version="3.0.46"; uses:="org.eclipse.mylyn.wikitext.parser,org.eclipse.mylyn.wikitext.parser.builder.event,org.eclipse.mylyn.wikitext.parser.outline,org.eclipse.mylyn.wikitext.util" + org.eclipse.mylyn.wikitext [851] + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser.builder.event + -> Export-Package: org.eclipse.mylyn.wikitext.parser.builder.event; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.42.20220107230029"; version="3.0.42"; uses:="org.eclipse.mylyn.wikitext.parser" + Unresolved requirement: Import-Package: com.google.common.base; version="[31.1.0,32.0.0)" + -> Export-Package: com.google.common.base; bundle-symbolic-name="com.google.guava"; bundle-version="31.1.0.jre"; version="31.1.0"; uses:="javax.annotation" + com.google.guava [623] + Unresolved requirement: Import-Package: javax.annotation; version="[3.0.0,4.0.0)"; resolution:="optional" + Unresolved requirement: Import-Package: com.google.common.xml; version="[31.1.0,32.0.0)" + -> Export-Package: com.google.common.xml; bundle-symbolic-name="com.google.guava"; bundle-version="31.1.0.jre"; version="31.1.0"; uses:="com.google.common.escape" + Unresolved requirement: Import-Package: org.jsoup; version="[1.15.0,2.0.0)" + -> Export-Package: org.jsoup; bundle-symbolic-name="org.jsoup"; bundle-version="1.15.3"; version="1.15.3"; uses:="javax.annotation,javax.net.ssl,org.jsoup.nodes,org.jsoup.parser,org.jsoup.safety" + org.jsoup [978] + Unresolved requirement: Import-Package: javax.annotation.meta; resolution:="optional" + Unresolved requirement: Import-Package: org.jsoup.internal + -> Export-Package: org.jsoup.internal; bundle-symbolic-name="org.jsoup"; bundle-version="1.14.3.v20211012-1727"; version="1.14.3"; x-internal:="true"; uses:="javax.annotation,javax.annotation.meta" + Unresolved requirement: Import-Package: org.jsoup + -> Export-Package: org.jsoup; bundle-symbolic-name="org.jsoup"; bundle-version="1.14.3.v20211012-1727"; version="1.14.3"; uses:="javax.annotation,javax.net.ssl,org.jsoup.nodes,org.jsoup.parser,org.jsoup.safety" + Unresolved requirement: Import-Package: org.jsoup.parser + -> Export-Package: org.jsoup.parser; bundle-symbolic-name="org.jsoup"; bundle-version="1.14.3.v20211012-1727"; version="1.14.3"; uses:="javax.annotation,org.jsoup.nodes" + Unresolved requirement: Import-Package: org.jsoup.helper + -> Export-Package: org.jsoup.helper; bundle-symbolic-name="org.jsoup"; bundle-version="1.14.3.v20211012-1727"; version="1.14.3"; uses:="javax.annotation,javax.net.ssl,javax.xml.parsers,org.jsoup,org.jsoup.nodes,org.jsoup.parser,org.jsoup.select,org.w3c.dom" + Unresolved requirement: Import-Package: org.jsoup.safety + -> Export-Package: org.jsoup.safety; bundle-symbolic-name="org.jsoup"; bundle-version="1.14.3.v20211012-1727"; version="1.14.3"; uses:="org.jsoup.nodes" + Unresolved requirement: Import-Package: org.jsoup.select + -> Export-Package: org.jsoup.select; bundle-symbolic-name="org.jsoup"; bundle-version="1.14.3.v20211012-1727"; version="1.14.3"; uses:="javax.annotation,org.jsoup.nodes" + Unresolved requirement: Import-Package: org.jsoup.select; version="[1.15.0,2.0.0)" + -> Export-Package: org.jsoup.select; bundle-symbolic-name="org.jsoup"; bundle-version="1.15.3"; version="1.15.3"; uses:="javax.annotation,org.jsoup.nodes" + Unresolved requirement: Import-Package: com.google.common.collect; version="[31.1.0,32.0.0)" + -> Export-Package: com.google.common.collect; bundle-symbolic-name="com.google.guava"; bundle-version="31.1.0.jre"; version="31.1.0"; uses:="com.google.common.base,javax.annotation" + Unresolved requirement: Import-Package: com.google.common.escape; version="[31.1.0,32.0.0)" + -> Export-Package: com.google.common.escape; bundle-symbolic-name="com.google.guava"; bundle-version="31.1.0.jre"; version="31.1.0"; uses:="com.google.common.base,javax.annotation" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser.outline + -> Export-Package: org.eclipse.mylyn.wikitext.parser.outline; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.42.20220107230029"; version="3.0.42"; uses:="org.eclipse.mylyn.wikitext.parser,org.eclipse.mylyn.wikitext.parser.markup" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser.markup.block + -> Export-Package: org.eclipse.mylyn.wikitext.parser.markup.block; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.42.20220107230029"; version="3.0.42"; uses:="org.eclipse.mylyn.wikitext.parser.markup,org.eclipse.mylyn.wikitext.parser.outline" + Unresolved requirement: Import-Package: org.jsoup.nodes; version="[1.15.0,2.0.0)" + -> Export-Package: org.jsoup.nodes; bundle-symbolic-name="org.jsoup"; bundle-version="1.15.3"; version="1.15.3"; uses:="javax.annotation,org.jsoup,org.jsoup.helper,org.jsoup.parser,org.jsoup.select" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.internal.parser.html + -> Export-Package: org.eclipse.mylyn.wikitext.internal.parser.html; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.42.20220107230029"; version="3.0.42"; x-internal:="true"; uses:="org.eclipse.mylyn.wikitext.parser,org.jsoup.nodes,org.xml.sax" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser.markup + -> Export-Package: org.eclipse.mylyn.wikitext.parser.markup; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.42.20220107230029"; version="3.0.42"; uses:="org.eclipse.mylyn.wikitext.parser,org.eclipse.mylyn.wikitext.parser.util" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser.markup.token + -> Export-Package: org.eclipse.mylyn.wikitext.parser.markup.token; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.42.20220107230029"; version="3.0.42"; uses:="org.eclipse.mylyn.wikitext.parser.markup" + Unresolved requirement: Import-Package: org.jsoup.internal; version="[1.15.0,2.0.0)" + -> Export-Package: org.jsoup.internal; bundle-symbolic-name="org.jsoup"; bundle-version="1.15.3"; version="1.15.3"; uses:="javax.annotation,javax.annotation.meta" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.util + -> Export-Package: org.eclipse.mylyn.wikitext.util; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.46.202301111837"; version="3.0.46"; uses:="javax.xml.stream,org.eclipse.mylyn.wikitext.parser,org.eclipse.mylyn.wikitext.parser.markup,org.xml.sax" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser.css + -> Export-Package: org.eclipse.mylyn.wikitext.parser.css; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.46.202301111837"; version="3.0.46" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.internal.util + -> Export-Package: org.eclipse.mylyn.wikitext.internal.util; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.46.202301111837"; version="3.0.46"; x-internal:="true" + Unresolved requirement: Import-Package: org.jsoup.internal; version="[1.14.0,2.0.0)" + -> Export-Package: org.jsoup.internal; bundle-symbolic-name="org.jsoup"; bundle-version="1.14.3.v20211012-1727"; version="1.14.3"; x-internal:="true"; uses:="javax.annotation,javax.annotation.meta" + Unresolved requirement: Import-Package: org.jsoup.nodes; version="[1.14.0,2.0.0)" + -> Export-Package: org.jsoup.nodes; bundle-symbolic-name="org.jsoup"; bundle-version="1.15.3"; version="1.15.3"; uses:="javax.annotation,org.jsoup,org.jsoup.helper,org.jsoup.parser,org.jsoup.select" + Unresolved requirement: Import-Package: com.google.common.base; version="[30.1.0,31.0.0)" + -> Export-Package: com.google.common.base; bundle-symbolic-name="com.google.guava"; bundle-version="30.1.0.v20210127-2300"; version="30.1.0"; uses:="com.google.errorprone.annotations,org.checkerframework.checker.nullness.qual" + Unresolved requirement: Import-Package: com.google.common.xml; version="[30.1.0,31.0.0)" + -> Export-Package: com.google.common.xml; bundle-symbolic-name="com.google.guava"; bundle-version="30.1.0.v20210127-2300"; version="30.1.0"; uses:="com.google.common.escape" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser.util + -> Export-Package: org.eclipse.mylyn.wikitext.parser.util; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.46.202301111837"; version="3.0.46"; uses:="org.eclipse.mylyn.wikitext.parser.markup,org.eclipse.mylyn.wikitext.parser.outline,org.eclipse.mylyn.wikitext.util" + Unresolved requirement: Import-Package: org.jsoup.select; version="[1.14.0,2.0.0)" + -> Export-Package: org.jsoup.select; bundle-symbolic-name="org.jsoup"; bundle-version="1.14.3.v20211012-1727"; version="1.14.3"; uses:="javax.annotation,org.jsoup.nodes" + Unresolved requirement: Import-Package: com.google.common.escape; version="[30.1.0,31.0.0)" + -> Export-Package: com.google.common.escape; bundle-symbolic-name="com.google.guava"; bundle-version="30.1.0.v20210127-2300"; version="30.1.0"; uses:="com.google.common.base,com.google.errorprone.annotations,org.checkerframework.checker.nullness.qual" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser + -> Export-Package: org.eclipse.mylyn.wikitext.parser; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.46.202301111837"; version="3.0.46"; uses:="org.eclipse.mylyn.wikitext.parser.markup,org.xml.sax" + Unresolved requirement: Import-Package: com.google.common.base + -> Export-Package: com.google.common.base; bundle-symbolic-name="com.google.guava"; bundle-version="32.1.2.jre"; version="32.1.2"; uses:="javax.annotation" + com.google.guava [622] + Unresolved requirement: Import-Package: javax.annotation; version="[3.0.0,4.0.0)"; resolution:="optional" + Unresolved requirement: Require-Bundle: com.google.guava; bundle-version="30.1.0" + -> Bundle-SymbolicName: com.google.guava; bundle-version="32.1.2.jre" + Unresolved requirement: Require-Bundle: org.eclipse.mylyn.wikitext.markdown; bundle-version="3.0.40" + -> Bundle-SymbolicName: org.eclipse.mylyn.wikitext.markdown; bundle-version="3.0.42.20220107230029" + org.eclipse.mylyn.wikitext.markdown [369] + Unresolved requirement: Import-Package: com.google.common.collect; version="[30.1.0,31.0.0)" + -> Export-Package: com.google.common.collect; bundle-symbolic-name="com.google.guava"; bundle-version="30.1.0.v20210127-2300"; version="30.1.0"; uses:="com.google.common.base,com.google.errorprone.annotations,org.checkerframework.checker.nullness.qual" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser.markup.phrase; version="[3.0.0,4.0.0)" + -> Export-Package: org.eclipse.mylyn.wikitext.parser.markup.phrase; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.46.202301111837"; version="3.0.46"; uses:="org.eclipse.mylyn.wikitext.parser.markup" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.util; version="[3.0.0,4.0.0)" + -> Export-Package: org.eclipse.mylyn.wikitext.util; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.46.202301111837"; version="3.0.46"; uses:="javax.xml.stream,org.eclipse.mylyn.wikitext.parser,org.eclipse.mylyn.wikitext.parser.markup,org.xml.sax" + Unresolved requirement: Import-Package: com.google.common.base; version="[30.1.0,31.0.0)" + -> Export-Package: com.google.common.base; bundle-symbolic-name="com.google.guava"; bundle-version="30.1.0.v20210127-2300"; version="30.1.0"; uses:="com.google.errorprone.annotations,org.checkerframework.checker.nullness.qual" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.markdown + -> Export-Package: org.eclipse.mylyn.wikitext.markdown; bundle-symbolic-name="org.eclipse.mylyn.wikitext.markdown"; bundle-version="3.0.48.202308291007"; version="3.0.48"; uses:="org.eclipse.mylyn.wikitext.parser,org.eclipse.mylyn.wikitext.parser.markup" + org.eclipse.mylyn.wikitext.markdown [860] + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.util; version="[3.0.0,4.0.0)" + -> Export-Package: org.eclipse.mylyn.wikitext.util; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.46.202301111837"; version="3.0.46"; uses:="javax.xml.stream,org.eclipse.mylyn.wikitext.parser,org.eclipse.mylyn.wikitext.parser.markup,org.xml.sax" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser.builder; version="[3.0.0,4.0.0)" + -> Export-Package: org.eclipse.mylyn.wikitext.parser.builder; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.46.202301111837"; version="3.0.46"; uses:="org.eclipse.mylyn.wikitext.parser,org.eclipse.mylyn.wikitext.parser.builder.event,org.eclipse.mylyn.wikitext.parser.outline,org.eclipse.mylyn.wikitext.util" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser.markup; version="[3.0.0,4.0.0)" + -> Export-Package: org.eclipse.mylyn.wikitext.parser.markup; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.42.20220107230029"; version="3.0.42"; uses:="org.eclipse.mylyn.wikitext.parser,org.eclipse.mylyn.wikitext.parser.util" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.markdown.internal + -> Export-Package: org.eclipse.mylyn.wikitext.markdown.internal; bundle-symbolic-name="org.eclipse.mylyn.wikitext.markdown"; bundle-version="3.0.42.20220107230029"; version="3.0.42"; x-internal:="true"; uses:="org.eclipse.mylyn.wikitext.parser,org.eclipse.mylyn.wikitext.parser.builder,org.eclipse.mylyn.wikitext.parser.markup" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.markdown.internal.token + -> Export-Package: org.eclipse.mylyn.wikitext.markdown.internal.token; bundle-symbolic-name="org.eclipse.mylyn.wikitext.markdown"; bundle-version="3.0.42.20220107230029"; version="3.0.42"; x-internal:="true"; uses:="org.eclipse.mylyn.wikitext.parser.markup" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.validation; version="[3.0.0,4.0.0)" + -> Export-Package: org.eclipse.mylyn.wikitext.validation; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.46.202301111837"; version="3.0.46"; uses:="org.eclipse.mylyn.wikitext.parser.markup" + Unresolved requirement: Import-Package: com.google.common.base; version="[31.1.0,33.0.0)" + -> Export-Package: com.google.common.base; bundle-symbolic-name="com.google.guava"; bundle-version="32.1.2.jre"; version="32.1.2"; uses:="javax.annotation" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser.markup.phrase; version="[3.0.0,4.0.0)" + -> Export-Package: org.eclipse.mylyn.wikitext.parser.markup.phrase; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.46.202301111837"; version="3.0.46"; uses:="org.eclipse.mylyn.wikitext.parser.markup" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser; version="[3.0.0,4.0.0)" + -> Export-Package: org.eclipse.mylyn.wikitext.parser; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.46.202301111837"; version="3.0.46"; uses:="org.eclipse.mylyn.wikitext.parser.markup,org.xml.sax" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser.markup.token; version="[3.0.0,4.0.0)" + -> Export-Package: org.eclipse.mylyn.wikitext.parser.markup.token; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.42.20220107230029"; version="3.0.42"; uses:="org.eclipse.mylyn.wikitext.parser.markup" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.markdown.internal.util + -> Export-Package: org.eclipse.mylyn.wikitext.markdown.internal.util; bundle-symbolic-name="org.eclipse.mylyn.wikitext.markdown"; bundle-version="3.0.42.20220107230029"; version="3.0.42"; x-internal:="true"; uses:="org.eclipse.mylyn.wikitext.markdown.internal.block,org.eclipse.mylyn.wikitext.parser,org.eclipse.mylyn.wikitext.parser.markup" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.markdown.internal.phrase + -> Export-Package: org.eclipse.mylyn.wikitext.markdown.internal.phrase; bundle-symbolic-name="org.eclipse.mylyn.wikitext.markdown"; bundle-version="3.0.42.20220107230029"; version="3.0.42"; x-internal:="true"; uses:="org.eclipse.mylyn.wikitext.parser,org.eclipse.mylyn.wikitext.parser.markup,org.eclipse.mylyn.wikitext.parser.markup.token" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.markdown.internal.block + -> Export-Package: org.eclipse.mylyn.wikitext.markdown.internal.block; bundle-symbolic-name="org.eclipse.mylyn.wikitext.markdown"; bundle-version="3.0.46.202301111837"; version="3.0.46"; x-internal:="true"; uses:="org.eclipse.mylyn.wikitext.markdown.internal.util,org.eclipse.mylyn.wikitext.parser.markup" + org.eclipse.mylyn.wikitext.markdown [861] + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.markdown.internal + -> Export-Package: org.eclipse.mylyn.wikitext.markdown.internal; bundle-symbolic-name="org.eclipse.mylyn.wikitext.markdown"; bundle-version="3.0.42.20220107230029"; version="3.0.42"; x-internal:="true"; uses:="org.eclipse.mylyn.wikitext.parser,org.eclipse.mylyn.wikitext.parser.builder,org.eclipse.mylyn.wikitext.parser.markup" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.markdown.internal.token + -> Export-Package: org.eclipse.mylyn.wikitext.markdown.internal.token; bundle-symbolic-name="org.eclipse.mylyn.wikitext.markdown"; bundle-version="3.0.42.20220107230029"; version="3.0.42"; x-internal:="true"; uses:="org.eclipse.mylyn.wikitext.parser.markup" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.markdown.internal.phrase + -> Export-Package: org.eclipse.mylyn.wikitext.markdown.internal.phrase; bundle-symbolic-name="org.eclipse.mylyn.wikitext.markdown"; bundle-version="3.0.42.20220107230029"; version="3.0.42"; x-internal:="true"; uses:="org.eclipse.mylyn.wikitext.parser,org.eclipse.mylyn.wikitext.parser.markup,org.eclipse.mylyn.wikitext.parser.markup.token" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.util; version="[3.0.0,4.0.0)" + -> Export-Package: org.eclipse.mylyn.wikitext.util; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.46.202301111837"; version="3.0.46"; uses:="javax.xml.stream,org.eclipse.mylyn.wikitext.parser,org.eclipse.mylyn.wikitext.parser.markup,org.xml.sax" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.markdown.internal.util + -> Export-Package: org.eclipse.mylyn.wikitext.markdown.internal.util; bundle-symbolic-name="org.eclipse.mylyn.wikitext.markdown"; bundle-version="3.0.42.20220107230029"; version="3.0.42"; x-internal:="true"; uses:="org.eclipse.mylyn.wikitext.markdown.internal.block,org.eclipse.mylyn.wikitext.parser,org.eclipse.mylyn.wikitext.parser.markup" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.markdown + -> Export-Package: org.eclipse.mylyn.wikitext.markdown; bundle-symbolic-name="org.eclipse.mylyn.wikitext.markdown"; bundle-version="3.0.48.202308291007"; version="3.0.48"; uses:="org.eclipse.mylyn.wikitext.parser,org.eclipse.mylyn.wikitext.parser.markup" + Unresolved requirement: Import-Package: com.google.common.base; version="[31.1.0,32.0.0)" + -> Export-Package: com.google.common.base; bundle-symbolic-name="com.google.guava"; bundle-version="31.1.0.jre"; version="31.1.0"; uses:="javax.annotation" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser.builder; version="[3.0.0,4.0.0)" + -> Export-Package: org.eclipse.mylyn.wikitext.parser.builder; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.46.202301111837"; version="3.0.46"; uses:="org.eclipse.mylyn.wikitext.parser,org.eclipse.mylyn.wikitext.parser.builder.event,org.eclipse.mylyn.wikitext.parser.outline,org.eclipse.mylyn.wikitext.util" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser.markup.token; version="[3.0.0,4.0.0)" + -> Export-Package: org.eclipse.mylyn.wikitext.parser.markup.token; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.42.20220107230029"; version="3.0.42"; uses:="org.eclipse.mylyn.wikitext.parser.markup" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser; version="[3.0.0,4.0.0)" + -> Export-Package: org.eclipse.mylyn.wikitext.parser; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.46.202301111837"; version="3.0.46"; uses:="org.eclipse.mylyn.wikitext.parser.markup,org.xml.sax" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.validation; version="[3.0.0,4.0.0)" + -> Export-Package: org.eclipse.mylyn.wikitext.validation; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.46.202301111837"; version="3.0.46"; uses:="org.eclipse.mylyn.wikitext.parser.markup" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser.markup.phrase; version="[3.0.0,4.0.0)" + -> Export-Package: org.eclipse.mylyn.wikitext.parser.markup.phrase; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.46.202301111837"; version="3.0.46"; uses:="org.eclipse.mylyn.wikitext.parser.markup" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser.markup; version="[3.0.0,4.0.0)" + -> Export-Package: org.eclipse.mylyn.wikitext.parser.markup; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.42.20220107230029"; version="3.0.42"; uses:="org.eclipse.mylyn.wikitext.parser,org.eclipse.mylyn.wikitext.parser.util" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.markdown.internal.block + -> Export-Package: org.eclipse.mylyn.wikitext.markdown.internal.block; bundle-symbolic-name="org.eclipse.mylyn.wikitext.markdown"; bundle-version="3.0.46.202301111837"; version="3.0.46"; x-internal:="true"; uses:="org.eclipse.mylyn.wikitext.markdown.internal.util,org.eclipse.mylyn.wikitext.parser.markup" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser.markup; version="[3.0.0,4.0.0)" + -> Export-Package: org.eclipse.mylyn.wikitext.parser.markup; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.42.20220107230029"; version="3.0.42"; uses:="org.eclipse.mylyn.wikitext.parser,org.eclipse.mylyn.wikitext.parser.util" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser.markup.token; version="[3.0.0,4.0.0)" + -> Export-Package: org.eclipse.mylyn.wikitext.parser.markup.token; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.42.20220107230029"; version="3.0.42"; uses:="org.eclipse.mylyn.wikitext.parser.markup" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.validation; version="[3.0.0,4.0.0)" + -> Export-Package: org.eclipse.mylyn.wikitext.validation; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.46.202301111837"; version="3.0.46"; uses:="org.eclipse.mylyn.wikitext.parser.markup" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser; version="[3.0.0,4.0.0)" + -> Export-Package: org.eclipse.mylyn.wikitext.parser; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.46.202301111837"; version="3.0.46"; uses:="org.eclipse.mylyn.wikitext.parser.markup,org.xml.sax" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser.builder; version="[3.0.0,4.0.0)" + -> Export-Package: org.eclipse.mylyn.wikitext.parser.builder; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.46.202301111837"; version="3.0.46"; uses:="org.eclipse.mylyn.wikitext.parser,org.eclipse.mylyn.wikitext.parser.builder.event,org.eclipse.mylyn.wikitext.parser.outline,org.eclipse.mylyn.wikitext.util" + Unresolved requirement: Import-Package: com.google.gson; version="2.7.0" + -> Export-Package: com.google.gson; bundle-symbolic-name="com.google.gson"; bundle-version="2.8.9.v20220111-1409"; version="2.8.9"; uses:="com.google.gson.internal,com.google.gson.reflect,com.google.gson.stream" + Unresolved requirement: Require-Bundle: org.eclipse.lsp4j.jsonrpc; bundle-version="[0.19.0,0.20.0)" + -> Bundle-SymbolicName: org.eclipse.lsp4j.jsonrpc; bundle-version="0.19.0.v20221118-0359" + + at org.eclipse.osgi.container.Module.start(Module.java:463) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1847) + at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1840) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1781) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1745) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1667) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) + at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234) + at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345) + +!ENTRY org.eclipse.lsp4e 4 0 2024-04-25 11:26:26.988 +!MESSAGE FrameworkEvent ERROR +!STACK 0 +org.osgi.framework.BundleException: Could not resolve module: org.eclipse.lsp4e [843] + Unresolved requirement: Require-Bundle: org.eclipse.lsp4j; bundle-version="[0.19.0,0.20.0)" + -> Bundle-SymbolicName: org.eclipse.lsp4j; bundle-version="0.19.0.v20221118-0359" + org.eclipse.lsp4j [846] + Unresolved requirement: Import-Package: com.google.gson; version="[2.9.1,2.10.0)" + -> Export-Package: com.google.gson; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1"; uses:="com.google.gson.internal,com.google.gson.reflect,com.google.gson.stream" + com.google.gson [620] + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.messages; version="[0.19.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc.messages; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.0.v20230517-2120"; version="0.21.0"; uses:="org.eclipse.lsp4j.jsonrpc.validation" + org.eclipse.lsp4j.jsonrpc [848] + Unresolved requirement: Import-Package: com.google.gson.internal; version="[2.9.1,2.11.0)" + -> Export-Package: com.google.gson.internal; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1"; x-internal:="true"; uses:="com.google.gson,com.google.gson.reflect,com.google.gson.stream" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc + -> Export-Package: org.eclipse.lsp4j.jsonrpc; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.1.v20230829-0012"; version="0.21.1"; uses:="com.google.gson,org.eclipse.lsp4j.jsonrpc.json,org.eclipse.lsp4j.jsonrpc.messages" + org.eclipse.lsp4j.jsonrpc [847] + Unresolved requirement: Import-Package: com.google.gson.annotations; version="[2.9.1,2.11.0)" + -> Export-Package: com.google.gson.annotations; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.messages + -> Export-Package: org.eclipse.lsp4j.jsonrpc.messages; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.0.v20230517-2120"; version="0.21.0"; uses:="org.eclipse.lsp4j.jsonrpc.validation" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.json.adapters + -> Export-Package: org.eclipse.lsp4j.jsonrpc.json.adapters; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.0.v20230517-2120"; version="0.21.0"; uses:="com.google.gson,com.google.gson.reflect,com.google.gson.stream,org.eclipse.lsp4j.jsonrpc.json,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Import-Package: com.google.gson; version="[2.9.1,2.11.0)" + -> Export-Package: com.google.gson; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1"; uses:="com.google.gson.internal,com.google.gson.reflect,com.google.gson.stream" + Unresolved requirement: Import-Package: com.google.gson.stream; version="[2.9.1,2.11.0)" + -> Export-Package: com.google.gson.stream; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1" + Unresolved requirement: Import-Package: com.google.gson.reflect; version="[2.9.1,2.11.0)" + -> Export-Package: com.google.gson.reflect; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.json + -> Export-Package: org.eclipse.lsp4j.jsonrpc.json; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.19.0.v20221118-0359"; version="0.19.0"; uses:="com.google.gson,org.eclipse.lsp4j.jsonrpc,org.eclipse.lsp4j.jsonrpc.messages" + org.eclipse.lsp4j.jsonrpc [849] + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.json.adapters + -> Export-Package: org.eclipse.lsp4j.jsonrpc.json.adapters; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.0.v20230517-2120"; version="0.21.0"; uses:="com.google.gson,com.google.gson.reflect,com.google.gson.stream,org.eclipse.lsp4j.jsonrpc.json,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Import-Package: com.google.gson; version="[2.9.1,2.10.0)" + -> Export-Package: com.google.gson; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1"; uses:="com.google.gson.internal,com.google.gson.reflect,com.google.gson.stream" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.services + -> Export-Package: org.eclipse.lsp4j.jsonrpc.services; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.1.v20230829-0012"; version="0.21.1"; uses:="org.eclipse.lsp4j.jsonrpc,org.eclipse.lsp4j.jsonrpc.json" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc + -> Export-Package: org.eclipse.lsp4j.jsonrpc; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.1.v20230829-0012"; version="0.21.1"; uses:="com.google.gson,org.eclipse.lsp4j.jsonrpc.json,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Import-Package: com.google.gson.annotations; version="[2.9.1,2.10.0)" + -> Export-Package: com.google.gson.annotations; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.messages + -> Export-Package: org.eclipse.lsp4j.jsonrpc.messages; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.0.v20230517-2120"; version="0.21.0"; uses:="org.eclipse.lsp4j.jsonrpc.validation" + Unresolved requirement: Import-Package: com.google.gson.reflect; version="[2.9.1,2.10.0)" + -> Export-Package: com.google.gson.reflect; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1" + Unresolved requirement: Import-Package: com.google.gson.stream; version="[2.9.1,2.10.0)" + -> Export-Package: com.google.gson.stream; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.validation + -> Export-Package: org.eclipse.lsp4j.jsonrpc.validation; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.19.0.v20221118-0359"; version="0.19.0"; uses:="org.eclipse.lsp4j.jsonrpc,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Import-Package: com.google.gson; version="[2.9.1,2.11.0)" + -> Export-Package: com.google.gson; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1"; uses:="com.google.gson.internal,com.google.gson.reflect,com.google.gson.stream" + Unresolved requirement: Import-Package: com.google.gson.stream; version="[2.9.1,2.11.0)" + -> Export-Package: com.google.gson.stream; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.services + -> Export-Package: org.eclipse.lsp4j.jsonrpc.services; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.1.v20230829-0012"; version="0.21.1"; uses:="org.eclipse.lsp4j.jsonrpc,org.eclipse.lsp4j.jsonrpc.json" + Unresolved requirement: Import-Package: com.google.gson.reflect; version="[2.9.1,2.11.0)" + -> Export-Package: com.google.gson.reflect; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.json + -> Export-Package: org.eclipse.lsp4j.jsonrpc.json; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.19.0.v20221118-0359"; version="0.19.0"; uses:="com.google.gson,org.eclipse.lsp4j.jsonrpc,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.validation + -> Export-Package: org.eclipse.lsp4j.jsonrpc.validation; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.19.0.v20221118-0359"; version="0.19.0"; uses:="org.eclipse.lsp4j.jsonrpc,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Import-Package: com.google.gson.annotations; version="[2.9.1,2.11.0)" + -> Export-Package: com.google.gson.annotations; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.validation; version="[0.19.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc.validation; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.19.0.v20221118-0359"; version="0.19.0"; uses:="org.eclipse.lsp4j.jsonrpc,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.json.adapters; version="[0.19.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc.json.adapters; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.19.0.v20221118-0359"; version="0.19.0"; uses:="com.google.gson,com.google.gson.reflect,com.google.gson.stream,org.eclipse.lsp4j.jsonrpc.json,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Import-Package: com.google.common.base; version="[30.1.0,31.0.0)" + -> Export-Package: com.google.common.base; bundle-symbolic-name="com.google.guava"; bundle-version="30.1.0.v20210127-2300"; version="30.1.0"; uses:="com.google.errorprone.annotations,org.checkerframework.checker.nullness.qual" + com.google.guava [1027] + Unresolved requirement: Import-Package: com.google.errorprone.annotations; version="[3.0.0,4.0.0)"; resolution:="optional" + Unresolved requirement: Import-Package: com.google.errorprone.annotations.concurrent; version="[3.0.0,4.0.0)"; resolution:="optional" + Unresolved requirement: Import-Package: javax.crypto; version="[3.0.0,4.0.0)"; resolution:="optional" + Unresolved requirement: Import-Package: javax.crypto.spec; version="[3.0.0,4.0.0)"; resolution:="optional" + Unresolved requirement: Import-Package: org.checkerframework.checker.nullness.qual; version="[3.5.0,4.0.0)"; resolution:="optional" + Unresolved requirement: Import-Package: org.eclipse.lsp4j + -> Export-Package: org.eclipse.lsp4j; bundle-symbolic-name="org.eclipse.lsp4j"; bundle-version="0.14.0.v20220526-1518"; version="0.14.0.v20220526-1518"; uses:="com.google.gson.annotations,org.eclipse.lsp4j.adapters,org.eclipse.lsp4j.jsonrpc.messages,org.eclipse.lsp4j.jsonrpc.validation,org.eclipse.xtext.xbase.lib" + org.eclipse.lsp4j [1069] + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc; version="[0.14.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.1.v20230829-0012"; version="0.21.1"; uses:="com.google.gson,org.eclipse.lsp4j.jsonrpc.json,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Import-Package: com.google.gson.reflect; version="[2.8.9,2.9.0)" + -> Export-Package: com.google.gson.reflect; bundle-symbolic-name="com.google.gson"; bundle-version="2.8.9.v20220111-1409"; version="2.8.9" + com.google.gson [1026] + Unresolved requirement: Import-Package: com.google.gson.internal.sql; version="[2.8.0,3.0.0)" + -> Export-Package: com.google.gson.internal.sql; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1"; x-internal:="true"; uses:="com.google.gson,com.google.gson.internal.bind" + Unresolved requirement: Import-Package: com.google.gson.annotations; version="[2.8.0,3.0.0)" + -> Export-Package: com.google.gson.annotations; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1" + Unresolved requirement: Import-Package: com.google.gson.reflect; version="[2.8.0,3.0.0)" + -> Export-Package: com.google.gson.reflect; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1" + Unresolved requirement: Import-Package: com.google.gson.internal.reflect; version="[2.8.0,3.0.0)" + -> Export-Package: com.google.gson.internal.reflect; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1"; x-internal:="true"; uses:="com.google.gson" + Unresolved requirement: Import-Package: com.google.gson.internal.bind.util; version="[2.8.0,3.0.0)" + -> Export-Package: com.google.gson.internal.bind.util; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1"; x-internal:="true" + Unresolved requirement: Import-Package: com.google.gson.internal; version="[2.8.0,3.0.0)" + -> Export-Package: com.google.gson.internal; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1"; x-internal:="true"; uses:="com.google.gson,com.google.gson.reflect,com.google.gson.stream" + Unresolved requirement: Import-Package: com.google.gson.stream; version="[2.8.9,2.9.0)" + -> Export-Package: com.google.gson.stream; bundle-symbolic-name="com.google.gson"; bundle-version="2.8.9.v20220111-1409"; version="2.8.9" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.json; version="[0.14.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc.json; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.19.0.v20221118-0359"; version="0.19.0"; uses:="com.google.gson,org.eclipse.lsp4j.jsonrpc,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.messages; version="[0.14.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc.messages; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.0.v20230517-2120"; version="0.21.0"; uses:="org.eclipse.lsp4j.jsonrpc.validation" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.validation; version="[0.14.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc.validation; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.19.0.v20221118-0359"; version="0.19.0"; uses:="org.eclipse.lsp4j.jsonrpc,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.services; version="[0.14.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.services; bundle-symbolic-name="org.eclipse.lsp4j"; bundle-version="0.21.1.v20230829-0012"; version="0.21.1"; uses:="org.eclipse.lsp4j,org.eclipse.lsp4j.adapters,org.eclipse.lsp4j.jsonrpc.json,org.eclipse.lsp4j.jsonrpc.messages,org.eclipse.lsp4j.jsonrpc.services" + org.eclipse.lsp4j [844] + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.json.adapters; version="[0.21.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc.json.adapters; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.0.v20230517-2120"; version="0.21.0"; uses:="com.google.gson,com.google.gson.reflect,com.google.gson.stream,org.eclipse.lsp4j.jsonrpc.json,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Import-Package: com.google.gson.stream; version="[2.9.1,2.11.0)" + -> Export-Package: com.google.gson.stream; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.util + -> Export-Package: org.eclipse.lsp4j.util; bundle-symbolic-name="org.eclipse.lsp4j"; bundle-version="0.19.0.v20221118-0359"; version="0.19.0"; uses:="org.eclipse.lsp4j" + Unresolved requirement: Import-Package: com.google.gson.annotations; version="[2.9.1,2.11.0)" + -> Export-Package: com.google.gson.annotations; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1" + Unresolved requirement: Import-Package: com.google.gson.reflect; version="[2.9.1,2.11.0)" + -> Export-Package: com.google.gson.reflect; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.validation; version="[0.21.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc.validation; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.0.v20230517-2120"; version="0.21.0"; uses:="org.eclipse.lsp4j.jsonrpc,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc; version="[0.21.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.1.v20230829-0012"; version="0.21.1"; uses:="com.google.gson,org.eclipse.lsp4j.jsonrpc.json,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Import-Package: org.eclipse.lsp4j + -> Export-Package: org.eclipse.lsp4j; bundle-symbolic-name="org.eclipse.lsp4j"; bundle-version="0.14.0.v20220526-1518"; version="0.14.0.v20220526-1518"; uses:="com.google.gson.annotations,org.eclipse.lsp4j.adapters,org.eclipse.lsp4j.jsonrpc.messages,org.eclipse.lsp4j.jsonrpc.validation,org.eclipse.xtext.xbase.lib" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.json; version="[0.21.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc.json; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.1.v20230829-0012"; version="0.21.1"; uses:="com.google.gson,org.eclipse.lsp4j.jsonrpc,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Import-Package: com.google.gson; version="[2.9.1,2.11.0)" + -> Export-Package: com.google.gson; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1"; uses:="com.google.gson.internal,com.google.gson.reflect,com.google.gson.stream" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.adapters + -> Export-Package: org.eclipse.lsp4j.adapters; bundle-symbolic-name="org.eclipse.lsp4j"; bundle-version="0.21.0.v20230517-2120"; version="0.21.0"; uses:="com.google.gson,com.google.gson.reflect,com.google.gson.stream,org.eclipse.lsp4j,org.eclipse.lsp4j.jsonrpc.messages" + org.eclipse.lsp4j [845] + Unresolved requirement: Import-Package: com.google.gson.annotations; version="[2.9.1,2.11.0)" + -> Export-Package: com.google.gson.annotations; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1" + Unresolved requirement: Import-Package: com.google.gson.reflect; version="[2.9.1,2.11.0)" + -> Export-Package: com.google.gson.reflect; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc; version="[0.21.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.1.v20230829-0012"; version="0.21.1"; uses:="com.google.gson,org.eclipse.lsp4j.jsonrpc.json,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.json; version="[0.21.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc.json; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.1.v20230829-0012"; version="0.21.1"; uses:="com.google.gson,org.eclipse.lsp4j.jsonrpc,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Import-Package: com.google.gson; version="[2.9.1,2.11.0)" + -> Export-Package: com.google.gson; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1"; uses:="com.google.gson.internal,com.google.gson.reflect,com.google.gson.stream" + Unresolved requirement: Import-Package: com.google.gson.stream; version="[2.9.1,2.11.0)" + -> Export-Package: com.google.gson.stream; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1" + Unresolved requirement: Import-Package: org.eclipse.lsp4j + -> Export-Package: org.eclipse.lsp4j; bundle-symbolic-name="org.eclipse.lsp4j"; bundle-version="0.14.0.v20220526-1518"; version="0.14.0.v20220526-1518"; uses:="com.google.gson.annotations,org.eclipse.lsp4j.adapters,org.eclipse.lsp4j.jsonrpc.messages,org.eclipse.lsp4j.jsonrpc.validation,org.eclipse.xtext.xbase.lib" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.services + -> Export-Package: org.eclipse.lsp4j.services; bundle-symbolic-name="org.eclipse.lsp4j"; bundle-version="0.21.1.v20230829-0012"; version="0.21.1"; uses:="org.eclipse.lsp4j,org.eclipse.lsp4j.adapters,org.eclipse.lsp4j.jsonrpc.json,org.eclipse.lsp4j.jsonrpc.messages,org.eclipse.lsp4j.jsonrpc.services" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.validation; version="[0.21.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc.validation; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.0.v20230517-2120"; version="0.21.0"; uses:="org.eclipse.lsp4j.jsonrpc,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.json.adapters; version="[0.21.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc.json.adapters; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.0.v20230517-2120"; version="0.21.0"; uses:="com.google.gson,com.google.gson.reflect,com.google.gson.stream,org.eclipse.lsp4j.jsonrpc.json,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.messages; version="[0.21.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc.messages; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.0.v20230517-2120"; version="0.21.0"; uses:="org.eclipse.lsp4j.jsonrpc.validation" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.util + -> Export-Package: org.eclipse.lsp4j.util; bundle-symbolic-name="org.eclipse.lsp4j"; bundle-version="0.19.0.v20221118-0359"; version="0.19.0"; uses:="org.eclipse.lsp4j" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.services; version="[0.21.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc.services; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.0.v20230517-2120"; version="0.21.0"; uses:="org.eclipse.lsp4j.jsonrpc,org.eclipse.lsp4j.jsonrpc.json" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.messages; version="[0.21.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc.messages; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.0.v20230517-2120"; version="0.21.0"; uses:="org.eclipse.lsp4j.jsonrpc.validation" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.services; version="[0.21.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc.services; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.0.v20230517-2120"; version="0.21.0"; uses:="org.eclipse.lsp4j.jsonrpc,org.eclipse.lsp4j.jsonrpc.json" + Unresolved requirement: Import-Package: com.google.gson; version="[2.8.9,2.9.0)" + -> Export-Package: com.google.gson; bundle-symbolic-name="com.google.gson"; bundle-version="2.8.9.v20220111-1409"; version="2.8.9"; uses:="com.google.gson.internal,com.google.gson.reflect,com.google.gson.stream" + Unresolved requirement: Import-Package: com.google.common.base; version="[14.0.0,31.0.0)" + -> Export-Package: com.google.common.base; bundle-symbolic-name="com.google.guava"; bundle-version="30.1.0.v20210127-2300"; version="30.1.0"; uses:="com.google.errorprone.annotations,org.checkerframework.checker.nullness.qual" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.util; version="[0.14.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.util; bundle-symbolic-name="org.eclipse.lsp4j"; bundle-version="0.19.0.v20221118-0359"; version="0.19.0"; uses:="org.eclipse.lsp4j" + Unresolved requirement: Import-Package: org.eclipse.xtext.xbase.lib.util; version="[2.24.0,3.0.0)" + -> Export-Package: org.eclipse.xtext.xbase.lib.util; bundle-symbolic-name="org.eclipse.xtext.xbase.lib"; bundle-version="2.29.0.v20221121-0915"; version="2.29.0" + org.eclipse.xtext.xbase.lib [943] + Unresolved requirement: Require-Bundle: com.google.guava; bundle-version="[30.1.0,31.0.0)"; visibility:="reexport" + -> Bundle-SymbolicName: com.google.guava; bundle-version="30.1.0.v20210127-2300" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.services; version="[0.14.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc.services; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.1.v20230829-0012"; version="0.21.1"; uses:="org.eclipse.lsp4j.jsonrpc,org.eclipse.lsp4j.jsonrpc.json" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.adapters; version="[0.14.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.adapters; bundle-symbolic-name="org.eclipse.lsp4j"; bundle-version="0.21.0.v20230517-2120"; version="0.21.0"; uses:="com.google.gson,com.google.gson.reflect,com.google.gson.stream,org.eclipse.lsp4j,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Import-Package: com.google.gson.annotations; version="[2.8.9,2.9.0)" + -> Export-Package: com.google.gson.annotations; bundle-symbolic-name="com.google.gson"; bundle-version="2.8.9.v20220111-1409"; version="2.8.9" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.json.adapters; version="[0.14.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc.json.adapters; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.0.v20230517-2120"; version="0.21.0"; uses:="com.google.gson,com.google.gson.reflect,com.google.gson.stream,org.eclipse.lsp4j.jsonrpc.json,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Import-Package: org.eclipse.xtext.xbase.lib; version="[2.24.0,3.0.0)" + -> Export-Package: org.eclipse.xtext.xbase.lib; bundle-symbolic-name="org.eclipse.xtext.xbase.lib"; bundle-version="2.29.0.v20221121-0915"; version="2.29.0" + Unresolved requirement: Import-Package: com.google.gson.reflect; version="[2.9.1,2.10.0)" + -> Export-Package: com.google.gson.reflect; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc; version="[0.19.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.1.v20230829-0012"; version="0.21.1"; uses:="com.google.gson,org.eclipse.lsp4j.jsonrpc.json,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Import-Package: com.google.gson.annotations; version="[2.9.1,2.10.0)" + -> Export-Package: com.google.gson.annotations; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.services; version="[0.19.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc.services; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.21.0.v20230517-2120"; version="0.21.0"; uses:="org.eclipse.lsp4j.jsonrpc,org.eclipse.lsp4j.jsonrpc.json" + Unresolved requirement: Import-Package: org.eclipse.xtext.xbase.lib.util; version="[2.28.0,3.0.0)" + -> Export-Package: org.eclipse.xtext.xbase.lib.util; bundle-symbolic-name="org.eclipse.xtext.xbase.lib"; bundle-version="2.29.0.v20221121-0915"; version="2.29.0" + Unresolved requirement: Import-Package: com.google.gson.stream; version="[2.9.1,2.10.0)" + -> Export-Package: com.google.gson.stream; bundle-symbolic-name="com.google.gson"; bundle-version="2.9.1.v20220915-1632"; version="2.9.1" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.adapters + -> Export-Package: org.eclipse.lsp4j.adapters; bundle-symbolic-name="org.eclipse.lsp4j"; bundle-version="0.21.0.v20230517-2120"; version="0.21.0"; uses:="com.google.gson,com.google.gson.reflect,com.google.gson.stream,org.eclipse.lsp4j,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.services + -> Export-Package: org.eclipse.lsp4j.services; bundle-symbolic-name="org.eclipse.lsp4j"; bundle-version="0.21.1.v20230829-0012"; version="0.21.1"; uses:="org.eclipse.lsp4j,org.eclipse.lsp4j.adapters,org.eclipse.lsp4j.jsonrpc.json,org.eclipse.lsp4j.jsonrpc.messages,org.eclipse.lsp4j.jsonrpc.services" + Unresolved requirement: Import-Package: org.eclipse.xtext.xbase.lib; version="[2.28.0,3.0.0)" + -> Export-Package: org.eclipse.xtext.xbase.lib; bundle-symbolic-name="org.eclipse.xtext.xbase.lib"; bundle-version="2.29.0.v20221121-0915"; version="2.29.0" + Unresolved requirement: Import-Package: org.eclipse.lsp4j.jsonrpc.json; version="[0.19.0,1.0.0)" + -> Export-Package: org.eclipse.lsp4j.jsonrpc.json; bundle-symbolic-name="org.eclipse.lsp4j.jsonrpc"; bundle-version="0.19.0.v20221118-0359"; version="0.19.0"; uses:="com.google.gson,org.eclipse.lsp4j.jsonrpc,org.eclipse.lsp4j.jsonrpc.messages" + Unresolved requirement: Require-Bundle: org.eclipse.mylyn.wikitext; bundle-version="3.0.40" + -> Bundle-SymbolicName: org.eclipse.mylyn.wikitext; bundle-version="3.0.42.20220107230029" + org.eclipse.mylyn.wikitext [361] + Unresolved requirement: Import-Package: org.jsoup; version="[1.14.0,2.0.0)" + -> Export-Package: org.jsoup; bundle-symbolic-name="org.jsoup"; bundle-version="1.14.3.v20211012-1727"; version="1.14.3"; uses:="javax.annotation,javax.net.ssl,org.jsoup.nodes,org.jsoup.parser,org.jsoup.safety" + org.jsoup [1113] + Unresolved requirement: Import-Package: javax.annotation.meta; resolution:="optional" + Unresolved requirement: Import-Package: com.google.common.collect; version="[30.1.0,31.0.0)" + -> Export-Package: com.google.common.collect; bundle-symbolic-name="com.google.guava"; bundle-version="30.1.0.v20210127-2300"; version="30.1.0"; uses:="com.google.common.base,com.google.errorprone.annotations,org.checkerframework.checker.nullness.qual" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser.builder + -> Export-Package: org.eclipse.mylyn.wikitext.parser.builder; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.46.202301111837"; version="3.0.46"; uses:="org.eclipse.mylyn.wikitext.parser,org.eclipse.mylyn.wikitext.parser.builder.event,org.eclipse.mylyn.wikitext.parser.outline,org.eclipse.mylyn.wikitext.util" + org.eclipse.mylyn.wikitext [851] + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser.builder.event + -> Export-Package: org.eclipse.mylyn.wikitext.parser.builder.event; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.42.20220107230029"; version="3.0.42"; uses:="org.eclipse.mylyn.wikitext.parser" + Unresolved requirement: Import-Package: com.google.common.base; version="[31.1.0,32.0.0)" + -> Export-Package: com.google.common.base; bundle-symbolic-name="com.google.guava"; bundle-version="31.1.0.jre"; version="31.1.0"; uses:="javax.annotation" + com.google.guava [623] + Unresolved requirement: Import-Package: javax.annotation; version="[3.0.0,4.0.0)"; resolution:="optional" + Unresolved requirement: Import-Package: com.google.common.xml; version="[31.1.0,32.0.0)" + -> Export-Package: com.google.common.xml; bundle-symbolic-name="com.google.guava"; bundle-version="31.1.0.jre"; version="31.1.0"; uses:="com.google.common.escape" + Unresolved requirement: Import-Package: org.jsoup; version="[1.15.0,2.0.0)" + -> Export-Package: org.jsoup; bundle-symbolic-name="org.jsoup"; bundle-version="1.15.3"; version="1.15.3"; uses:="javax.annotation,javax.net.ssl,org.jsoup.nodes,org.jsoup.parser,org.jsoup.safety" + org.jsoup [978] + Unresolved requirement: Import-Package: javax.annotation.meta; resolution:="optional" + Unresolved requirement: Import-Package: org.jsoup.internal + -> Export-Package: org.jsoup.internal; bundle-symbolic-name="org.jsoup"; bundle-version="1.14.3.v20211012-1727"; version="1.14.3"; x-internal:="true"; uses:="javax.annotation,javax.annotation.meta" + Unresolved requirement: Import-Package: org.jsoup + -> Export-Package: org.jsoup; bundle-symbolic-name="org.jsoup"; bundle-version="1.14.3.v20211012-1727"; version="1.14.3"; uses:="javax.annotation,javax.net.ssl,org.jsoup.nodes,org.jsoup.parser,org.jsoup.safety" + Unresolved requirement: Import-Package: org.jsoup.parser + -> Export-Package: org.jsoup.parser; bundle-symbolic-name="org.jsoup"; bundle-version="1.14.3.v20211012-1727"; version="1.14.3"; uses:="javax.annotation,org.jsoup.nodes" + Unresolved requirement: Import-Package: org.jsoup.helper + -> Export-Package: org.jsoup.helper; bundle-symbolic-name="org.jsoup"; bundle-version="1.14.3.v20211012-1727"; version="1.14.3"; uses:="javax.annotation,javax.net.ssl,javax.xml.parsers,org.jsoup,org.jsoup.nodes,org.jsoup.parser,org.jsoup.select,org.w3c.dom" + Unresolved requirement: Import-Package: org.jsoup.safety + -> Export-Package: org.jsoup.safety; bundle-symbolic-name="org.jsoup"; bundle-version="1.14.3.v20211012-1727"; version="1.14.3"; uses:="org.jsoup.nodes" + Unresolved requirement: Import-Package: org.jsoup.select + -> Export-Package: org.jsoup.select; bundle-symbolic-name="org.jsoup"; bundle-version="1.14.3.v20211012-1727"; version="1.14.3"; uses:="javax.annotation,org.jsoup.nodes" + Unresolved requirement: Import-Package: org.jsoup.select; version="[1.15.0,2.0.0)" + -> Export-Package: org.jsoup.select; bundle-symbolic-name="org.jsoup"; bundle-version="1.15.3"; version="1.15.3"; uses:="javax.annotation,org.jsoup.nodes" + Unresolved requirement: Import-Package: com.google.common.collect; version="[31.1.0,32.0.0)" + -> Export-Package: com.google.common.collect; bundle-symbolic-name="com.google.guava"; bundle-version="31.1.0.jre"; version="31.1.0"; uses:="com.google.common.base,javax.annotation" + Unresolved requirement: Import-Package: com.google.common.escape; version="[31.1.0,32.0.0)" + -> Export-Package: com.google.common.escape; bundle-symbolic-name="com.google.guava"; bundle-version="31.1.0.jre"; version="31.1.0"; uses:="com.google.common.base,javax.annotation" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser.outline + -> Export-Package: org.eclipse.mylyn.wikitext.parser.outline; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.42.20220107230029"; version="3.0.42"; uses:="org.eclipse.mylyn.wikitext.parser,org.eclipse.mylyn.wikitext.parser.markup" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser.markup.block + -> Export-Package: org.eclipse.mylyn.wikitext.parser.markup.block; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.42.20220107230029"; version="3.0.42"; uses:="org.eclipse.mylyn.wikitext.parser.markup,org.eclipse.mylyn.wikitext.parser.outline" + Unresolved requirement: Import-Package: org.jsoup.nodes; version="[1.15.0,2.0.0)" + -> Export-Package: org.jsoup.nodes; bundle-symbolic-name="org.jsoup"; bundle-version="1.15.3"; version="1.15.3"; uses:="javax.annotation,org.jsoup,org.jsoup.helper,org.jsoup.parser,org.jsoup.select" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.internal.parser.html + -> Export-Package: org.eclipse.mylyn.wikitext.internal.parser.html; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.42.20220107230029"; version="3.0.42"; x-internal:="true"; uses:="org.eclipse.mylyn.wikitext.parser,org.jsoup.nodes,org.xml.sax" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser.markup + -> Export-Package: org.eclipse.mylyn.wikitext.parser.markup; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.42.20220107230029"; version="3.0.42"; uses:="org.eclipse.mylyn.wikitext.parser,org.eclipse.mylyn.wikitext.parser.util" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser.markup.token + -> Export-Package: org.eclipse.mylyn.wikitext.parser.markup.token; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.42.20220107230029"; version="3.0.42"; uses:="org.eclipse.mylyn.wikitext.parser.markup" + Unresolved requirement: Import-Package: org.jsoup.internal; version="[1.15.0,2.0.0)" + -> Export-Package: org.jsoup.internal; bundle-symbolic-name="org.jsoup"; bundle-version="1.15.3"; version="1.15.3"; uses:="javax.annotation,javax.annotation.meta" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.util + -> Export-Package: org.eclipse.mylyn.wikitext.util; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.46.202301111837"; version="3.0.46"; uses:="javax.xml.stream,org.eclipse.mylyn.wikitext.parser,org.eclipse.mylyn.wikitext.parser.markup,org.xml.sax" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser.css + -> Export-Package: org.eclipse.mylyn.wikitext.parser.css; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.46.202301111837"; version="3.0.46" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.internal.util + -> Export-Package: org.eclipse.mylyn.wikitext.internal.util; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.46.202301111837"; version="3.0.46"; x-internal:="true" + Unresolved requirement: Import-Package: org.jsoup.internal; version="[1.14.0,2.0.0)" + -> Export-Package: org.jsoup.internal; bundle-symbolic-name="org.jsoup"; bundle-version="1.14.3.v20211012-1727"; version="1.14.3"; x-internal:="true"; uses:="javax.annotation,javax.annotation.meta" + Unresolved requirement: Import-Package: org.jsoup.nodes; version="[1.14.0,2.0.0)" + -> Export-Package: org.jsoup.nodes; bundle-symbolic-name="org.jsoup"; bundle-version="1.15.3"; version="1.15.3"; uses:="javax.annotation,org.jsoup,org.jsoup.helper,org.jsoup.parser,org.jsoup.select" + Unresolved requirement: Import-Package: com.google.common.base; version="[30.1.0,31.0.0)" + -> Export-Package: com.google.common.base; bundle-symbolic-name="com.google.guava"; bundle-version="30.1.0.v20210127-2300"; version="30.1.0"; uses:="com.google.errorprone.annotations,org.checkerframework.checker.nullness.qual" + Unresolved requirement: Import-Package: com.google.common.xml; version="[30.1.0,31.0.0)" + -> Export-Package: com.google.common.xml; bundle-symbolic-name="com.google.guava"; bundle-version="30.1.0.v20210127-2300"; version="30.1.0"; uses:="com.google.common.escape" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser.util + -> Export-Package: org.eclipse.mylyn.wikitext.parser.util; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.46.202301111837"; version="3.0.46"; uses:="org.eclipse.mylyn.wikitext.parser.markup,org.eclipse.mylyn.wikitext.parser.outline,org.eclipse.mylyn.wikitext.util" + Unresolved requirement: Import-Package: org.jsoup.select; version="[1.14.0,2.0.0)" + -> Export-Package: org.jsoup.select; bundle-symbolic-name="org.jsoup"; bundle-version="1.14.3.v20211012-1727"; version="1.14.3"; uses:="javax.annotation,org.jsoup.nodes" + Unresolved requirement: Import-Package: com.google.common.escape; version="[30.1.0,31.0.0)" + -> Export-Package: com.google.common.escape; bundle-symbolic-name="com.google.guava"; bundle-version="30.1.0.v20210127-2300"; version="30.1.0"; uses:="com.google.common.base,com.google.errorprone.annotations,org.checkerframework.checker.nullness.qual" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser + -> Export-Package: org.eclipse.mylyn.wikitext.parser; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.46.202301111837"; version="3.0.46"; uses:="org.eclipse.mylyn.wikitext.parser.markup,org.xml.sax" + Unresolved requirement: Import-Package: com.google.common.base + -> Export-Package: com.google.common.base; bundle-symbolic-name="com.google.guava"; bundle-version="32.1.2.jre"; version="32.1.2"; uses:="javax.annotation" + com.google.guava [622] + Unresolved requirement: Import-Package: javax.annotation; version="[3.0.0,4.0.0)"; resolution:="optional" + Unresolved requirement: Require-Bundle: com.google.guava; bundle-version="30.1.0" + -> Bundle-SymbolicName: com.google.guava; bundle-version="32.1.2.jre" + Unresolved requirement: Require-Bundle: org.eclipse.mylyn.wikitext.markdown; bundle-version="3.0.40" + -> Bundle-SymbolicName: org.eclipse.mylyn.wikitext.markdown; bundle-version="3.0.42.20220107230029" + org.eclipse.mylyn.wikitext.markdown [369] + Unresolved requirement: Import-Package: com.google.common.collect; version="[30.1.0,31.0.0)" + -> Export-Package: com.google.common.collect; bundle-symbolic-name="com.google.guava"; bundle-version="30.1.0.v20210127-2300"; version="30.1.0"; uses:="com.google.common.base,com.google.errorprone.annotations,org.checkerframework.checker.nullness.qual" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser.markup.phrase; version="[3.0.0,4.0.0)" + -> Export-Package: org.eclipse.mylyn.wikitext.parser.markup.phrase; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.46.202301111837"; version="3.0.46"; uses:="org.eclipse.mylyn.wikitext.parser.markup" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.util; version="[3.0.0,4.0.0)" + -> Export-Package: org.eclipse.mylyn.wikitext.util; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.46.202301111837"; version="3.0.46"; uses:="javax.xml.stream,org.eclipse.mylyn.wikitext.parser,org.eclipse.mylyn.wikitext.parser.markup,org.xml.sax" + Unresolved requirement: Import-Package: com.google.common.base; version="[30.1.0,31.0.0)" + -> Export-Package: com.google.common.base; bundle-symbolic-name="com.google.guava"; bundle-version="30.1.0.v20210127-2300"; version="30.1.0"; uses:="com.google.errorprone.annotations,org.checkerframework.checker.nullness.qual" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.markdown + -> Export-Package: org.eclipse.mylyn.wikitext.markdown; bundle-symbolic-name="org.eclipse.mylyn.wikitext.markdown"; bundle-version="3.0.48.202308291007"; version="3.0.48"; uses:="org.eclipse.mylyn.wikitext.parser,org.eclipse.mylyn.wikitext.parser.markup" + org.eclipse.mylyn.wikitext.markdown [860] + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.util; version="[3.0.0,4.0.0)" + -> Export-Package: org.eclipse.mylyn.wikitext.util; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.46.202301111837"; version="3.0.46"; uses:="javax.xml.stream,org.eclipse.mylyn.wikitext.parser,org.eclipse.mylyn.wikitext.parser.markup,org.xml.sax" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser.builder; version="[3.0.0,4.0.0)" + -> Export-Package: org.eclipse.mylyn.wikitext.parser.builder; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.46.202301111837"; version="3.0.46"; uses:="org.eclipse.mylyn.wikitext.parser,org.eclipse.mylyn.wikitext.parser.builder.event,org.eclipse.mylyn.wikitext.parser.outline,org.eclipse.mylyn.wikitext.util" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser.markup; version="[3.0.0,4.0.0)" + -> Export-Package: org.eclipse.mylyn.wikitext.parser.markup; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.42.20220107230029"; version="3.0.42"; uses:="org.eclipse.mylyn.wikitext.parser,org.eclipse.mylyn.wikitext.parser.util" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.markdown.internal + -> Export-Package: org.eclipse.mylyn.wikitext.markdown.internal; bundle-symbolic-name="org.eclipse.mylyn.wikitext.markdown"; bundle-version="3.0.42.20220107230029"; version="3.0.42"; x-internal:="true"; uses:="org.eclipse.mylyn.wikitext.parser,org.eclipse.mylyn.wikitext.parser.builder,org.eclipse.mylyn.wikitext.parser.markup" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.markdown.internal.token + -> Export-Package: org.eclipse.mylyn.wikitext.markdown.internal.token; bundle-symbolic-name="org.eclipse.mylyn.wikitext.markdown"; bundle-version="3.0.42.20220107230029"; version="3.0.42"; x-internal:="true"; uses:="org.eclipse.mylyn.wikitext.parser.markup" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.validation; version="[3.0.0,4.0.0)" + -> Export-Package: org.eclipse.mylyn.wikitext.validation; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.46.202301111837"; version="3.0.46"; uses:="org.eclipse.mylyn.wikitext.parser.markup" + Unresolved requirement: Import-Package: com.google.common.base; version="[31.1.0,33.0.0)" + -> Export-Package: com.google.common.base; bundle-symbolic-name="com.google.guava"; bundle-version="32.1.2.jre"; version="32.1.2"; uses:="javax.annotation" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser.markup.phrase; version="[3.0.0,4.0.0)" + -> Export-Package: org.eclipse.mylyn.wikitext.parser.markup.phrase; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.46.202301111837"; version="3.0.46"; uses:="org.eclipse.mylyn.wikitext.parser.markup" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser; version="[3.0.0,4.0.0)" + -> Export-Package: org.eclipse.mylyn.wikitext.parser; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.46.202301111837"; version="3.0.46"; uses:="org.eclipse.mylyn.wikitext.parser.markup,org.xml.sax" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser.markup.token; version="[3.0.0,4.0.0)" + -> Export-Package: org.eclipse.mylyn.wikitext.parser.markup.token; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.42.20220107230029"; version="3.0.42"; uses:="org.eclipse.mylyn.wikitext.parser.markup" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.markdown.internal.util + -> Export-Package: org.eclipse.mylyn.wikitext.markdown.internal.util; bundle-symbolic-name="org.eclipse.mylyn.wikitext.markdown"; bundle-version="3.0.42.20220107230029"; version="3.0.42"; x-internal:="true"; uses:="org.eclipse.mylyn.wikitext.markdown.internal.block,org.eclipse.mylyn.wikitext.parser,org.eclipse.mylyn.wikitext.parser.markup" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.markdown.internal.phrase + -> Export-Package: org.eclipse.mylyn.wikitext.markdown.internal.phrase; bundle-symbolic-name="org.eclipse.mylyn.wikitext.markdown"; bundle-version="3.0.42.20220107230029"; version="3.0.42"; x-internal:="true"; uses:="org.eclipse.mylyn.wikitext.parser,org.eclipse.mylyn.wikitext.parser.markup,org.eclipse.mylyn.wikitext.parser.markup.token" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.markdown.internal.block + -> Export-Package: org.eclipse.mylyn.wikitext.markdown.internal.block; bundle-symbolic-name="org.eclipse.mylyn.wikitext.markdown"; bundle-version="3.0.46.202301111837"; version="3.0.46"; x-internal:="true"; uses:="org.eclipse.mylyn.wikitext.markdown.internal.util,org.eclipse.mylyn.wikitext.parser.markup" + org.eclipse.mylyn.wikitext.markdown [861] + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.markdown.internal + -> Export-Package: org.eclipse.mylyn.wikitext.markdown.internal; bundle-symbolic-name="org.eclipse.mylyn.wikitext.markdown"; bundle-version="3.0.42.20220107230029"; version="3.0.42"; x-internal:="true"; uses:="org.eclipse.mylyn.wikitext.parser,org.eclipse.mylyn.wikitext.parser.builder,org.eclipse.mylyn.wikitext.parser.markup" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.markdown.internal.token + -> Export-Package: org.eclipse.mylyn.wikitext.markdown.internal.token; bundle-symbolic-name="org.eclipse.mylyn.wikitext.markdown"; bundle-version="3.0.42.20220107230029"; version="3.0.42"; x-internal:="true"; uses:="org.eclipse.mylyn.wikitext.parser.markup" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.markdown.internal.phrase + -> Export-Package: org.eclipse.mylyn.wikitext.markdown.internal.phrase; bundle-symbolic-name="org.eclipse.mylyn.wikitext.markdown"; bundle-version="3.0.42.20220107230029"; version="3.0.42"; x-internal:="true"; uses:="org.eclipse.mylyn.wikitext.parser,org.eclipse.mylyn.wikitext.parser.markup,org.eclipse.mylyn.wikitext.parser.markup.token" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.util; version="[3.0.0,4.0.0)" + -> Export-Package: org.eclipse.mylyn.wikitext.util; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.46.202301111837"; version="3.0.46"; uses:="javax.xml.stream,org.eclipse.mylyn.wikitext.parser,org.eclipse.mylyn.wikitext.parser.markup,org.xml.sax" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.markdown.internal.util + -> Export-Package: org.eclipse.mylyn.wikitext.markdown.internal.util; bundle-symbolic-name="org.eclipse.mylyn.wikitext.markdown"; bundle-version="3.0.42.20220107230029"; version="3.0.42"; x-internal:="true"; uses:="org.eclipse.mylyn.wikitext.markdown.internal.block,org.eclipse.mylyn.wikitext.parser,org.eclipse.mylyn.wikitext.parser.markup" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.markdown + -> Export-Package: org.eclipse.mylyn.wikitext.markdown; bundle-symbolic-name="org.eclipse.mylyn.wikitext.markdown"; bundle-version="3.0.48.202308291007"; version="3.0.48"; uses:="org.eclipse.mylyn.wikitext.parser,org.eclipse.mylyn.wikitext.parser.markup" + Unresolved requirement: Import-Package: com.google.common.base; version="[31.1.0,32.0.0)" + -> Export-Package: com.google.common.base; bundle-symbolic-name="com.google.guava"; bundle-version="31.1.0.jre"; version="31.1.0"; uses:="javax.annotation" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser.builder; version="[3.0.0,4.0.0)" + -> Export-Package: org.eclipse.mylyn.wikitext.parser.builder; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.46.202301111837"; version="3.0.46"; uses:="org.eclipse.mylyn.wikitext.parser,org.eclipse.mylyn.wikitext.parser.builder.event,org.eclipse.mylyn.wikitext.parser.outline,org.eclipse.mylyn.wikitext.util" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser.markup.token; version="[3.0.0,4.0.0)" + -> Export-Package: org.eclipse.mylyn.wikitext.parser.markup.token; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.42.20220107230029"; version="3.0.42"; uses:="org.eclipse.mylyn.wikitext.parser.markup" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser; version="[3.0.0,4.0.0)" + -> Export-Package: org.eclipse.mylyn.wikitext.parser; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.46.202301111837"; version="3.0.46"; uses:="org.eclipse.mylyn.wikitext.parser.markup,org.xml.sax" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.validation; version="[3.0.0,4.0.0)" + -> Export-Package: org.eclipse.mylyn.wikitext.validation; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.46.202301111837"; version="3.0.46"; uses:="org.eclipse.mylyn.wikitext.parser.markup" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser.markup.phrase; version="[3.0.0,4.0.0)" + -> Export-Package: org.eclipse.mylyn.wikitext.parser.markup.phrase; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.46.202301111837"; version="3.0.46"; uses:="org.eclipse.mylyn.wikitext.parser.markup" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser.markup; version="[3.0.0,4.0.0)" + -> Export-Package: org.eclipse.mylyn.wikitext.parser.markup; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.42.20220107230029"; version="3.0.42"; uses:="org.eclipse.mylyn.wikitext.parser,org.eclipse.mylyn.wikitext.parser.util" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.markdown.internal.block + -> Export-Package: org.eclipse.mylyn.wikitext.markdown.internal.block; bundle-symbolic-name="org.eclipse.mylyn.wikitext.markdown"; bundle-version="3.0.46.202301111837"; version="3.0.46"; x-internal:="true"; uses:="org.eclipse.mylyn.wikitext.markdown.internal.util,org.eclipse.mylyn.wikitext.parser.markup" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser.markup; version="[3.0.0,4.0.0)" + -> Export-Package: org.eclipse.mylyn.wikitext.parser.markup; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.42.20220107230029"; version="3.0.42"; uses:="org.eclipse.mylyn.wikitext.parser,org.eclipse.mylyn.wikitext.parser.util" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser.markup.token; version="[3.0.0,4.0.0)" + -> Export-Package: org.eclipse.mylyn.wikitext.parser.markup.token; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.42.20220107230029"; version="3.0.42"; uses:="org.eclipse.mylyn.wikitext.parser.markup" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.validation; version="[3.0.0,4.0.0)" + -> Export-Package: org.eclipse.mylyn.wikitext.validation; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.46.202301111837"; version="3.0.46"; uses:="org.eclipse.mylyn.wikitext.parser.markup" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser; version="[3.0.0,4.0.0)" + -> Export-Package: org.eclipse.mylyn.wikitext.parser; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.46.202301111837"; version="3.0.46"; uses:="org.eclipse.mylyn.wikitext.parser.markup,org.xml.sax" + Unresolved requirement: Import-Package: org.eclipse.mylyn.wikitext.parser.builder; version="[3.0.0,4.0.0)" + -> Export-Package: org.eclipse.mylyn.wikitext.parser.builder; bundle-symbolic-name="org.eclipse.mylyn.wikitext"; bundle-version="3.0.46.202301111837"; version="3.0.46"; uses:="org.eclipse.mylyn.wikitext.parser,org.eclipse.mylyn.wikitext.parser.builder.event,org.eclipse.mylyn.wikitext.parser.outline,org.eclipse.mylyn.wikitext.util" + Unresolved requirement: Import-Package: com.google.gson; version="2.7.0" + -> Export-Package: com.google.gson; bundle-symbolic-name="com.google.gson"; bundle-version="2.8.9.v20220111-1409"; version="2.8.9"; uses:="com.google.gson.internal,com.google.gson.reflect,com.google.gson.stream" + Unresolved requirement: Require-Bundle: org.eclipse.lsp4j.jsonrpc; bundle-version="[0.19.0,0.20.0)" + -> Bundle-SymbolicName: org.eclipse.lsp4j.jsonrpc; bundle-version="0.19.0.v20221118-0359" + + at org.eclipse.osgi.container.Module.start(Module.java:463) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1847) + at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1840) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1781) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1745) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1667) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) + at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234) + at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345) + +!ENTRY org.eclipse.cdt.remote.core 4 0 2024-04-25 11:26:26.990 +!MESSAGE FrameworkEvent ERROR +!STACK 0 +org.osgi.framework.BundleException: Could not resolve module: org.eclipse.cdt.remote.core [1052] + Another singleton bundle selected: osgi.identity; type="osgi.bundle"; version:Version="1.2.0.202211062329"; osgi.identity="org.eclipse.cdt.remote.core"; singleton:="true" + + at org.eclipse.osgi.container.Module.start(Module.java:463) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1847) + at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1840) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1781) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1745) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1667) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) + at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234) + at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345) + +!ENTRY org.eclipse.ecf.provider.filetransfer 4 0 2024-04-25 11:26:26.991 +!MESSAGE FrameworkEvent ERROR +!STACK 0 +org.osgi.framework.BundleException: Could not resolve module: org.eclipse.ecf.provider.filetransfer [1054] + Another singleton bundle selected: osgi.identity; type="osgi.bundle"; version:Version="3.3.0.v20230422-0242"; osgi.identity="org.eclipse.ecf.provider.filetransfer"; singleton:="true" + + at org.eclipse.osgi.container.Module.start(Module.java:463) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1847) + at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1840) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1781) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1745) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1667) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) + at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234) + at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345) + +!ENTRY org.eclipse.ecf.provider.filetransfer.httpclient5 4 0 2024-04-25 11:26:26.991 +!MESSAGE FrameworkEvent ERROR +!STACK 0 +org.osgi.framework.BundleException: Could not resolve module: org.eclipse.ecf.provider.filetransfer.httpclient5 [1055] + Another singleton bundle selected: osgi.identity; type="osgi.bundle"; version:Version="1.1.0.v20230423-0417"; osgi.identity="org.eclipse.ecf.provider.filetransfer.httpclient5"; singleton:="true" + + at org.eclipse.osgi.container.Module.start(Module.java:463) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1847) + at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1840) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1781) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1745) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1667) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) + at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234) + at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345) + +!ENTRY org.eclipse.emf.common.ui 4 0 2024-04-25 11:26:26.992 +!MESSAGE FrameworkEvent ERROR +!STACK 0 +org.osgi.framework.BundleException: Could not resolve module: org.eclipse.emf.common.ui [1058] + Another singleton bundle selected: osgi.identity; type="osgi.bundle"; version:Version="2.21.0.v20230211-1150"; osgi.identity="org.eclipse.emf.common.ui"; singleton:="true" + + at org.eclipse.osgi.container.Module.start(Module.java:463) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1847) + at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1840) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1781) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1745) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1667) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) + at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234) + at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345) + +!ENTRY org.eclipse.equinox.p2.discovery.compatibility 4 0 2024-04-25 11:26:26.993 +!MESSAGE FrameworkEvent ERROR +!STACK 0 +org.osgi.framework.BundleException: Could not resolve module: org.eclipse.equinox.p2.discovery.compatibility [1060] + Another singleton bundle selected: osgi.identity; type="osgi.bundle"; version:Version="1.3.0.v20230322-1009"; osgi.identity="org.eclipse.equinox.p2.discovery.compatibility"; singleton:="true" + + at org.eclipse.osgi.container.Module.start(Module.java:463) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1847) + at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1840) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1781) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1745) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1667) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) + at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234) + at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345) + +!ENTRY org.eclipse.linuxtools.dataviewers 4 0 2024-04-25 11:26:26.993 +!MESSAGE FrameworkEvent ERROR +!STACK 0 +org.osgi.framework.BundleException: Could not resolve module: org.eclipse.linuxtools.dataviewers [1062] + Another singleton bundle selected: osgi.identity; type="osgi.bundle"; version:Version="6.1.0.202309052024"; osgi.identity="org.eclipse.linuxtools.dataviewers"; singleton:="true" + + at org.eclipse.osgi.container.Module.start(Module.java:463) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1847) + at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1840) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1781) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1745) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1667) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) + at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234) + at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345) + +!ENTRY org.eclipse.linuxtools.dataviewers.charts 4 0 2024-04-25 11:26:26.994 +!MESSAGE FrameworkEvent ERROR +!STACK 0 +org.osgi.framework.BundleException: Could not resolve module: org.eclipse.linuxtools.dataviewers.charts [1063] + Another singleton bundle selected: osgi.identity; type="osgi.bundle"; version:Version="7.0.0.202309052024"; osgi.identity="org.eclipse.linuxtools.dataviewers.charts"; singleton:="true" + + at org.eclipse.osgi.container.Module.start(Module.java:463) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1847) + at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1840) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1781) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1745) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1667) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) + at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234) + at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345) + +!ENTRY org.eclipse.linuxtools.docker.core 4 0 2024-04-25 11:26:26.995 +!MESSAGE FrameworkEvent ERROR +!STACK 0 +org.osgi.framework.BundleException: Could not resolve module: org.eclipse.linuxtools.docker.core [1065] + Another singleton bundle selected: osgi.identity; type="osgi.bundle"; version:Version="5.9.0.202211291906"; osgi.identity="org.eclipse.linuxtools.docker.core"; singleton:="true" + + at org.eclipse.osgi.container.Module.start(Module.java:463) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1847) + at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1840) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1781) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1745) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1667) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) + at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234) + at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345) + +!ENTRY org.eclipse.linuxtools.docker.editor.ls 4 0 2024-04-25 11:26:26.995 +!MESSAGE FrameworkEvent ERROR +!STACK 0 +org.osgi.framework.BundleException: Could not resolve module: org.eclipse.linuxtools.docker.editor.ls [1067] + Another singleton bundle selected: osgi.identity; type="osgi.bundle"; version:Version="1.0.1.202211291906"; osgi.identity="org.eclipse.linuxtools.docker.editor.ls"; singleton:="true" + + at org.eclipse.osgi.container.Module.start(Module.java:463) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1847) + at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1840) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1781) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1745) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1667) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) + at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234) + at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345) + +!ENTRY org.eclipse.linuxtools.docker.ui 4 0 2024-04-25 11:26:26.996 +!MESSAGE FrameworkEvent ERROR +!STACK 0 +org.osgi.framework.BundleException: Could not resolve module: org.eclipse.linuxtools.docker.ui [1068] + Another singleton bundle selected: osgi.identity; type="osgi.bundle"; version:Version="5.9.0.202211291906"; osgi.identity="org.eclipse.linuxtools.docker.ui"; singleton:="true" + + at org.eclipse.osgi.container.Module.start(Module.java:463) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1847) + at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1840) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1781) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1745) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1667) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) + at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234) + at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345) + +!ENTRY org.eclipse.remote.serial.core 4 0 2024-04-25 11:26:26.996 +!MESSAGE FrameworkEvent ERROR +!STACK 0 +org.osgi.framework.BundleException: Could not resolve module: org.eclipse.remote.serial.core [1072] + Another singleton bundle selected: osgi.identity; type="osgi.bundle"; version:Version="1.2.0.202211062329"; osgi.identity="org.eclipse.remote.serial.core"; singleton:="true" + + at org.eclipse.osgi.container.Module.start(Module.java:463) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1847) + at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1840) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1781) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1745) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1667) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) + at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234) + at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345) + +!ENTRY org.eclipse.remote.serial.ui 4 0 2024-04-25 11:26:26.997 +!MESSAGE FrameworkEvent ERROR +!STACK 0 +org.osgi.framework.BundleException: Could not resolve module: org.eclipse.remote.serial.ui [1073] + Another singleton bundle selected: osgi.identity; type="osgi.bundle"; version:Version="1.1.0.202211062329"; osgi.identity="org.eclipse.remote.serial.ui"; singleton:="true" + + at org.eclipse.osgi.container.Module.start(Module.java:463) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1847) + at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1840) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1781) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1745) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1667) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) + at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234) + at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345) + +!ENTRY org.eclipse.remote.telnet.core 4 0 2024-04-25 11:26:26.998 +!MESSAGE FrameworkEvent ERROR +!STACK 0 +org.osgi.framework.BundleException: Could not resolve module: org.eclipse.remote.telnet.core [1074] + Another singleton bundle selected: osgi.identity; type="osgi.bundle"; version:Version="1.2.0.202211062329"; osgi.identity="org.eclipse.remote.telnet.core"; singleton:="true" + + at org.eclipse.osgi.container.Module.start(Module.java:463) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1847) + at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1840) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1781) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1745) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1667) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) + at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234) + at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345) + +!ENTRY org.eclipse.swtchart.extensions 4 0 2024-04-25 11:26:26.998 +!MESSAGE FrameworkEvent ERROR +!STACK 0 +org.osgi.framework.BundleException: Could not resolve module: org.eclipse.swtchart.extensions [1076] + Another singleton bundle selected: osgi.identity; type="osgi.bundle"; version:Version="0.13.0.202207230616"; osgi.identity="org.eclipse.swtchart.extensions"; singleton:="true" + + at org.eclipse.osgi.container.Module.start(Module.java:463) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1847) + at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1840) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1781) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1745) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1667) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) + at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234) + at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345) + +!ENTRY org.eclipse.tm.terminal.connector.local 4 0 2024-04-25 11:26:26.999 +!MESSAGE FrameworkEvent ERROR +!STACK 0 +org.osgi.framework.BundleException: Could not resolve module: org.eclipse.tm.terminal.connector.local [1077] + Another singleton bundle selected: osgi.identity; type="osgi.bundle"; version:Version="4.8.0.202211062329"; osgi.identity="org.eclipse.tm.terminal.connector.local"; singleton:="true" + + at org.eclipse.osgi.container.Module.start(Module.java:463) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1847) + at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1840) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1781) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1745) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1667) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) + at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234) + at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345) + +!ENTRY org.eclipse.tm.terminal.connector.process 4 0 2024-04-25 11:26:26.999 +!MESSAGE FrameworkEvent ERROR +!STACK 0 +org.osgi.framework.BundleException: Could not resolve module: org.eclipse.tm.terminal.connector.process [1078] + Another singleton bundle selected: osgi.identity; type="osgi.bundle"; version:Version="4.9.0.202211062329"; osgi.identity="org.eclipse.tm.terminal.connector.process"; singleton:="true" + + at org.eclipse.osgi.container.Module.start(Module.java:463) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1847) + at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1840) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1781) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1745) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1667) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) + at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234) + at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345) + +!ENTRY org.eclipse.tm.terminal.connector.ssh 4 0 2024-04-25 11:26:27.000 +!MESSAGE FrameworkEvent ERROR +!STACK 0 +org.osgi.framework.BundleException: Could not resolve module: org.eclipse.tm.terminal.connector.ssh [1079] + Another singleton bundle selected: osgi.identity; type="osgi.bundle"; version:Version="4.8.100.202303140100"; osgi.identity="org.eclipse.tm.terminal.connector.ssh"; singleton:="true" + + at org.eclipse.osgi.container.Module.start(Module.java:463) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1847) + at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1840) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1781) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1745) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1667) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) + at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234) + at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345) + +!ENTRY org.eclipse.tm.terminal.connector.telnet 4 0 2024-04-25 11:26:27.001 +!MESSAGE FrameworkEvent ERROR +!STACK 0 +org.osgi.framework.BundleException: Could not resolve module: org.eclipse.tm.terminal.connector.telnet [1080] + Another singleton bundle selected: osgi.identity; type="osgi.bundle"; version:Version="4.8.0.202211062329"; osgi.identity="org.eclipse.tm.terminal.connector.telnet"; singleton:="true" + + at org.eclipse.osgi.container.Module.start(Module.java:463) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1847) + at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1840) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1781) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1745) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1667) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) + at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234) + at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345) + +!ENTRY org.eclipse.tm.terminal.control 4 0 2024-04-25 11:26:27.001 +!MESSAGE FrameworkEvent ERROR +!STACK 0 +org.osgi.framework.BundleException: Could not resolve module: org.eclipse.tm.terminal.control [1081] + Another singleton bundle selected: osgi.identity; type="osgi.bundle"; version:Version="5.5.100.202311142253"; osgi.identity="org.eclipse.tm.terminal.control"; singleton:="true" + + at org.eclipse.osgi.container.Module.start(Module.java:463) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1847) + at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1840) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1781) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1745) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1667) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) + at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234) + at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345) + +!ENTRY org.eclipse.tm.terminal.view.core 4 0 2024-04-25 11:26:27.002 +!MESSAGE FrameworkEvent ERROR +!STACK 0 +org.osgi.framework.BundleException: Could not resolve module: org.eclipse.tm.terminal.view.core [1082] + Another singleton bundle selected: osgi.identity; type="osgi.bundle"; version:Version="4.10.100.202309151124"; osgi.identity="org.eclipse.tm.terminal.view.core"; singleton:="true" + + at org.eclipse.osgi.container.Module.start(Module.java:463) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1847) + at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1840) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1781) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1745) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1667) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) + at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234) + at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345) + +!ENTRY org.eclipse.tm.terminal.view.ui 4 0 2024-04-25 11:26:27.002 +!MESSAGE FrameworkEvent ERROR +!STACK 0 +org.osgi.framework.BundleException: Could not resolve module: org.eclipse.tm.terminal.view.ui [1083] + Another singleton bundle selected: osgi.identity; type="osgi.bundle"; version:Version="4.11.300.202311142324"; osgi.identity="org.eclipse.tm.terminal.view.ui"; singleton:="true" + + at org.eclipse.osgi.container.Module.start(Module.java:463) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1847) + at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1840) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1781) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1745) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1667) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) + at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234) + at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345) + +!ENTRY org.eclipse.tm4e.registry 4 0 2024-04-25 11:26:27.003 +!MESSAGE FrameworkEvent ERROR +!STACK 0 +org.osgi.framework.BundleException: Could not resolve module: org.eclipse.tm4e.registry [1085] + Another singleton bundle selected: osgi.identity; type="osgi.bundle"; version:Version="0.6.5.202308132047"; osgi.identity="org.eclipse.tm4e.registry"; singleton:="true" + + at org.eclipse.osgi.container.Module.start(Module.java:463) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1847) + at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1840) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1781) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1745) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1667) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) + at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234) + at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345) + +!ENTRY org.eclipse.tm4e.ui 4 0 2024-04-25 11:26:27.003 +!MESSAGE FrameworkEvent ERROR +!STACK 0 +org.osgi.framework.BundleException: Could not resolve module: org.eclipse.tm4e.ui [1086] + Another singleton bundle selected: osgi.identity; type="osgi.bundle"; version:Version="0.6.1.202211021121"; osgi.identity="org.eclipse.tm4e.ui"; singleton:="true" + + at org.eclipse.osgi.container.Module.start(Module.java:463) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1847) + at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1840) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1781) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1745) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1667) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) + at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234) + at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345) + +!ENTRY org.eclipse.wst.common.frameworks.ui 4 0 2024-04-25 11:26:27.004 +!MESSAGE FrameworkEvent ERROR +!STACK 0 +org.osgi.framework.BundleException: Could not resolve module: org.eclipse.wst.common.frameworks.ui [1091] + Another singleton bundle selected: osgi.identity; type="osgi.bundle"; version:Version="1.3.0.v202308161955"; osgi.identity="org.eclipse.wst.common.frameworks.ui"; singleton:="true" + + at org.eclipse.osgi.container.Module.start(Module.java:463) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1847) + at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1840) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1781) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1745) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1667) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) + at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234) + at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345) + +!ENTRY org.eclipse.wst.common.uriresolver 4 0 2024-04-25 11:26:27.005 +!MESSAGE FrameworkEvent ERROR +!STACK 0 +org.osgi.framework.BundleException: Could not resolve module: org.eclipse.wst.common.uriresolver [1092] + Another singleton bundle selected: osgi.identity; type="osgi.bundle"; version:Version="1.4.0.v202308161955"; osgi.identity="org.eclipse.wst.common.uriresolver"; singleton:="true" + + at org.eclipse.osgi.container.Module.start(Module.java:463) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1847) + at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1840) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1781) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1745) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1667) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) + at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234) + at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345) + +!ENTRY org.eclipse.wst.sse.core 4 0 2024-04-25 11:26:27.005 +!MESSAGE FrameworkEvent ERROR +!STACK 0 +org.osgi.framework.BundleException: Could not resolve module: org.eclipse.wst.sse.core [1093] + Another singleton bundle selected: osgi.identity; type="osgi.bundle"; version:Version="1.2.900.v202211200019"; osgi.identity="org.eclipse.wst.sse.core"; singleton:="true" + + at org.eclipse.osgi.container.Module.start(Module.java:463) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1847) + at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1840) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1781) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1745) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1667) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) + at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234) + at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345) + +!ENTRY org.eclipse.wst.xml.core 4 0 2024-04-25 11:26:27.006 +!MESSAGE FrameworkEvent ERROR +!STACK 0 +org.osgi.framework.BundleException: Could not resolve module: org.eclipse.wst.xml.core [1094] + Another singleton bundle selected: osgi.identity; type="osgi.bundle"; version:Version="1.2.700.v202305221615"; osgi.identity="org.eclipse.wst.xml.core"; singleton:="true" + + at org.eclipse.osgi.container.Module.start(Module.java:463) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1847) + at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1840) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1781) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1745) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1667) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) + at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234) + at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345) + +!ENTRY org.eclipse.xsd 4 0 2024-04-25 11:26:27.006 +!MESSAGE FrameworkEvent ERROR +!STACK 0 +org.osgi.framework.BundleException: Could not resolve module: org.eclipse.xsd [1095] + Another singleton bundle selected: osgi.identity; type="osgi.bundle"; version:Version="2.19.0.v20230614-0642"; osgi.identity="org.eclipse.xsd"; singleton:="true" + + at org.eclipse.osgi.container.Module.start(Module.java:463) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1847) + at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1840) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1781) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1745) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1667) + at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) + at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234) + at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345) + +!ENTRY org.eclipse.equinox.app 0 0 2024-04-25 11:26:27.065 +!MESSAGE Product org.eclipse.epp.package.cpp.product could not be found. + +!ENTRY org.eclipse.osgi 4 0 2024-04-25 11:26:38.863 +!MESSAGE Application error +!STACK 1 +java.lang.LinkageError: loader constraint violation: loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @602c167e wants to load abstract class org.eclipse.e4.core.contexts.ContextFunction. A different abstract class with the same name was previously loaded by org.eclipse.osgi.internal.loader.EquinoxClassLoader @194ec3c8. (org.eclipse.e4.core.contexts.ContextFunction is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @194ec3c8, parent loader 'platform') + at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.getHandler(HandlerServiceImpl.java:65) + at org.eclipse.ui.internal.commands.CommandPersistence.readCommandsFromRegistry(CommandPersistence.java:196) + at org.eclipse.ui.internal.commands.CommandPersistence.reRead(CommandPersistence.java:461) + at org.eclipse.ui.internal.CommandToModelProcessor.process(CommandToModelProcessor.java:71) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58) + at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:300) + at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:234) + at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:173) + at org.eclipse.e4.ui.internal.workbench.ModelAssembler.runProcessor(ModelAssembler.java:715) + at org.eclipse.e4.ui.internal.workbench.ModelAssembler.runProcessors(ModelAssembler.java:649) + at org.eclipse.e4.ui.internal.workbench.ModelAssembler.processModel(ModelAssembler.java:322) + at org.eclipse.e4.ui.internal.workbench.ResourceHandler.loadMostRecentModel(ResourceHandler.java:199) + at org.eclipse.e4.ui.internal.workbench.swt.E4Application.loadApplicationModel(E4Application.java:371) + at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createE4Workbench(E4Application.java:247) + at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:573) + at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:342) + at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:551) + at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:156) + at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152) + at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203) + at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136) + at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104) + at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:402) + at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) + at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.base/java.lang.reflect.Method.invoke(Method.java:568) + at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659) + at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596) + at org.eclipse.equinox.launcher.Main.run(Main.java:1467) + at org.eclipse.equinox.launcher.Main.main(Main.java:1440) diff --git a/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version new file mode 100644 index 0000000..6b2aaa7 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..30841eb --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +encoding=UTF-8 +version=1 diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml index 1a5207d..3023585 100644 --- a/.settings/language.settings.xml +++ b/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -16,10 +16,10 @@ - + - + \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..455a709 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,73 @@ +{ + "files.associations": { + "array": "cpp", + "atomic": "cpp", + "bit": "cpp", + "*.tcc": "cpp", + "cctype": "cpp", + "clocale": "cpp", + "cmath": "cpp", + "compare": "cpp", + "concepts": "cpp", + "cstdarg": "cpp", + "cstddef": "cpp", + "cstdint": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "cstring": "cpp", + "cwchar": "cpp", + "cwctype": "cpp", + "deque": "cpp", + "list": "cpp", + "map": "cpp", + "set": "cpp", + "string": "cpp", + "unordered_map": "cpp", + "vector": "cpp", + "exception": "cpp", + "algorithm": "cpp", + "functional": "cpp", + "iterator": "cpp", + "memory": "cpp", + "memory_resource": "cpp", + "numeric": "cpp", + "optional": "cpp", + "random": "cpp", + "string_view": "cpp", + "system_error": "cpp", + "tuple": "cpp", + "type_traits": "cpp", + "utility": "cpp", + "fstream": "cpp", + "initializer_list": "cpp", + "iosfwd": "cpp", + "iostream": "cpp", + "istream": "cpp", + "limits": "cpp", + "new": "cpp", + "numbers": "cpp", + "ostream": "cpp", + "sstream": "cpp", + "stdexcept": "cpp", + "streambuf": "cpp", + "cinttypes": "cpp", + "typeinfo": "cpp", + "csignal": "cpp", + "ctime": "cpp", + "strstream": "cpp", + "bitset": "cpp", + "chrono": "cpp", + "codecvt": "cpp", + "complex": "cpp", + "condition_variable": "cpp", + "ratio": "cpp", + "future": "cpp", + "iomanip": "cpp", + "mutex": "cpp", + "semaphore": "cpp", + "stop_token": "cpp", + "thread": "cpp", + "cfenv": "cpp", + "typeindex": "cpp" + } +} \ No newline at end of file diff --git a/API_log/SH_log.cpp b/API_log/SH_log.cpp index 61d06f7..05bb876 100644 --- a/API_log/SH_log.cpp +++ b/API_log/SH_log.cpp @@ -7,7 +7,8 @@ #include #include #include - +#include "../common/SH_global.h" +#include "../common/SH_CommonFunc.hpp" struct _LogParam { pthread_mutex_t *m_mutex; @@ -33,7 +34,8 @@ int log_init(const char* file_name, int log_buf_size, int limit_size) struct timeval now = {0,0}; gettimeofday(&now, NULL); - time_t t = now.tv_sec; + time_t t ; + t = now.tv_sec; struct tm* sys_tm = localtime(&t); char fileTime[20]={0x00}; char fileName[100]={0x00}; @@ -46,6 +48,16 @@ int log_init(const char* file_name, int log_buf_size, int limit_size) void log_write(const char *level, const char* format, ...) { + struct timeval now = {0,0}; + gettimeofday(&now, NULL); + time_t t; + t = now.tv_sec; + struct tm* sys_tm = localtime(&t); + char fileTime[20]={0x00}; + char fileName[100]={0x00}; + int n = snprintf(fileTime, 64, "%d-%02d-%02d.log", sys_tm->tm_year+1900, sys_tm->tm_mon+1, sys_tm->tm_mday); + sprintf(fileName,"%s%s",SOFTWARE_RUN_LOG,fileTime); + strcpy(gLogParam.m_log_full_name, fileName); FILE *fp = fopen(gLogParam.m_log_full_name, "a"); if(fp == NULL) { return; @@ -53,15 +65,10 @@ void log_write(const char *level, const char* format, ...) memset(gLogParam.m_buf, 0, sizeof(char)*gLogParam.m_log_buf_size); - struct timeval now = {0,0}; - gettimeofday(&now, NULL); - time_t t = now.tv_sec; - struct tm* sys_tm = localtime(&t); - pthread_mutex_lock(gLogParam.m_mutex); - int n = snprintf(gLogParam.m_buf, 64, "%d-%02d-%02d %02d:%02d:%02d %s: ", sys_tm->tm_year+1900, sys_tm->tm_mon+1, sys_tm->tm_mday, + n = snprintf(gLogParam.m_buf, 64, "%d-%02d-%02d %02d:%02d:%02d %s: ", sys_tm->tm_year+1900, sys_tm->tm_mon+1, sys_tm->tm_mday, sys_tm->tm_hour, sys_tm->tm_min, sys_tm->tm_sec, level); diff --git a/Cidn-SH b/Cidn-SH new file mode 100644 index 0000000..d5a8937 Binary files /dev/null and b/Cidn-SH differ diff --git a/MD5/md5.cpp b/MD5/md5.cpp new file mode 100644 index 0000000..6c9cd15 --- /dev/null +++ b/MD5/md5.cpp @@ -0,0 +1,304 @@ +#include "md5.h" + +#ifndef HAVE_OPENSSL + + #define F(x, y, z) ((z) ^ ((x) & ((y) ^ (z)))) + #define G(x, y, z) ((y) ^ ((z) & ((x) ^ (y)))) + #define H(x, y, z) ((x) ^ (y) ^ (z)) + #define I(x, y, z) ((y) ^ ((x) | ~(z))) + #define STEP(f, a, b, c, d, x, t, s) \ + (a) += f((b), (c), (d)) + (x) + (t); \ + (a) = (((a) << (s)) | (((a) & 0xffffffff) >> (32 - (s)))); \ + (a) += (b); + + #if defined(__i386__) || defined(__x86_64__) || defined(__vax__) + #define SET(n) \ + (*(MD5_u32 *)&ptr[(n) * 4]) + #define GET(n) \ + SET(n) + #else + #define SET(n) \ + (ctx->block[(n)] = \ + (MD5_u32)ptr[(n) * 4] | \ + ((MD5_u32)ptr[(n) * 4 + 1] << 8) | \ + ((MD5_u32)ptr[(n) * 4 + 2] << 16) | \ + ((MD5_u32)ptr[(n) * 4 + 3] << 24)) + #define GET(n) \ + (ctx->block[(n)]) + #endif + + typedef unsigned int MD5_u32; + + typedef struct { + MD5_u32 lo, hi; + MD5_u32 a, b, c, d; + unsigned char buffer[64]; + MD5_u32 block[16]; + } MD5_CTX; + + static void MD5_Init(MD5_CTX *ctx); + static void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size); + static void MD5_Final(unsigned char *result, MD5_CTX *ctx); + + static const void *body(MD5_CTX *ctx, const void *data, unsigned long size){ + const unsigned char *ptr; + MD5_u32 a, b, c, d; + MD5_u32 saved_a, saved_b, saved_c, saved_d; + + ptr = (const unsigned char*)data; + + a = ctx->a; + b = ctx->b; + c = ctx->c; + d = ctx->d; + + do { + saved_a = a; + saved_b = b; + saved_c = c; + saved_d = d; + + STEP(F, a, b, c, d, SET(0), 0xd76aa478, 7) + STEP(F, d, a, b, c, SET(1), 0xe8c7b756, 12) + STEP(F, c, d, a, b, SET(2), 0x242070db, 17) + STEP(F, b, c, d, a, SET(3), 0xc1bdceee, 22) + STEP(F, a, b, c, d, SET(4), 0xf57c0faf, 7) + STEP(F, d, a, b, c, SET(5), 0x4787c62a, 12) + STEP(F, c, d, a, b, SET(6), 0xa8304613, 17) + STEP(F, b, c, d, a, SET(7), 0xfd469501, 22) + STEP(F, a, b, c, d, SET(8), 0x698098d8, 7) + STEP(F, d, a, b, c, SET(9), 0x8b44f7af, 12) + STEP(F, c, d, a, b, SET(10), 0xffff5bb1, 17) + STEP(F, b, c, d, a, SET(11), 0x895cd7be, 22) + STEP(F, a, b, c, d, SET(12), 0x6b901122, 7) + STEP(F, d, a, b, c, SET(13), 0xfd987193, 12) + STEP(F, c, d, a, b, SET(14), 0xa679438e, 17) + STEP(F, b, c, d, a, SET(15), 0x49b40821, 22) + STEP(G, a, b, c, d, GET(1), 0xf61e2562, 5) + STEP(G, d, a, b, c, GET(6), 0xc040b340, 9) + STEP(G, c, d, a, b, GET(11), 0x265e5a51, 14) + STEP(G, b, c, d, a, GET(0), 0xe9b6c7aa, 20) + STEP(G, a, b, c, d, GET(5), 0xd62f105d, 5) + STEP(G, d, a, b, c, GET(10), 0x02441453, 9) + STEP(G, c, d, a, b, GET(15), 0xd8a1e681, 14) + STEP(G, b, c, d, a, GET(4), 0xe7d3fbc8, 20) + STEP(G, a, b, c, d, GET(9), 0x21e1cde6, 5) + STEP(G, d, a, b, c, GET(14), 0xc33707d6, 9) + STEP(G, c, d, a, b, GET(3), 0xf4d50d87, 14) + STEP(G, b, c, d, a, GET(8), 0x455a14ed, 20) + STEP(G, a, b, c, d, GET(13), 0xa9e3e905, 5) + STEP(G, d, a, b, c, GET(2), 0xfcefa3f8, 9) + STEP(G, c, d, a, b, GET(7), 0x676f02d9, 14) + STEP(G, b, c, d, a, GET(12), 0x8d2a4c8a, 20) + STEP(H, a, b, c, d, GET(5), 0xfffa3942, 4) + STEP(H, d, a, b, c, GET(8), 0x8771f681, 11) + STEP(H, c, d, a, b, GET(11), 0x6d9d6122, 16) + STEP(H, b, c, d, a, GET(14), 0xfde5380c, 23) + STEP(H, a, b, c, d, GET(1), 0xa4beea44, 4) + STEP(H, d, a, b, c, GET(4), 0x4bdecfa9, 11) + STEP(H, c, d, a, b, GET(7), 0xf6bb4b60, 16) + STEP(H, b, c, d, a, GET(10), 0xbebfbc70, 23) + STEP(H, a, b, c, d, GET(13), 0x289b7ec6, 4) + STEP(H, d, a, b, c, GET(0), 0xeaa127fa, 11) + STEP(H, c, d, a, b, GET(3), 0xd4ef3085, 16) + STEP(H, b, c, d, a, GET(6), 0x04881d05, 23) + STEP(H, a, b, c, d, GET(9), 0xd9d4d039, 4) + STEP(H, d, a, b, c, GET(12), 0xe6db99e5, 11) + STEP(H, c, d, a, b, GET(15), 0x1fa27cf8, 16) + STEP(H, b, c, d, a, GET(2), 0xc4ac5665, 23) + STEP(I, a, b, c, d, GET(0), 0xf4292244, 6) + STEP(I, d, a, b, c, GET(7), 0x432aff97, 10) + STEP(I, c, d, a, b, GET(14), 0xab9423a7, 15) + STEP(I, b, c, d, a, GET(5), 0xfc93a039, 21) + STEP(I, a, b, c, d, GET(12), 0x655b59c3, 6) + STEP(I, d, a, b, c, GET(3), 0x8f0ccc92, 10) + STEP(I, c, d, a, b, GET(10), 0xffeff47d, 15) + STEP(I, b, c, d, a, GET(1), 0x85845dd1, 21) + STEP(I, a, b, c, d, GET(8), 0x6fa87e4f, 6) + STEP(I, d, a, b, c, GET(15), 0xfe2ce6e0, 10) + STEP(I, c, d, a, b, GET(6), 0xa3014314, 15) + STEP(I, b, c, d, a, GET(13), 0x4e0811a1, 21) + STEP(I, a, b, c, d, GET(4), 0xf7537e82, 6) + STEP(I, d, a, b, c, GET(11), 0xbd3af235, 10) + STEP(I, c, d, a, b, GET(2), 0x2ad7d2bb, 15) + STEP(I, b, c, d, a, GET(9), 0xeb86d391, 21) + + a += saved_a; + b += saved_b; + c += saved_c; + d += saved_d; + + ptr += 64; + } while (size -= 64); + + ctx->a = a; + ctx->b = b; + ctx->c = c; + ctx->d = d; + + return ptr; + } + + void MD5_Init(MD5_CTX *ctx){ + ctx->a = 0x67452301; + ctx->b = 0xefcdab89; + ctx->c = 0x98badcfe; + ctx->d = 0x10325476; + + ctx->lo = 0; + ctx->hi = 0; + } + + void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size){ + MD5_u32 saved_lo; + unsigned long used, free; + + saved_lo = ctx->lo; + if ((ctx->lo = (saved_lo + size) & 0x1fffffff) < saved_lo) + ctx->hi++; + ctx->hi += size >> 29; + used = saved_lo & 0x3f; + + if (used){ + free = 64 - used; + if (size < free) { + memcpy(&ctx->buffer[used], data, size); + return; + } + + memcpy(&ctx->buffer[used], data, free); + data = (unsigned char *)data + free; + size -= free; + body(ctx, ctx->buffer, 64); + } + + if (size >= 64) { + data = body(ctx, data, size & ~(unsigned long)0x3f); + size &= 0x3f; + } + + memcpy(ctx->buffer, data, size); + } + + void MD5_Final(unsigned char *result, MD5_CTX *ctx){ + unsigned long used, free; + used = ctx->lo & 0x3f; + ctx->buffer[used++] = 0x80; + free = 64 - used; + + if (free < 8) { + memset(&ctx->buffer[used], 0, free); + body(ctx, ctx->buffer, 64); + used = 0; + free = 64; + } + + memset(&ctx->buffer[used], 0, free - 8); + + ctx->lo <<= 3; + ctx->buffer[56] = ctx->lo; + ctx->buffer[57] = ctx->lo >> 8; + ctx->buffer[58] = ctx->lo >> 16; + ctx->buffer[59] = ctx->lo >> 24; + ctx->buffer[60] = ctx->hi; + ctx->buffer[61] = ctx->hi >> 8; + ctx->buffer[62] = ctx->hi >> 16; + ctx->buffer[63] = ctx->hi >> 24; + body(ctx, ctx->buffer, 64); + result[0] = ctx->a; + result[1] = ctx->a >> 8; + result[2] = ctx->a >> 16; + result[3] = ctx->a >> 24; + result[4] = ctx->b; + result[5] = ctx->b >> 8; + result[6] = ctx->b >> 16; + result[7] = ctx->b >> 24; + result[8] = ctx->c; + result[9] = ctx->c >> 8; + result[10] = ctx->c >> 16; + result[11] = ctx->c >> 24; + result[12] = ctx->d; + result[13] = ctx->d >> 8; + result[14] = ctx->d >> 16; + result[15] = ctx->d >> 24; + memset(ctx, 0, sizeof(*ctx)); + } +#else + #include +#endif + + +using namespace std; + +/* Return Calculated raw result(always little-endian), the size is always 16 */ +void md5bin(const void* dat, size_t len, unsigned char out[16]) { + MD5_CTX c; + MD5_Init(&c); + MD5_Update(&c, dat, len); + MD5_Final(out, &c); +} + +static char hb2hex(unsigned char hb) { + hb = hb & 0xF; + return hb < 10 ? '0' + hb : hb - 10 + 'a'; +} + +string md5file(const char* filename){ + printf("file = %s\n",filename); + FILE* file = fopen(filename, "rb"); + string res = md5file(file); + fclose(file); + return res; +} + +string md5file(FILE* file){ + + MD5_CTX c; + MD5_Init(&c); + + char buff[BUFSIZ]; + unsigned char out[16]; + size_t len = 0; + while( ( len = fread(buff ,sizeof(char), BUFSIZ, file) ) > 0) { + MD5_Update(&c, buff, len); + } + MD5_Final(out, &c); + + string res; + for(size_t i = 0; i < 16; ++ i) { + res.push_back(hb2hex(out[i] >> 4)); + res.push_back(hb2hex(out[i])); + } + return res; +} + +string md5(const void* dat, size_t len) { + string res; + unsigned char out[16]; + md5bin(dat, len, out); + for(size_t i = 0; i < 16; ++ i) { + res.push_back(hb2hex(out[i] >> 4)); + res.push_back(hb2hex(out[i])); + } + return res; +} + +std::string md5(std::string dat){ + return md5(dat.c_str(), dat.length()); +} + +/* Generate shorter md5sum by something like base62 instead of base16 or base10. 0~61 are represented by 0-9a-zA-Z */ +string md5sum6(const void* dat, size_t len){ + static const char* tbl = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; + string res; + unsigned char out[16]; + md5bin(dat, len, out); + for(size_t i = 0; i < 6; ++i) { + res.push_back(tbl[out[i] % 62]); + } + return res; +} + +std::string md5sum6(std::string dat){ + return md5sum6(dat.c_str(), dat.length() ); +} diff --git a/MD5/md5.h b/MD5/md5.h new file mode 100644 index 0000000..f63ab34 --- /dev/null +++ b/MD5/md5.h @@ -0,0 +1,16 @@ +#ifndef MD5_H +#define MD5_H + +#define _CRT_SECURE_NO_WARNINGS +#include +#include +#include + +std::string md5(std::string dat); +std::string md5(const void* dat, size_t len); +extern std::string md5file(const char* filename); +std::string md5file(FILE* file); +std::string md5sum6(std::string dat); +std::string md5sum6(const void* dat, size_t len); + +#endif // end of MD5_H diff --git a/Makefile b/Makefile index 481d64f..54d941c 100644 --- a/Makefile +++ b/Makefile @@ -2,22 +2,24 @@ TARGET = Cidn-SH OBJ_PATH = $(shell pwd)/debug PREFIX_BIN = -CC = arm-linux-gnueabihf-g++ -STRIP = arm-linux-gnueabihf-strip -INCLUDES = -I../third_party/boost/include \ - -I../third_party/fftw/include \ - -I../third_party/jsoncpp/include \ - -I../third_party/sqlite/include/ +CC = ${CXX} +STRIP = aarch64-poky-linux-strip +INCLUDES = -I../Tools/GatewayThirdParty/boost/include \ + -I../Tools/GatewayThirdParty/fftw/include \ + -I../Tools/GatewayThirdParty/jsoncpp/include \ + -I../Tools/GatewayThirdParty/sqlite/include/ \ + -I../Tools/GatewayThirdParty/curl/include/ \ + -I ./ \ -LIBS = -L../third_party/boost/lib \ - -L../third_party/fftw/lib \ - -L../third_party/ssl/lib \ - -L../third_party/jsoncpp \ - -L../third_party/mqtt1410/lib \ - -L../third_party/sqlite/lib \ - -lsqlite3 -lboost_system -lpthread -lboost_thread -lboost_date_time -lfftw3 -lssl -lcrypto -ljson -lmosquitto +LIBS = -L../Tools/renesas_thirdparty/lib \ + -L../Tools/renesas_thirdparty/lib \ + -L../Tools/renesas_thirdparty/lib \ + -L../Tools/renesas_thirdparty/lib \ + -L../Tools/renesas_thirdparty/lib \ + -L../Tools/renesas_thirdparty/lib \ + -lsqlite3 -lboost_system -lpthread -lboost_thread -lboost_date_time -lfftw3 -ljsoncpp -lmosquitto -lcurl -CFLAGS = -O2 #-Wall -Werror +CFLAGS = -O0 -fpermissive #-Wall -Werror LINKFLAGS = AllDirs :=$(shell ls -R | grep '^\./.*:' | awk '{if( \ diff --git a/calculation/Calculation.cpp b/calculation/Calculation.cpp index 38f9aa5..7893857 100644 --- a/calculation/Calculation.cpp +++ b/calculation/Calculation.cpp @@ -60,7 +60,46 @@ void Calculation::iFFT(int n, fftw_complex* in, fftw_complex* out) fftw_destroy_plan(p); fftw_cleanup(); } +void Calculation::_iFFT( std::vector & vecrealData,std::vector & vecimageData,std::vector & veciFFTData) +{ + fftw_complex *inFFt, *outFFt; + int N = vecrealData.size(); + inFFt = (fftw_complex *)fftw_malloc(sizeof(fftw_complex) * N); + outFFt = (fftw_complex *)fftw_malloc(sizeof(fftw_complex) * N); + for (int j = 0; j < N; j++) { + inFFt[j][0] = (double)vecrealData[j]; + inFFt[j][1] = (double)vecimageData[j]; + } + iFFT(N,inFFt, outFFt); + for (int i = 0; i < N; i++) { + outFFt[i][0] *= 1./N; + outFFt[i][1] *= 1./N; + veciFFTData.push_back(outFFt[i][0]); + } + fftw_free(inFFt); + fftw_free(outFFt); +} +void Calculation::_FFT(std::vector & vecData, std::vector & vecFFTrealData,std::vector & vecFFTimageData) +{ + fftw_complex *inHilFFt, *outHilFFt; + inHilFFt = (fftw_complex *)fftw_malloc(sizeof(fftw_complex) * vecData.size()); + outHilFFt = (fftw_complex *)fftw_malloc(sizeof(fftw_complex) * vecData.size()); + + for (int j = 0; j < vecData.size(); j++) { + inHilFFt[j][0] = (double)vecData[j]; + inHilFFt[j][1] = 0; + } + + FFT(vecData.size(), inHilFFt, outHilFFt); + fftShift(outHilFFt, vecData.size()); + for (int i = 0; i < vecData.size(); i++) { + vecFFTrealData.push_back(outHilFFt[i][0]); + vecFFTimageData.push_back(outHilFFt[i][1]); + } + fftw_free(inHilFFt); + fftw_free(outHilFFt); +} //************************************ // Method: caculateAmp_Pha // FullName: Calculation::caculateAmp_Pha @@ -155,6 +194,22 @@ float Calculation::rms(std::vector & vecData) } + +float Calculation::getSample_variance(std::vector a) +{ + float ss = 0; + float s = 0; + float mx = mean(a); + int len = a.size(); + for (int i = 0; i < len; i++) { + s = a[i] - mx; + ss += pow(s, 2); + } + return ss / (len - 1); +} + + + float Calculation::variance(std::vector & vecDropMeanData) { double varianceTemp = 0; @@ -187,7 +242,43 @@ float Calculation::kurtosis(std::vector & vecDropMeanData, float fVarianc tempkurtosis = tempkurtosis / pow(fVariance, 2); return tempkurtosis; } +void Calculation::Hanning(std::vector & vecData,std::vector & vecHanningData) +{ + int N = vecData.size(); + float* w = NULL; + w = (float*)calloc(N, sizeof(float)); + int half, i, idx; + if (N % 2 == 0) + { + half = N / 2; + for (i = 0; i < half; i++) //CALC_HANNING Calculates Hanning window samples. + w[i] = 0.5 * (1 - cos(2 * pi * (i + 1) / (N + 1))); + + + idx = half - 1; + for (i = half; i < N; i++) { + w[i] = w[idx]; + idx--; + } + } + else + { + half = (N + 1) / 2; + for (i = 0; i < half; i++) //CALC_HANNING Calculates Hanning window samples. + w[i] = 0.5 * (1 - cos(2 * pi * (i + 1) / (N + 1))); + + idx = half - 2; + for (i = half; i < N; i++) { + w[i] = w[idx]; + idx--; + } + } + for(int j = 0; j < N;j++){ + vecHanningData.push_back(w[j]); + } + free(w); +} void Calculation::hilbert(std::vector & vecData, std::vector & vecHilbertData, int N) { @@ -253,6 +344,7 @@ void Calculation::hilbert(std::vector & vecData, std::vector & vec vecHilbertData.push_back(amp); // printf("%d %f\n",n,vecHilbertData[n]); } + fftw_free(out); } @@ -289,9 +381,9 @@ void Calculation::FFTSpec(std::vector & vecData, std::vector & vec } -void Calculation::envSpec(std::vector & vecData, std::vector & vecEnvSpecData) +void Calculation::envSpec(std::vector & vecData, std::vector & vecEnvSpecData,int StartFrequency,int EndFrequency) { - std::vector vecDropMeanData; + /*std::vector vecDropMeanData; drop_mean(vecDropMeanData, vecData); std::vector vecHilbertData; @@ -313,5 +405,42 @@ void Calculation::envSpec(std::vector & vecData, std::vector & vec for (int i = vecHilbertData.size() / 2 + 1; i < vecHilbertData.size(); i++) { float ftemp = 2 * sqrt(outHilFFt[i][0] * outHilFFt[i][0] + outHilFFt[i][1] * outHilFFt[i][1]) / vecHilbertData.size(); vecEnvSpecData.push_back(ftemp); - } + }*/ + std::vector vecFFTrealData,vecFFTimageData; + std::vector vecRealData,vecImageData; + std::vector veciFFtData; + std::vector veciFFtData2; + std::vector vecHilbertData; + _FFT(vecData,vecFFTrealData,vecFFTimageData); + for(int i = 0; i < vecFFTrealData.size();i++){ + if(i > StartFrequency && i < EndFrequency){ + vecRealData.push_back(vecFFTrealData.at(i)); + vecImageData.push_back(vecFFTimageData.at(i)); + }else{ + vecRealData.push_back(0); + vecImageData.push_back(0); + } + } + _iFFT(vecRealData,vecImageData,veciFFtData); + for(int j = 0; j < veciFFtData.size();j++){ + veciFFtData2.push_back(veciFFtData[j]*2); + } + hilbert(veciFFtData2,vecHilbertData,veciFFtData2.size()); + FFTSpec(vecHilbertData, vecEnvSpecData); +} + + +void Calculation::GenerateSin(std::vector & vecData) +{ + int i; + int ft = 1; /* 周期 hz */ + int fs = 12800; /* 采样频率*/ + + /* generate data */ + int data_len = (8*1024); + + for (i = 0; i < data_len; i++) { + vecData.push_back(sin(1000 * 2 *3.1415926*ft*i/fs)); + } + } diff --git a/calculation/Calculation.hpp b/calculation/Calculation.hpp index 3e26611..6d888be 100644 --- a/calculation/Calculation.hpp +++ b/calculation/Calculation.hpp @@ -75,7 +75,8 @@ public: float rms(std::vector & vecData); - + //获取样本方差 + float getSample_variance(std::vector a); //去数据的直流分量 @@ -105,7 +106,8 @@ public: float kurtosis(std::vector & vecDropMeanData, float fVariance); - + //hanning 窗 + void Hanning(std::vector & vecData,std::vector & vecHanningData); //快速傅里叶变换函数 @@ -122,8 +124,8 @@ public: //快速傅里叶逆变换 void iFFT(int n, fftw_complex* in, fftw_complex* out); - - + void _iFFT(std::vector & vecData, std::vector & vecFFTSpecData,std::vector & veciFFTData); + void _FFT(std::vector & vecData, std::vector & vecFFTrealData,std::vector & vecFFTimageData); //通道幅值和相位提取 @@ -139,7 +141,8 @@ public: - + //生成正弦信号 + void GenerateSin(std::vector & vecData); //FFT shift @@ -147,7 +150,7 @@ public: //频谱图数据 void FFTSpec(std::vector & vecData, std::vector & vecFFTSpecData); //包络图谱数据 - void envSpec(std::vector & vecData, std::vector & vecEnvSpecData); + void envSpec(std::vector & vecData, std::vector & vecEnvSpecData,int StartFrequency,int EndFrequency); }; diff --git a/common/Mutex.h b/common/Mutex.h new file mode 100644 index 0000000..ece4f02 --- /dev/null +++ b/common/Mutex.h @@ -0,0 +1,20 @@ +#ifndef _MY_COMM_H_ +#define _MY_COMM_H_ +#include + +class Mutex { +private: + pthread_mutex_t mutex; +public: + Mutex() { mutex = PTHREAD_MUTEX_INITIALIZER;pthread_mutex_init(&mutex,NULL); /*printf("\n pthread_mutex_init \n");*/} + virtual ~Mutex() {pthread_mutex_destroy(&mutex); /*printf("\n pthread_mutex_destroy \n");*/} + void Lock() {pthread_mutex_lock(&mutex); /*printf("\n mutex lock \n");*/} + void UnLock() {pthread_mutex_unlock(&mutex); /*printf("\n mutex unlock \n");*/} +}; +//Mutex g_Mutex; + + + + + +#endif //_MY_COMM_H_ diff --git a/common/SH_CommonFunc.cpp b/common/SH_CommonFunc.cpp index 016dd81..ab7e782 100644 --- a/common/SH_CommonFunc.cpp +++ b/common/SH_CommonFunc.cpp @@ -3,9 +3,353 @@ #include "SH_global.h" #include "SH_CommonFunc.hpp" #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../dbaccess/SH_SqlDB.hpp" +#define ETHTOOL_GLINK 0x0000000a /* Get link status (ethtool_value) */ +#define MAX_WAIT_TIME 1 +#define MAX_NO_PACKETS 1 +#define ICMP_HEADSIZE 8 +#define PACKET_SIZE 4096 +struct timeval tvsend,tvrecv; +struct sockaddr_in dest_addr,recv_addr; +int sockfd; +pid_t pid; +char sendpacket[PACKET_SIZE]; +char recvpacket[PACKET_SIZE]; static boost::mutex s_config_mu; +Mutex g_tDbMutex; +string GetLocalTimeWithMs(void) +{ + string defaultTime = "19700101000000000"; + try + { + struct timeval curTime; + gettimeofday(&curTime, NULL); + int milli = curTime.tv_usec / 1000; + + char buffer[80] = {0}; + struct tm nowTime; + localtime_r(&curTime.tv_sec, &nowTime);//把得到的值存入临时分配的内存中,线程安全 + strftime(buffer, sizeof(buffer), "%Y%m%d%H%M%S", &nowTime); + + char currentTime[84] = {0}; + snprintf(currentTime, sizeof(currentTime), "%s%03d", buffer, milli); + + return currentTime; + } + catch(const std::exception& e) + { + return defaultTime; + } + catch (...) + { + return defaultTime; + } +} +int code_convert(const char *from_charset, const char *to_charset, char *inbuf, size_t inlen, + char *outbuf, size_t outlen) { + iconv_t cd; + char **pin = &inbuf; + char **pout = &outbuf; + + cd = iconv_open(to_charset, from_charset); + if (cd == 0) + return -1; + + memset(outbuf, 0, outlen); + + if ((int)iconv(cd, pin, &inlen, pout, &outlen) == -1) + { + iconv_close(cd); + return -1; + } + iconv_close(cd); + *pout = '\0'; + + return 0; +} + +int u2g(char *inbuf, size_t inlen, char *outbuf, size_t outlen) { + return code_convert("utf-8", "gb2312", inbuf, inlen, outbuf, outlen); +} + +int g2u(char *inbuf, size_t inlen, char *outbuf, size_t outlen) { + return code_convert("gb2312", "utf-8", inbuf, inlen, outbuf, outlen); +} + +std::string GBKToUTF8(const std::string& strGBK) +{ + int length = strGBK.size()*2+1; + + char *temp = (char*)malloc(sizeof(char)*length); + + if(g2u((char*)strGBK.c_str(),strGBK.size(),temp,length) >= 0) + { + std::string str_result; + str_result.append(temp); + free(temp); + return str_result; + }else + { + free(temp); + return ""; + } +} + +std::string UTFtoGBK(const char* utf8) +{ + int length = strlen(utf8); + + char *temp = (char*)malloc(sizeof(char)*length); + + if(u2g((char*)utf8,length,temp,length) >= 0) + { + std::string str_result; + str_result.append(temp); + free(temp); + + return str_result; + }else + { + free(temp); + return ""; + } +} + + +void InitGpio(unsigned int gpioN,unsigned int inout) +{ + int fd = 0; + char tmp[100] = {0}; + //打开gpio设备文件 + fd = open("/sys/class/gpio/export", O_WRONLY); + if(-1 == fd) + { + printf("[%s]:[%d] open gpio export file error\r\n", __FUNCTION__, __LINE__); + } + //申请gpio + sprintf(tmp,"%d",gpioN); + if(write(fd, tmp, strlen(tmp)) < 0) + { + printf("write file operation error %s\r\n",tmp); + + } + close(fd); + sleep(1); + //配置gpio方向 +#ifdef G2UL_GATEWAY + char tmp2[100] = {0}; + if(gpioN == 507) + memcpy(tmp2,"P18_3",5); + else if(gpioN == 499) + memcpy(tmp2,"P17_3",5); + else if(gpioN == 496) + memcpy(tmp2,"P17_0",5); + else if(gpioN == 130) + memcpy(tmp2,"P9_0",4); + else if(gpioN == 408) + memcpy(tmp2,"P6_0",4); + else if(gpioN == 363) + memcpy(tmp2,"P0_3",4); + else if(gpioN == 498) + memcpy(tmp2,"P17_2",5); + else if(gpioN == 466) + memcpy(tmp2,"P13_2",5); + else if(gpioN == 488) + memcpy(tmp2,"P16_0",5); + else if(gpioN == 474) + memcpy(tmp2,"P14_2",5); + else if(gpioN == 497) + memcpy(tmp2,"P17_1",5); + else if(gpioN == 409) + memcpy(tmp2,"P6_1",4); + else if(gpioN == 410) + memcpy(tmp2,"P6_2",4); + else if(gpioN == 449) + memcpy(tmp2,"P11_1",5); + else if(gpioN == 489) + memcpy(tmp2,"P16_1",5); + sprintf(tmp,"/sys/class/gpio/%s/direction",tmp2); +#else if IMX6UL_GATEWAY + sprintf(tmp,"/sys/class/gpio/gpio%d/direction",gpioN); +#endif + + print_info("open GPIO = %s\n",tmp); + fd = open(tmp, O_WRONLY); + if(-1 == fd) + { + printf("[%s]:[%d] open gpio direction file error\r\n", __FUNCTION__, __LINE__); + } + + if(inout == 0) + { + print_info("=====InitGpio=====in\n"); + if(-1 == write(fd, "in", sizeof("in"))) + { + print_info("[%s]:[%d] [%d]write operation direction error\r\n", __FUNCTION__, __LINE__,gpioN); + close(fd); + } + } + else if( inout == 1) + { + print_info("=====InitGpio=====out\n"); + if(-1 == write(fd, "out", sizeof("out"))) + { + print_info("[%s]:[%d] [%d]write operation direction error\r\n", __FUNCTION__, __LINE__,gpioN); + close(fd); + } + } + close(fd); +// printf("gpio%d init %d\r\n",gpioN,inout); +} +int gpio_set(unsigned int gpioN,char x) +{ + int fd = 0; + char tmp[100] = {0}; +#ifdef G2UL_GATEWAY + char tmp2[100] = {0}; + if(gpioN == 507) + memcpy(tmp2,"P18_3",5); + else if(gpioN == 499) + memcpy(tmp2,"P17_3",5); + else if(gpioN == 496) + memcpy(tmp2,"P17_0",5); + else if(gpioN == 130) + memcpy(tmp2,"P9_0",4); + else if(gpioN == 408) + memcpy(tmp2,"P6_0",4); + else if(gpioN == 363) + memcpy(tmp2,"P0_3",4); + else if(gpioN == 498) + memcpy(tmp2,"P17_2",5); + else if(gpioN == 466) + memcpy(tmp2,"P13_2",5); + else if(gpioN == 488) + memcpy(tmp2,"P16_0",5); + else if(gpioN == 474) + memcpy(tmp2,"P14_2",5); + else if(gpioN == 497) + memcpy(tmp2,"P17_1",5); + else if(gpioN == 409) + memcpy(tmp2,"P6_1",4); + else if(gpioN == 410) + memcpy(tmp2,"P6_2",4); + else if(gpioN == 449) + memcpy(tmp2,"P11_1",5); + else if(gpioN == 489) + memcpy(tmp2,"P16_1",5); + sprintf(tmp,"/sys/class/gpio/%s/value",tmp2); +#else if IMX6UL_GATEWAY + sprintf(tmp,"/sys/class/gpio/gpio%d/value",gpioN); +#endif +// printf("%s\r\n",tmp); + //print_info("set GPIO = %s\n",tmp); + //打开gpio value文件 + fd = open(tmp, O_WRONLY); + if(-1 == fd) + { + print_red("[%s]:[%d] open gpio export file error\r\n", __FUNCTION__, __LINE__); + return (-1);//exit(1); + } + //设置电平 + if(x) + { + if(-1 == write(fd, "1", sizeof("1"))) + { + print_red("[%s]:[%d] %d write operation value error\r\n", __FUNCTION__, __LINE__,gpioN); + close(fd); + return (-1);//exit(1); + } + } + else + { + if(-1 == write(fd, "0", sizeof("0"))) + { + print_red("[%s]:[%d] %d write operation value error\r\n", __FUNCTION__, __LINE__,gpioN); + close(fd); + return (-1);//exit(1); + } + } +// printf("gpio%d set %d ok\r\n",gpioN,x); + close(fd); + return 0; +} +int gpio_read(unsigned int gpioN) +{ + int fd = 0; + char value; + + char tmp[100] = {0}; + +#ifdef G2UL_GATEWAY + char tmp2[100] = {0}; + if(gpioN == 507) + memcpy(tmp2,"P18_3",5); + else if(gpioN == 499) + memcpy(tmp2,"P17_3",5); + else if(gpioN == 496) + memcpy(tmp2,"P17_0",5); + else if(gpioN == 130) + memcpy(tmp2,"P9_0",4); + else if(gpioN == 408) + memcpy(tmp2,"P6_0",4); + else if(gpioN == 363) + memcpy(tmp2,"P0_3",4); + else if(gpioN == 498) + memcpy(tmp2,"P17_2",5); + else if(gpioN == 466) + memcpy(tmp2,"P13_2",5); + else if(gpioN == 488) + memcpy(tmp2,"P16_0",5); + else if(gpioN == 474) + memcpy(tmp2,"P14_2",5); + else if(gpioN == 497) + memcpy(tmp2,"P17_1",5); + else if(gpioN == 409) + memcpy(tmp2,"P6_1",4); + else if(gpioN == 410) + memcpy(tmp2,"P6_2",4); + else if(gpioN == 449) + memcpy(tmp2,"P11_1",5); + else if(gpioN == 489) + memcpy(tmp2,"P16_1",5); + sprintf(tmp,"/sys/class/gpio/%s/value",tmp2); +#else if IMX6UL_GATEWAY + sprintf(tmp,"/sys/class/gpio/gpio%d/value",gpioN); +#endif + //打开gpio value文件 + fd = open(tmp, O_RDONLY); + if(-1 == fd) + { + print_red("[%s]:[%d] %d open gpio export file error\r\n", __FUNCTION__, __LINE__,gpioN); + return (-1);//exit(1); + } + //读取 value文件 + if(-1 == read(fd, &value, sizeof(value))) + { + print_red("[%s]:[%d] %d read gpiovalue is fail\r\n", __FUNCTION__, __LINE__,gpioN); + close(fd); + return (-1);//exit(1); + } + close(fd); + //printf("gpio%d get %d\r\n",gpioN,value); + return value; +} int CheckFileVersion(int argc, char** argv) { @@ -36,8 +380,81 @@ int CheckFileVersion(int argc, char** argv) } return 0; } +int config_uart(const char* Port,speed_t speed) +{ + int iFd = open(Port,O_RDWR | O_NOCTTY); + if(iFd < 0) { + return -1; + } + struct termios opt; + tcgetattr(iFd, &opt); + cfsetispeed(&opt, speed); + cfsetospeed(&opt, speed); + if (tcgetattr(iFd, &opt)<0) { + return -1; + } + opt.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG); + opt.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON); + opt.c_oflag &= ~(OPOST); + opt.c_cflag &= ~(CSIZE | PARENB | CBAUD); + opt.c_cflag |= (CS8 | speed); + opt.c_cc[VMIN] = 255; + opt.c_cc[VTIME] = 5; + if (tcsetattr(iFd, TCSANOW, &opt)<0) { + return -1; + } + tcflush(iFd,TCIOFLUSH); + return iFd; +} +int write_data(int fd, char *buff, int len) +{ + int ret; + char buf[100]; + ret = write(fd, buff, len); + if (ret < 0) { + return -1; + } + return ret; +} +int read_data(int fd, char *buff, int len, int timeout) +{ + int ret; + struct timeval to; + fd_set rdfds; + + to.tv_sec = 0; + to.tv_usec = timeout; + + FD_ZERO(&rdfds); + FD_SET(fd, &rdfds); + + if (timeout > 0) { + ret = select(fd+1, &rdfds, NULL, NULL, &to); + if (ret <= 0) { + // printf("zigbee doesn't respond!\n"); + return ret; + } + } + + ret = read(fd,buff,len); + if(ret < 0) { + perror("read_data"); + return -1; + } + buff[ret] = '\0'; + return ret; +} +int ModifyMac(char* buff) +{ + FILE *fp = fopen("/opt/system/mac", "w"); + fprintf(fp, buff); + fprintf(fp, "\n"); + fclose(fp); + system("cp /opt/system/mac /opt/system/macbak"); + system("/opt/Cidn/init.sh"); +} std::string GetCurrentTime() { struct tm nowtime; @@ -114,7 +531,50 @@ void GetTimeNet(char* timebuf,int type) } } +// 获取RTC时间 +std::string GetRTC(char* timestamp,int& millisecond) +{ + time_t rtc_timestamp; + struct tm tm; + struct timespec ts; + char rtcTime[100]={0x00}; + int fd = open("/dev/rtc0", O_RDONLY); + if (fd < 0) { + perror("open /dev/rtc0"); + } else { + struct rtc_time rtc_tm; + if (ioctl(fd, RTC_RD_TIME, &rtc_tm) < 0) { + perror("ioctl RTC_RD_TIME"); + } else { + clock_gettime(CLOCK_REALTIME, &ts); + millisecond = (int)(ts.tv_nsec / 1000000); + printf("RTC date/time is %d-%d-%d, %02d:%02d:%02d\n", + rtc_tm.tm_year + 1900, rtc_tm.tm_mon + 1, rtc_tm.tm_mday, + rtc_tm.tm_hour, rtc_tm.tm_min, rtc_tm.tm_sec); + sprintf(rtcTime,"%d-%d-%d, %02d:%02d:%02d",rtc_tm.tm_year + 1900, rtc_tm.tm_mon + 1, rtc_tm.tm_mday, + rtc_tm.tm_hour, rtc_tm.tm_min, rtc_tm.tm_sec); + // 将rtc_time结构体转换为time_t时间戳 + tm.tm_year = rtc_tm.tm_year; + tm.tm_mon = rtc_tm.tm_mon; + tm.tm_mday = rtc_tm.tm_mday; + tm.tm_hour = rtc_tm.tm_hour; + tm.tm_min = rtc_tm.tm_min; + tm.tm_sec = rtc_tm.tm_sec; + tm.tm_isdst = -1; // 不使用夏令时 + + rtc_timestamp = mktime(&tm); + + if (rtc_timestamp == -1) { + perror("mktime"); + } + printf("RTC timestamp is %ld,millisecond = %d\n", rtc_timestamp,millisecond); + sprintf(timestamp,"%ld",rtc_timestamp); + } + } + close(fd); + return std::string(rtcTime); +} void GetTime_(char time_buff[],TIME_SIZE len) { int i = sizeof(time_buff); @@ -142,24 +602,218 @@ std::string ReadStrByOpt(std::string filename, std::string config, std::string o is.close(); return value; } -std::vector ReadStrByOpt(std::string filename,std::string& strUpdataFileName) +std::vector ReadStrUpdate(std::string filename) { boost::mutex::scoped_lock lock(s_config_mu); Json::Value root,hwVersion; Json::Reader reader; std::vector value; + std::vector vecDataNodeUpdate; + DataNodeUpdate datanodeUpdate; std::fstream is; is.open(filename.c_str(), std::ios::in); if (reader.parse(is, root)) { - hwVersion = root["hw_vesion"]; - strUpdataFileName = root["fw_name"].asString(); - } - for(int i = 0; i < hwVersion.size();i++){ - value.push_back(hwVersion[i].asString()); - } + print_info("root = %d\n",root.size()); + for(int i = 0; i < root.size();i++){ + hwVersion = root[i]["hw_vesion"]; + for(int i = 0; i < hwVersion.size();i++){ + datanodeUpdate.hwVersion.push_back(hwVersion[i].asString()); + } + datanodeUpdate.strUpdataFileName = root[i]["fw_name"].asString(); + datanodeUpdate.strSoftVersion = root[i]["sf_vesion"].asString(); + print_info("strUpdataFileName = %s,strSoftVersion = %s\n",datanodeUpdate.strUpdataFileName.c_str(),\ + datanodeUpdate.strSoftVersion.c_str()); + vecDataNodeUpdate.push_back(datanodeUpdate); + } + } is.close(); - return value; + + return vecDataNodeUpdate; +} +void ReadStrConfig(std::string filename) +{ + Json::Value root,gateWay,dataNode; + std::fstream is; + Json::Reader reader; + is.open(filename.c_str(), std::ios::in); + string zigbeeChannel; + if (reader.parse(is, root)) { + gateWay = root["gateWay"]; + dataNode = root["dataNodeArray"]; + print_info("dataNode = %d\n",dataNode.size()); + for(int i = 0; i < dataNode.size();i++){ + string softVersion = dataNode[i]["softVersion"].asString(); + string bpNo = dataNode[i]["bpNo"].asString(); + print_info("bpNo = %s\n",bpNo.c_str()); + string wakeupTime = dataNode[i]["wakeupTime"].asString(); + int viff = dataNode[i]["viff"].asInt(); + string StaticTime = dataNode[i]["StaticTime"].asString(); + int configFlag = dataNode[i]["configFlag"].asInt(); + int rangeValue = dataNode[i]["range"].asInt(); + int updateValue = dataNode[i]["update"].asInt(); + string zigbeeLongAddr = dataNode[i]["zigbeeLongAddr"].asString(); + int accFlag = dataNode[i]["accFlag"].asInt(); + print_info("accFlag = %d\n",accFlag); + int temTopFlag = dataNode[i]["temTopFlag"].asInt(); + string startBrands = dataNode[i]["startBrands"].asString(); + int waveInterVal = dataNode[i]["waveInterVal"].asInt(); + string zigbeePanId = dataNode[i]["zigbeePanId"].asString(); + int waveTime = dataNode[i]["waveTime"].asInt(); + int zigbeePower = dataNode[i]["zigbeePower"].asInt(); + int zigbeeRetry = dataNode[i]["zigbeeRetry"].asInt(); + string stopBrands = dataNode[i]["stopBrands"].asString(); + int featureInterVal = dataNode[i]["featureInterVal"].asInt(); + int zigbeeFlag = dataNode[i]["zigbeeFlag"].asInt(); + string zigbeeDesAddr = dataNode[i]["zigbeeDesAddr"].asString(); + print_info("zigbeeDesAddr = %s\n",zigbeeDesAddr.c_str()); + int ZigbeeRetryGap = dataNode[i]["zigbeeRetryGap"].asInt(); + string dataNodeNo = dataNode[i]["dataNodeNo"].asString(); + int initFlag = dataNode[i]["initFlag"].asInt(); + string faultFrequency = dataNode[i]["faultFrequency"].asString(); + int temBotFlag = dataNode[i]["temBotFlag"].asInt(); + string bateryV = dataNode[i]["bateryV"].asString(); + int ACCSampleTime = dataNode[i]["ACCSampleTime"].asInt(); + print_info("ACCSampleTime = %d\n",ACCSampleTime); + string firstPowerTime = dataNode[i]["firstPowerTime"].asString(); + string serialNo = dataNode[i]["serialNo"].asString(); + string zigbeeAddr = dataNode[i]["zigbeeAddr"].asString(); + string productNo = dataNode[i]["productNo"].asString(); + string timeStamp = dataNode[i]["timeStamp"].asString(); + zigbeeChannel = dataNode[i]["zigbeeChannel"].asString(); + int RSSI = dataNode[i]["RSSI"].asInt(); + print_info("RSSI = %d\n",RSSI); + string hardVersion = dataNode[i]["hardVersion"].asString(); + string envelopeBandPass = dataNode[i]["envelopeBandPass"].asString(); + int samplingRate = dataNode[i]["samplingRate"].asInt(); + string dataNodeName = dataNode[i]["dataNodeName"].asString(); + int status = dataNode[i]["status"].asInt(); + int EquipSta = dataNode[i]["equipSta"].asInt(); + char insertSql[1024] = { 0 }; + char whereCon[100]={0x00}; + sprintf(whereCon,"dataNodeNo = '%s'",dataNodeNo.c_str()); + int rows = sql_ctl->GetTableRows(T_SENSOR_INFO(TNAME), whereCon); + if(rows > 0) + continue; + sprintf(insertSql, "'%s','%s','%d','%d','%d','%d','%d','%d',\ + '%s','%s','%s','%s','%s','%d',\ + '%d','%d','%d','%s','%d','%s',\ + '%s','%d','%d','%d','%s','%d','%s','%s',\ + '%s','%d','%s','%s','%s',\ + '%d','%d','%d','%d','%d','%s','%d','%d','%d','0','0,0'", + dataNodeNo.c_str(), dataNodeName.c_str(), initFlag, accFlag, zigbeeFlag, temTopFlag, temBotFlag,EquipSta,\ + hardVersion.c_str(), softVersion.c_str(), bpNo.c_str(), serialNo.c_str(), firstPowerTime.c_str(), atoi(wakeupTime.c_str()),\ + atoi(StaticTime.c_str()),waveTime,atoi(bateryV.c_str()),productNo.c_str(),configFlag, startBrands.c_str(), \ + stopBrands.c_str(), featureInterVal, waveInterVal, samplingRate,"",rangeValue, envelopeBandPass.c_str(), faultFrequency.c_str(),\ + zigbeePanId.c_str(), atoi(zigbeeChannel.c_str()), zigbeeAddr.c_str(), zigbeeLongAddr.c_str(), zigbeeDesAddr.c_str(), \ + zigbeePower,zigbeeRetry,ZigbeeRetryGap,ACCSampleTime,status, timeStamp.c_str(),viff,RSSI,updateValue); + sql_ctl->InsertData(T_SENSOR_INFO(TNAME), insertSql); + } + + /*WriteStr2Config(SERVERCONFIG, "Server", "localServerIpAddress", gateWay["Server"]["localServerIpAddress"].asString()); + WriteStr2Config(SERVERCONFIG, "Server", "localServerPort", gateWay["Server"]["localServerPort"].asString()); + WriteStr2Config(SERVERCONFIG, "Server", "CommMode", gateWay["Server"]["CommMode"].asString()); + WriteStr2Config(SERVERCONFIG, "Server", "UserName", gateWay["Server"]["UserName"].asString()); + WriteStr2Config(SERVERCONFIG, "Server", "Password", gateWay["Server"]["Password"].asString()); + + WriteStr2Config(NETWORKCONFIG, "Net", "dnsName", gateWay["Net"]["dnsName"].asString()); + WriteStr2Config(NETWORKCONFIG, "Net", "networkPortStatus", gateWay["Net"]["networkPortStatus"].asString()); + WriteStr2Config(NETWORKCONFIG, "Net", "gateway", gateWay["Net"]["gateway"].asString()); + WriteStr2Config(NETWORKCONFIG, "Net", "subnetMask", gateWay["Net"]["subnetMask"].asString()); + WriteStr2Config(NETWORKCONFIG, "Net", "ipAddress", gateWay["Net"]["ipAddress"].asString()); + WriteStr2Config(NETWORKCONFIG, "Net", "hostName", gateWay["Net"]["hostName"].asString()); + + WriteStr2Config(ZIGBEECONFIG, "Zigbee", "channel", zigbeeChannel);*/ + }else{ + print_info("parse error\n"); + } + is.close(); +} +int UpdataDataNodeConfig(std::string filename) +{ + vector vecDataNode; //声明一个字符串向量 + //以读入方式打开文件 + ifstream csv_data(filename, ios::in); + int iRet = 0; + if (!csv_data.is_open()) + { + cout << "Error: opening file fail" << endl; + return -1; + } + else { + string line; + + vector words; //声明一个字符串向量 + string word; + + DataNodeInfo dataNode; + // ------------读取数据----------------- + // 读取标题行 + getline(csv_data, line); + + + istringstream sin; + // 按行读取数据 + while (getline(csv_data, line)) + { + words.clear(); + sin.clear(); + sin.str(line); + while (getline(sin, word, ',')) + { + cout << word << endl; + words.push_back(word); + + } + string mac = words[1]; + if(mac != GlobalConfig::MacAddr_G){ + iRet = -2; + break; + } + dataNode.ZigbeeLongAddr = words[7]; + dataNode.FeatureInterVal = atoi(words[14].c_str()); + dataNode.WaveInterVal = atoi(words[15].c_str()); + dataNode.SamplingRate = atoi(words[16].c_str()); + print_info("words[17] = %s\n",words[17].c_str()); + + if(words[17].find("8g") != string::npos){ + dataNode.Range = 0; + }else if(words[17].find("16g") != string::npos){ + dataNode.Range = 1; + }else if(words[17].find("32g") != string::npos){ + dataNode.Range = 2; + }else if(words[17].find("64g") != string::npos){ + dataNode.Range = 3; + }else if(words[17].find("50g") != string::npos){ + dataNode.Range = 0; + } + + dataNode.ACCSampleTime = atoi(words[18].c_str()); + int update = atoi(words[20].c_str()); + if(update == 1) + vecDataNode.push_back(dataNode); + } + csv_data.close(); + } + + char whereCon[1024] = {0}; + char updateSql[1024] = { 0 }; + if(vecDataNode.size() > 0){ + for(int i = 0; i < vecDataNode.size();i++){ + sprintf(updateSql, "featureInterVal='%d',waveInterVal='%d',range='%d',samplingRate='%d',AccSampleTime = '%d',UpdateFlag = 0", + vecDataNode[i].FeatureInterVal, vecDataNode[i].WaveInterVal,vecDataNode[i].Range,\ + vecDataNode[i].SamplingRate,vecDataNode[i].ACCSampleTime); + sprintf(whereCon, "dataNodeNo='%s'", vecDataNode[i].ZigbeeLongAddr.c_str()); + + int iRet = sql_ctl->UpdateTableData(T_SENSOR_INFO(TNAME), updateSql, whereCon); + memset(whereCon,0x00,sizeof(whereCon)); + memset(updateSql,0x00,sizeof(updateSql)); + } + iRet = vecDataNode.size() ; + }else{ + iRet = -3; + } + return iRet; } int WriteStr2Config(std::string filename, std::string config, std::string option, std::string value, bool listable) { @@ -197,7 +851,7 @@ int WriteStr2Config(std::string filename, std::string config, std::string option } -std::string GetLocalMac() +std::string GetLocalMac(const char* net) { int sock_mac; struct ifreq ifr_mac; @@ -208,7 +862,7 @@ std::string GetLocalMac() return ""; } memset(&ifr_mac,0,sizeof(ifr_mac)); - strncpy(ifr_mac.ifr_name, "eth0", sizeof(ifr_mac.ifr_name)-1); + strncpy(ifr_mac.ifr_name, net, sizeof(ifr_mac.ifr_name)-1); if( (ioctl( sock_mac, SIOCGIFHWADDR, &ifr_mac)) < 0) { printf("mac ioctl error/n"); return ""; @@ -219,9 +873,10 @@ std::string GetLocalMac() (unsigned char)ifr_mac.ifr_hwaddr.sa_data[2], (unsigned char)ifr_mac.ifr_hwaddr.sa_data[3], (unsigned char)ifr_mac.ifr_hwaddr.sa_data[4], - (unsigned char)ifr_mac.ifr_hwaddr.sa_data[5]); + (unsigned char)ifr_mac.ifr_hwaddr.sa_data[5]); printf("local mac:%s /n",mac_addr); close( sock_mac ); + LOG_INFO("net : %s,mac:%s\n",net,mac_addr); return std::string( mac_addr ); } @@ -238,7 +893,7 @@ std::string GetGwIp_(const char *eth_name) bzero(&req, sizeof(struct ifreq)); strcpy(req.ifr_name, eth_name); - print_info("eth_name = %s\n",eth_name); + //print_info("eth_name = %s\n",eth_name); ioctl(sockfd, SIOCGIFADDR, &req); host = (struct sockaddr_in*) &req.ifr_addr; close(sockfd); @@ -250,14 +905,43 @@ std::string GetGwIp_(const char *eth_name) std::string IpAddrInit() { + const char *WLAN2 = "wlan2"; const char *WLAN0 = "wlan0"; const char *ETH0 = "eth0"; - std::string strip; - strip = GetGwIp_(ETH0); - if (strip.compare("0.0.0.0") == 0) { - strip = GetGwIp_(WLAN0); + const char *USB0 = "usb0"; + const char *WWAN0 = "wwan0"; + const char *ETH1 = "eth1"; + const char *ETH2 = "eth2"; + std::string strip = ""; + strip = GetGwIp_(WLAN0); + if (strip.compare("0.0.0.0") != 0) { + return strip; } - return strip; + strip = GetGwIp_(WLAN2); + if (strip.compare("0.0.0.0") != 0) { + return strip; + } + strip = GetGwIp_(ETH1); + if (strip.compare("0.0.0.0") != 0) { + return strip; + } + strip = GetGwIp_(ETH2); + if (strip.compare("0.0.0.0") != 0) { + return strip; + } + strip = GetGwIp_(ETH0); + if (strip.compare("0.0.0.0") != 0) { + return strip; + } + strip = GetGwIp_(USB0); + if (strip.compare("0.0.0.0") != 0) { + return strip; + } + strip = GetGwIp_(WWAN0); + if (strip.compare("0.0.0.0") != 0) { + return strip; + } + //return strip; } std::string GetWorkNic() @@ -308,8 +992,8 @@ std::string GetSysInfo() system_custom(getMemFree, chRes); std::string MemFree = std::string(chRes); - float a = boost::lexical_cast(MemFree); - float b = boost::lexical_cast(MemTotal); + float a = atof(MemFree.c_str()); + float b = atof(MemTotal.c_str()); float c = (1 - a/b)*100; const char * getEmmcInfo = "df -h | grep /dev/root"; @@ -323,7 +1007,7 @@ std::string GetSysInfo() Emmcinfo = ClearAllSpace(Emmcinfo); char sysinfo[128] = {0}; - sprintf(sysinfo, "%-13s%-13s%-13s%-13s ", boost::lexical_cast(c).substr(0,4).c_str(), CpuSys.c_str(), CpuUse.c_str(), Emmcinfo.c_str()); + sprintf(sysinfo, "%-13s%-13s%-13s%-13s ", to_string(c).substr(0,4).c_str(), CpuSys.c_str(), CpuUse.c_str(), Emmcinfo.c_str()); return std::string(sysinfo); } @@ -443,10 +1127,8 @@ std::string GetFileContent(std::string filename, int line) //BOOST用正则表达式验证ip地址合法 bool CheckIP(const char *ip) { - using namespace boost::xpressive; - /* 定义正则表达式 */ - cregex reg_ip = cregex::compile("(25[0-5]|2[0-5][0-9]|1[0-9][0-9]|[1-9][0-9]|[1-9])[.](25[0-5]|2[0-5][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])[.](25[0-5]|2[0-5][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])[.](25[0-5]|2[0-5][0-9]|1[0-9][0-9]|[1-9][0-9]|[1-9])"); - return regex_match(ip, reg_ip); + boost::xpressive::cregex reg_ip = boost::xpressive::cregex::compile("(25[0-4]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[1-9])[.](25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])[.](25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])[.](25[0-4]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[1-9])"); + return boost::xpressive::regex_match(ip, reg_ip); } bool IsValidMask(std::string mask) { @@ -542,13 +1224,13 @@ bool IsValidMask(std::string mask) { // jsData["memoryTotal"] = (int)mem_total; // jsData["memoryFree"] = (int)mem_free; // jsData["memoryUse"] = fMemRate * 100; -// jsData["hardDiskTotal"] = boost::lexical_cast(strhardTotal.substr(0,strhardTotal.length() - 1)); -// jsData["hardDiskFree"] = boost::lexical_cast(strhardFree.substr(0,strhardFree.length() - 1)); +// jsData["hardDiskTotal"] = atof(strhardTotal.substr(0,strhardTotal.length() - 1)); +// jsData["hardDiskFree"] = atof(strhardFree.substr(0,strhardFree.length() - 1)); -// double total = boost::lexical_cast(strhardTotal.substr(0,strhardTotal.length() - 1)); -// double free = boost::lexical_cast(strhardFree.substr(0,strhardFree.length() - 1)); +// double total = atof(strhardTotal.substr(0,strhardTotal.length() - 1)); +// double free = atof(strhardFree.substr(0,strhardFree.length() - 1)); // double use = ((total - free) / free) * 100; -// // jsData["hardDiskUse"] = boost::lexical_cast(strrateHardUse.substr(0,strrateHardUse.length() - 1)); +// // jsData["hardDiskUse"] = atof(strrateHardUse.substr(0,strrateHardUse.length() - 1)); // jsData["hardDiskUse"] = use; // jsData["cpuSystemUse"] = rateSys; // jsData["temperature"] = temperature; @@ -566,7 +1248,40 @@ bool IsValidMask(std::string mask) { // return 0; // } +double GetHardDiskFree() +{ + char hardName[32]; + char hardTotal[32]; + char hardUse[32]; + char hardFree[32]; + char rateHardUse[32]; + const char * getEmmcInfo = "df -h | grep /opt"; + char chRes[100]; + memset(chRes, 0, 100); + system_custom(getEmmcInfo, chRes); + sscanf(chRes,"%s%s%s%s%s",hardName, hardTotal, hardUse, hardFree, rateHardUse); + std::string strhardTotal(hardTotal); + std::string strhardFree(hardFree); + std::string strrateHardUse(rateHardUse); + double freeDisk = atof(strhardFree.substr(0,strhardFree.length() - 1).c_str()); + return freeDisk; +} +int getSysIntValue(char *key) +{ + FILE *fp = NULL; + int value = 0; + if(key == NULL)return 0; + fp = fopen(key, "r"); + if (fp == NULL) { + printf("Error: could not open %s file\n",key); + return 1; + } + + fscanf(fp, "%d", &value); + fclose(fp);fp = NULL; + return value; +} std::string GetSysStatus() { long mem_used = -1; @@ -618,13 +1333,24 @@ std::string GetSysStatus() const char * getEmmcInfo = "df -h | grep /opt"; char chRes[100]; memset(chRes, 0, 100); +#ifdef IMX6UL_GATEWAY system_custom(getEmmcInfo, chRes); sscanf(chRes,"%s%s%s%s%s",hardName, hardTotal, hardUse, hardFree, rateHardUse); +#endif +#ifdef G2UL_GATEWAY + getDiskInfo(hardTotal,hardFree); +#endif + std::string strhardTotal(hardTotal); std::string strhardFree(hardFree); std::string strrateHardUse(rateHardUse); - + char key[128] = {0}; + memset(key,0,sizeof(key)); + sprintf(key,"/sys/class/thermal/thermal_zone0/temp"); + int temp = getSysIntValue(key); + + print_info("rateUser = %f,mem_total = %d,mem_free = %d,fMemRate = %f\n",rateUser,mem_total,mem_free,fMemRate); Json::Value jsData; Json::FastWriter fw; jsData["dataNodeGatewayNo"] = GlobalConfig::MacAddr_G; @@ -632,13 +1358,15 @@ std::string GetSysStatus() jsData["memoryTotal"] = (int)mem_total; jsData["memoryFree"] = (int)mem_free; jsData["memoryUse"] = fMemRate * 100; - jsData["hardDiskTotal"] = boost::lexical_cast(strhardTotal.substr(0,strhardTotal.length() - 1)); - jsData["hardDiskFree"] = boost::lexical_cast(strhardFree.substr(0,strhardFree.length() - 1)); + jsData["hardDiskTotal"] = atof(strhardTotal.substr(0,strhardTotal.length() - 1).c_str()); + jsData["hardDiskFree"] = atof(strhardFree.substr(0,strhardFree.length() - 1).c_str()); + jsData["temperature"] = temp/1000.0; + jsData["temperatureNR5G"] = atoi(GlobalConfig::NR5GTemp.c_str()); - double total = boost::lexical_cast(strhardTotal.substr(0,strhardTotal.length() - 1)); - double free = boost::lexical_cast(strhardFree.substr(0,strhardFree.length() - 1)); + double total = atof(strhardTotal.substr(0,strhardTotal.length() - 1).c_str()); + double free = atof(strhardFree.substr(0,strhardFree.length() - 1).c_str()); double use = ((total - free) / total) * 100; - // jsData["hardDiskUse"] = boost::lexical_cast(strrateHardUse.substr(0,strrateHardUse.length() - 1)); + // jsData["hardDiskUse"] = atof(strrateHardUse.substr(0,strrateHardUse.length() - 1)); jsData["hardDiskUse"] = use; jsData["cpuSystemUse"] = rateSys; @@ -650,6 +1378,48 @@ std::string GetSysStatus() return strJson; } + +unsigned char ch2hex(char ch) +{ + static const char *hex="0123456789ABCDEF"; + for(unsigned char i=0;i!=16;++i) + if(ch==hex[i]) + return i; + return 0; +} +string tohex(const string& str) +{ + string ret; + static const char *hex="0123456789ABCDEF"; + for(int i=0;i!=str.size();++i) + { + ret.push_back(hex[(str[i]>>4)&0xf]); + ret.push_back( hex[str[i]&0xf]); + } + return ret; +} +char* solve(char *dest,const char *src) +{ + int i=0; + int cnt=0; + unsigned char*d=(unsigned char*)dest; + while(*src) + { + if(i&1) + { + d[cnt++]|=ch2hex(*src); + } + else + { + d[cnt]=ch2hex(*src)<<4; + } + src++; + i++; + } + return dest; +} + + void swap(char *data) { int tmp; @@ -657,6 +1427,928 @@ void swap(char *data) data[1] = data[0]; data[0] = tmp; } +int OpenWatchDog() +{ + int fd = -1; + InitGpio(GlobalConfig::GPIO_G.hardWatchDog,1); + gpio_set(GlobalConfig::GPIO_G.hardWatchDog,1);//高电平有效 + if(0 >(fd = open("/dev/watchdog",O_WRONLY))){ + print_info("Failed:Open /dev/watchdog"); + } + return fd; + +} +int WriteWatchDog(int fd) +{ + if(1 != write(fd,"0",1)){ + print_info("Failed:feeding watchdog"); + } +} +int CloseWatchDog(int fd) +{ + close(fd); +} +string TrimStringLeft(const char* szData, const char* szTargets) +{ + string strData = szData; + int nPos = 0; + nPos = strData.find(szTargets); + while (nPos == 0) + { + strData.erase(nPos, 1); + nPos = strData.find(szTargets); + } + return strData; +} + +string TrimStringRight(const char* szData, const char* szTargets) +{ + string strData = szData; + int nPos = 0; + nPos = strData.rfind(szTargets); + while ((nPos == (int)(strData.size() - 1)) && (nPos >= 0)) + { + strData.erase(nPos, 1); + nPos = strData.rfind(szTargets); + } + return strData; +} +string GetOneContent(const char* szData, int nRow, const char* szSeparate) +{ + string strParam = ""; + string strTemp = szData; + int nFirstPos = -1; + for (int i = 0; i < nRow; i++) + { + nFirstPos = strTemp.find(szSeparate, nFirstPos + 1); + if (nFirstPos < 0) + return strParam.c_str(); + } + + int nSecondPos = strTemp.find(szSeparate, nFirstPos + 1); + if (nSecondPos < 0) + { + strParam = strTemp.substr(nFirstPos + 1); + } + else + { + strParam = strTemp.substr(nFirstPos + 1, nSecondPos - nFirstPos - 1); + } + + { + strParam = TrimStringRight(strParam.c_str(), " "); + strParam = TrimStringLeft(strParam.c_str(), " "); + } + return strParam.c_str(); +} +int set_opt(int fd,int nSpeed, int nBits, char nEvent, int nStop) +{ + struct termios newtio,oldtio; + if ( tcgetattr( fd,&oldtio) != 0) { //检测串口是否可用 + perror("SetupSerial 1"); + return -1; + } + bzero( &newtio, sizeof( newtio ) ); + newtio.c_cflag |= CLOCAL | CREAD; + newtio.c_cflag &= ~CSIZE; + + switch( nBits ) //设置数据位 + { + case 7: + newtio.c_cflag |= CS7; + break; + case 8: + newtio.c_cflag |= CS8; + break; + } + + switch( nEvent )//设置检验位 + { + case 'O': + newtio.c_cflag |= PARENB; + newtio.c_cflag |= PARODD; + newtio.c_iflag |= (INPCK | ISTRIP); + break; + case 'E': + newtio.c_iflag |= (INPCK | ISTRIP); + newtio.c_cflag |= PARENB; + newtio.c_cflag &= ~PARODD; + break; + case 'N': + newtio.c_cflag &= ~PARENB; + break; + } + + switch( nSpeed ) //设置波特率 + { + case 2400: + cfsetispeed(&newtio, B2400); + cfsetospeed(&newtio, B2400); + break; + case 4800: + cfsetispeed(&newtio, B4800); + cfsetospeed(&newtio, B4800); + break; + case 9600: + cfsetispeed(&newtio, B9600); + cfsetospeed(&newtio, B9600); + break; + case 115200: + cfsetispeed(&newtio, B115200); + cfsetospeed(&newtio, B115200); + break; + case 460800: + cfsetispeed(&newtio, B460800); + cfsetospeed(&newtio, B460800); + break; + default: + cfsetispeed(&newtio, B9600); + cfsetospeed(&newtio, B9600); + break; + } + if( nStop == 1 )//设置停止位 + newtio.c_cflag &= ~CSTOPB; + else if ( nStop == 2 ) + newtio.c_cflag |= CSTOPB; + newtio.c_cc[VTIME] = 0; + newtio.c_cc[VMIN] = 0; + tcflush(fd,TCIFLUSH); + if((tcsetattr(fd,TCSANOW,&newtio))!=0) //设置串口参数 + { + perror("com set error"); + return -1; + } + return 0; +} + +int getcsq() +{ + /*int fd = config_uart("/dev/ttyUSB2",115200); + print_info("fd = %d\n",fd); + if(fd < 0){ + printf("config_uart error\n"); + } + int len = write_data(fd,"AT+QENG=\"servingcell\"\r\n",27); + + sleep(1); + unsigned char rbuf[128]={0x00}; + len = read_data(fd,(char*)rbuf,100,10); + if(len < 0) { + print_info("Can't get /dev/ttyUSBx Serial Port data!\n"); + } + print_info("rbuf = %s\n",(char*)rbuf); + close(fd);*/ + + int ret = 0; + char csq[128] = {0}; + + int fd = 0, sig = 0; + + if((fd = open("/dev/ttyUSB2", O_RDWR | O_NOCTTY | O_NDELAY))<0){ + + //LOG_ERROR("open %s is FAILED\n\n","/dev/ttyUSB2"); + } + else{ + set_opt(fd, 9600, 8, 'N', 1); + } + set_opt(fd, 115200, 8, 'N', 1); + + //write(fd,"AT+QENG=\"servingcell\"\r\n",27);//开启定位 + write(fd,"AT+CSQ",6); + sleep(1); + unsigned char rbuf[128]={0x00}; + int len = read(fd, rbuf, sizeof(rbuf)); // 在串口读入字符串 + + print_info("rbuf = %s,len = %d\n",rbuf,len); + sleep(1); + if(len < 0) { + print_info("Can't get /dev/ttyUSBx Serial Port data!\n"); + } + + const char *str2 = "+QENG: "; + char *pdata = strstr((char*)rbuf, str2); + if(pdata) + strncpy(csq, pdata+7, sizeof(csq)); + else { + return -1; + } + //printf("SIM-CSQ: %s\n", csq); + GlobalConfig::NetStatus = GetOneContent(csq,1,","); + string signal = GetOneContent(csq,13,","); + GlobalConfig::NetSignal = atoi(signal.c_str()); + print_info("NetStatus = %s,NetSignal = %d\n",GlobalConfig::NetStatus.c_str(),GlobalConfig::NetSignal); + // ret = csq + close(fd); + /*if(csq[0] == ',') + ret = 0; + else if(csq[1] == ',') + ret = (int)csq[0] - '0'; + else if(csq[2] == ',') + ret = ((int)csq[0] - '0')*10 + (int)csq[1] - '0'; + + print_info("sig = %d\n", ret);*/ + return atoi(signal.c_str()); + +/* + int level; + char *str = NULL; + if (strstr(csq, "99,") || strstr(csq, "199,") ){ + printf("No signal ..\n"); + level = 0; + } + else { + char rssi_str[4]; + int rssi; + memset(rssi_str, 0, sizeof(rssi_str)); + if (*(csq+2) == ',') { + rssi_str[0] = *(csq+0+0); + rssi_str[1] = *(csq+0+1); + } + else if (isdigit(*(csq+2)) && isdigit(*(csq+3) == ',')) { + rssi_str[0] = *(csq+0+0); + rssi_str[1] = *(csq+0+1); + rssi_str[2] = *(csq+0+2); + } + rssi = atoi(rssi_str); + +printf("rssi = %d\n", rssi); + + int signal = -113 + (2 * rssi); + if(signal > -91) + level = 5; + else if (signal <= -91 && signal > -101) + level = 4; + else if(signal <= -101 && signal > -103) + level = 3; + else if(signal <= -103 && signal > -107) + level = 2; + else if(signal <= -107 && signal > -113) + level = 1; + else + level = 0; + printf("level = %d, signal: %d\n", rssi, signal); + } +*/ + +} +void IniReadValue(char* section, char* key, char* val, const char* file) +{ + FILE* fp; + int i = 0; + int lineContentLen = 0; + int position = 0; + char lineContent[LINE_CONTENT_MAX_LEN]; + bool bFoundSection = false; + bool bFoundKey = false; + fp = fopen(file, "r"); + if(fp == NULL) + { + printf("%s: Opent file %s failed.\n", __FILE__, file); + return; + } + while(feof(fp) == 0) + { + memset(lineContent, 0, LINE_CONTENT_MAX_LEN); + fgets(lineContent, LINE_CONTENT_MAX_LEN, fp); + if((lineContent[0] == ';') || (lineContent[0] == '\0') || (lineContent[0] == '\r') || (lineContent[0] == '\n')) + { + continue; + } + + //check section + if(strncmp(lineContent, section, strlen(section)) == 0) + { + bFoundSection = true; + //printf("Found section = %s\n", lineContent); + while(feof(fp) == 0) + { + memset(lineContent, 0, LINE_CONTENT_MAX_LEN); + fgets(lineContent, LINE_CONTENT_MAX_LEN, fp); + //check key + if(strncmp(lineContent, key, strlen(key)) == 0) + { + bFoundKey = true; + lineContentLen = strlen(lineContent); + //find value + for(i = strlen(key); i < lineContentLen; i++) + { + if(lineContent[i] == '=') + { + position = i + 1; + break; + } + } + if(i >= lineContentLen) break; + strncpy(val, lineContent + position, strlen(lineContent + position)); + lineContentLen = strlen(val); + for(i = 0; i < lineContentLen; i++) + { + if((lineContent[i] == '\0') || (lineContent[i] == '\r') || (lineContent[i] == '\n')) + { + val[i] = '\0'; + break; + } + } + } + else if(lineContent[0] == '[') + { + break; + } + } + break; + } + } + if(!bFoundSection){printf("No section = %s\n", section);} + else if(!bFoundKey){printf("No key = %s\n", key);} + fclose(fp); +} + +int readStringValue(const char* section, char* key, char* val, const char* file) +{ + char sect[SECTION_MAX_LEN]; + //printf("section = %s, key = %s, file = %s\n", section, key, file); + if (section == NULL || key == NULL || val == NULL || file == NULL) + { + printf("%s: input parameter(s) is NULL!\n", __func__); + return -1; + } + + memset(sect, 0, SECTION_MAX_LEN); + sprintf(sect, "[%s]", section); + //printf("reading value...\n"); + IniReadValue(sect, key, val, file); + + return 0; +} + +int readIntValue(const char* section, char* key, const char* file) +{ + char strValue[STRVALUE_MAX_LEN]; + memset(strValue, '\0', STRVALUE_MAX_LEN); + if(readStringValue(section, key, strValue, file) != 0) + { + printf("%s: error", __func__); + return 0; + } + return(atoi(strValue)); +} + +void IniWriteValue(const char* section, char* key, char* val, const char* file) +{ + FILE* fp; + int i = 0, n = 0, err = 0; + int lineContentLen = 0; + int position = 0; + char lineContent[LINE_CONTENT_MAX_LEN]; + char strWrite[LINE_CONTENT_MAX_LEN]; + bool bFoundSection = false; + bool bFoundKey = false; + + memset(lineContent, '\0', LINE_CONTENT_MAX_LEN); + memset(strWrite, '\0', LINE_CONTENT_MAX_LEN); + n = sprintf(strWrite, "%s=%s\n", key, val); + fp = fopen(file, "r+"); + if(fp == NULL) + { + printf("%s: Opent file %s failed.\n", __FILE__, file); + return; + } + while(feof(fp) == 0) + { + memset(lineContent, 0, LINE_CONTENT_MAX_LEN); + fgets(lineContent, LINE_CONTENT_MAX_LEN, fp); + if((lineContent[0] == ';') || (lineContent[0] == '\0') || (lineContent[0] == '\r') || (lineContent[0] == '\n')) + { + continue; + } + //check section + if(strncmp(lineContent, section, strlen(section)) == 0) + { + bFoundSection = true; + while(feof(fp) == 0) + { + memset(lineContent, 0, LINE_CONTENT_MAX_LEN); + fgets(lineContent, LINE_CONTENT_MAX_LEN, fp); + //check key + if(strncmp(lineContent, key, strlen(key)) == 0) + { + bFoundKey = true; + printf("%s: %s=%s\n", __func__, key, val); + fseek(fp, (0-strlen(lineContent)),SEEK_CUR); + err = fputs(strWrite, fp); + if(err < 0){printf("%s err.\n", __func__);} + break; + } + else if(lineContent[0] == '[') + { + break; + } + } + break; + } + } + if(!bFoundSection){printf("No section = %s\n", section);} + else if(!bFoundKey){printf("No key = %s\n", key);} + fclose(fp); +} + +int writeStringVlaue(const char* section, char* key, char* val, const char* file) +{ + char sect[SECTION_MAX_LEN]; + //printf("section = %s, key = %s, file = %s\n", section, key, file); + if (section == NULL || key == NULL || val == NULL || file == NULL) + { + printf("%s: input parameter(s) is NULL!\n", __func__); + return -1; + } + memset(sect, '\0', SECTION_MAX_LEN); + sprintf(sect, "[%s]", section); + IniWriteValue(sect, key, val, file); +} + +int writeIntValue(const char* section, char* key, int val, const char* file) +{ + char strValue[STRVALUE_MAX_LEN]; + memset(strValue, '\0', STRVALUE_MAX_LEN); + sprintf(strValue, "%-4d", val); + + writeStringVlaue(section, key, strValue, file); +} + +int getDiskInfo(char* diskTotal,char* diskFree) +{ + DISK diskInfo; +// pDISK pDiskInfo; +// char dpath[100]="/";//设置默认位置 +// int flag=0; +// if(NULL!=path) +// { +// strcpy(dpath,path); +// } +// if(-1==(flag=statfs("/tmp",pDiskInfo)))//获取包含磁盘空间信息的结构体 +// { +// perror("getDiskInfo statfs fail"); +// return 0; +// } +// unsigned long long total=0,avail=0,free=0,blockSize=0; +// +// blockSize=pDiskInfo->f_bsize;//每块包含字节大小 +// total=pDiskInfo->f_blocks*blockSize;//磁盘总空间 +// avail=pDiskInfo->f_bavail*blockSize;//非超级用户可用空间 +// free=pDiskInfo->f_bfree*blockSize;//磁盘所有剩余空间 +// //字符串转换 +// char diskTotal[30],diskAvail[30],diskFree[30]; +// flag=sprintf(diskTotal,"%llu",total>>20); +// flag=sprintf(diskAvail,"%llu",avail>>20); +// flag=sprintf(diskFree,"%llu",free>>20); +// print_info("diskTotal = %s,diskAvail = %s,diskFree = %s\n",diskTotal,diskAvail,diskFree); +// if(-1==flag) +// { +// return 0; +// } + /* 1.获取/home/下面的总容量 */ + statfs("/", &diskInfo); + unsigned long long blocksize = diskInfo.f_bsize; //每个block里包含的字节数 + unsigned long long totalsize = blocksize * diskInfo.f_blocks;//总的字节数,f_blocks为block的数目 + //printf("Total_size=%llu B =%llu KB =%llu MB = %llu GB\n",\ + totalsize,totalsize>>10,totalsize>>20, totalsize>>30); + + /* 2.获取一下剩余空间和可用空间的大小 */ + unsigned long long freeDisk = diskInfo.f_bfree * blocksize; //剩余空间的大小 + unsigned long long availableDisk = diskInfo.f_bavail * blocksize; //可用空间大小 + //printf("Disk_free=%llu MB =%llu GB Disk_available=%llu MB = %llu GB\n",\ + freeDisk>>20,freeDisk>>30,availableDisk>>20, availableDisk>>30); + sprintf(diskTotal,"%llu",totalsize>>20); + sprintf(diskFree,"%llu",freeDisk>>20); + return 1; +} +bool NetIsOk() +{ + + double rtt; + struct hostent *host; + struct protoent *protocol; + int i,recv_status; + +#ifdef _USE_DNS //如果定义该宏,则可以使用域名进行判断网络连接,例如www.baidu.com + /* 设置目的地址信息 */ + char hostname[32]; + sprintf(hostname,"%s","www.baidu.com") + bzero(&dest_addr, sizeof(dest_addr)); + dest_addr.sin_family = AF_INET; + + if((host=gethostbyname(hostname))==NULL) + { + LOG_ERROR("[NetStatus] error : Can't get serverhost info!\n"); + return false; + } + + bcopy((char*)host->h_addr,(char*)&dest_addr.sin_addr,host->h_length); +#else //如果不使用域名,则只能用ip地址直接发送icmp包, + dest_addr.sin_addr.s_addr = inet_addr(GlobalConfig::ServerIP.c_str()); +#endif + + + if ((sockfd = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)) < 0) + { /* 创建原始ICMP套接字 */ + LOG_ERROR("[NetStatus] error : socket %d\n",sockfd); + return false; + } + + int iFlag; + if(iFlag = fcntl(sockfd,F_GETFL,0)<0) + { + LOG_ERROR("[NetStatus] error : fcntl(sockfd,F_GETFL,0)"); + _CloseSocket(); + return false; + } + iFlag |= O_NONBLOCK; + if(iFlag = fcntl(sockfd,F_SETFL,iFlag)<0) + { + LOG_ERROR("[NetStatus] error : fcntl(sockfd,F_SETFL,iFlag )"); + _CloseSocket(); + return false; + } + print_info("================NetIsOk check=============\n"); + pid=getpid(); + for(i=0;i0) + { + _CloseSocket(); + return true; + } + + } + _CloseSocket(); + return false; +} + + + +int send_packet(int pkt_no,char *sendpacket) +{ + int packetsize; + packetsize=pack(pkt_no,sendpacket); + gettimeofday(&tvsend,NULL); + print_info("================NetIsOk send_packet=============\n"); + if(sendto(sockfd,sendpacket,packetsize,0,(struct sockaddr *)&dest_addr,sizeof(dest_addr) )<0) + { + LOG_ERROR("[NetStatus] error : sendto error"); + return -1; + } + return 1; +} + + +int pack(int pkt_no,char*sendpacket) +{ + int i,packsize; + struct icmp *icmp; + struct timeval *tval; + icmp=(struct icmp*)sendpacket; + icmp->icmp_type=ICMP_ECHO; //设置类型为ICMP请求报文 + icmp->icmp_code=0; + icmp->icmp_cksum=0; + icmp->icmp_seq=pkt_no; + icmp->icmp_id=pid; //设置当前进程ID为ICMP标示符 + packsize=ICMP_HEADSIZE+sizeof(struct timeval); + tval= (struct timeval *)icmp->icmp_data; + gettimeofday(tval,NULL); + icmp->icmp_cksum=cal_chksum( (unsigned short *)icmp,packsize); + return packsize; +} + + +unsigned short cal_chksum(unsigned short *addr,int len) +{ + int nleft=len; + int sum=0; + unsigned short *w=addr; + unsigned short answer=0; + while(nleft>1) //把ICMP报头二进制数据以2字节为单位累加起来 + { + sum+=*w++; + nleft-=2; + } + if( nleft==1) //若ICMP报头为奇数个字节,会剩下最后一字节.把最后一个字节视为一个2字节数据的高字节,这个2字节数据的低字节为0,继续累加 + { + *(unsigned char *)(&answer)=*(unsigned char *)w; + sum+=answer; + } + sum=(sum>>16)+(sum&0xffff); + sum+=(sum>>16); + answer=~sum; + return answer; +} + + +int recv_packet(int pkt_no,char *recvpacket) +{ + int n; + fd_set rfds; + FD_ZERO(&rfds); + FD_SET(sockfd,&rfds); + signal(SIGALRM,timeout); + unsigned int fromlen=sizeof(recv_addr); + alarm(MAX_WAIT_TIME); + print_info("================NetIsOk recv_packet=============\n"); + while(1) + { + select(sockfd+1, &rfds, NULL, NULL, NULL); + if (FD_ISSET(sockfd,&rfds)) + { + if( (n=recvfrom(sockfd,recvpacket,PACKET_SIZE,0,(struct sockaddr *)&recv_addr,&fromlen)) <0) + { + print_info("================NetIsOk recvfrom=============errno = %d\n",errno); + if(errno==EINTR){ + return -1; + LOG_ERROR("recvfrom error"); + return -2; + } + } + } + gettimeofday(&tvrecv,NULL); + if(unpack(pkt_no,recvpacket,n)==-1) + continue; + return 1; + } +} + +int unpack(int cur_seq,char *buf,int len) +{ + int iphdrlen; + struct ip *ip; + struct icmp *icmp; + ip=(struct ip *)buf; + iphdrlen=ip->ip_hl<<2; //求ip报头长度,即ip报头的长度标志乘4 + icmp=(struct icmp *)(buf+iphdrlen); //越过ip报头,指向ICMP报头 + len-=iphdrlen; //ICMP报头及ICMP数据报的总长度 + if( len<8) + return -1; + if( (icmp->icmp_type==ICMP_ECHOREPLY) && (icmp->icmp_id==pid) && (icmp->icmp_seq==cur_seq)) + return 0; + else return -1; +} + + +void timeout(int signo) +{ + LOG_ERROR("Request Timed Out\n"); + _CloseSocket(); +} + +void tv_sub(struct timeval *out,struct timeval *in) +{ + if( (out->tv_usec-=in->tv_usec)<0) + { + --out->tv_sec; + out->tv_usec+=1000000; + } + out->tv_sec-=in->tv_sec; +} + +void _CloseSocket() +{ + close(sockfd); + sockfd = 0; +} + +int socketHeart(const char* pSendData) +{ + print_info("socketHeart\n"); + int sockfd; // Socket文件描述符 + struct sockaddr_in serverAddr{}; // Server地址结构体 + + // 创建Socket + if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) { + std::cerr << "Failed to create socket." << std::endl; + return 1; + } + + // 设置Server地址信息 + serverAddr.sin_family = AF_INET; + serverAddr.sin_port = htons(18393); // TCP默认端口号为80 + inet_pton(AF_INET, /*GlobalConfig::ServerIP.c_str()*/"192.168.1.147", &serverAddr.sin_addr); + + // 连接到Server + if (connect(sockfd, reinterpret_cast(&serverAddr), sizeof(serverAddr)) == -1) { + std::cerr << "Failed to connect to the server." << std::endl; + close(sockfd); + return 1; + } + + // 发送心跳数据包 + const char heartbeat[] = "Heartbeat"; + ssize_t bytesSent = send(sockfd, pSendData, strlen(pSendData), MSG_NOSIGNAL); + if (bytesSent == -1) { + std::cerr << "Failed to send heartbeat packet." << std::endl; + close(sockfd); + return 1; + } else if (static_cast(bytesSent) != strlen(pSendData)) { + std::cerr << "Partially sent heartbeat packet." << std::endl; + close(sockfd); + return 1; + } + + // 关闭Socket连接 + close(sockfd); + + return 0; +} +//unsigned short cal_chksum(unsigned short *addr, int len) +//{ +// int nleft=len; +// int sum=0; +// unsigned short *w=addr; +// unsigned short answer=0; +// +// while(nleft > 1) +// { +// sum += *w++; +// nleft -= 2; +// } +// +// if( nleft == 1) +// { +// *(unsigned char *)(&answer) = *(unsigned char *)w; +// sum += answer; +// } +// +// sum = (sum >> 16) + (sum & 0xffff); +// sum += (sum >> 16); +// answer = ~sum; +// +// return answer; +//} + +// Ping函数,timeout为超时时间,单位是ms,10000 毫秒=10 秒 +//成功:返回0,失败:返回1或-1 +int Ping( const char *ips, int timeout) +{ + struct timeval *tval; + int maxfds = 0; + fd_set readfds; + + int iRet = 0; + struct sockaddr_in addr; + struct sockaddr_in from; + // 设定Ip信息 + bzero(&addr,sizeof(addr)); + addr.sin_family = AF_INET; + + addr.sin_addr.s_addr = inet_addr(ips); + + int sockfd; + // 取得socket 。 如果没加sudo 这里会报错 + sockfd = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP); + if (sockfd < 0) + { + print_error("ip:%s,socket error\n",ips); + return -1; + } + + struct timeval timeo; + // 设定TimeOut时间 + timeo.tv_sec = timeout / 1000; + timeo.tv_usec = timeout % 1000; + + if (setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, &timeo, sizeof(timeo)) == -1) + { + print_error("ip:%s,setsockopt error\n",ips); + close(sockfd); + return -1; + } + + char sendpacket[2048]; + char recvpacket[2048]; + // 设定Ping包 + memset(sendpacket, 0, sizeof(sendpacket)); + + pid_t pid; + // 取得PID,作为Ping的Sequence ID + pid=getpid(); + + struct ip *iph; + struct icmp *icmp; + + + icmp=(struct icmp*)sendpacket; + icmp->icmp_type=ICMP_ECHO; //回显请求 + icmp->icmp_code=0; + icmp->icmp_cksum=0; + icmp->icmp_seq=0; + icmp->icmp_id=pid; + tval= (struct timeval *)icmp->icmp_data; + gettimeofday(tval,NULL); + icmp->icmp_cksum=cal_chksum((unsigned short *)icmp,sizeof(struct icmp)); //校验 + + int n = sendto(sockfd, (char *)&sendpacket, sizeof(struct icmp), 0, (struct sockaddr *)&addr, sizeof(addr)); + if (n < 1) + { + print_error("ip:%s,sendto error\n",ips); + close(sockfd); + return -1; + } + + // 接受 + // 由于可能接受到其他Ping的应答消息,所以这里要用循环 + int cnt=0; + while(1) + { + // 设定TimeOut时间,这次才是真正起作用的 + FD_ZERO(&readfds); + FD_SET(sockfd, &readfds); + maxfds = sockfd + 1; + n = select(maxfds, &readfds, NULL, NULL, &timeo); + if (n <= 0) + { + print_info("ip:%s,Time out error\n",ips); + close(sockfd); + iRet = -1; + break; + } + + // 接受 + memset(recvpacket, 0, sizeof(recvpacket)); + int fromlen = sizeof(from); + n = recvfrom(sockfd, recvpacket, sizeof(recvpacket), 0, (struct sockaddr *)&from, (socklen_t *)&fromlen); + print_info("recvfrom Len:%d\n",n); + if (n < 1) + { + close(sockfd); + iRet = 1; + break; + } + + char *from_ip = (char *)inet_ntoa(from.sin_addr); + // 判断是否是自己Ping的回复 + if (strcmp(from_ip,ips) != 0) + { + print_info("NowPingip:%s Fromip:%s NowPingip is not same to Fromip,so ping wrong!\n",ips,from_ip); + close(sockfd); + iRet = 1; + break; + + } + + iph = (struct ip *)recvpacket; + + icmp=(struct icmp *)(recvpacket + (iph->ip_hl<<2)); + + print_info("ip:%s,icmp->icmp_type:%d,icmp->icmp_id:%d\n",ips,icmp->icmp_type,icmp->icmp_id); + // 判断Ping回复包的状态 + if (icmp->icmp_type == ICMP_ECHOREPLY && icmp->icmp_id == pid) //ICMP_ECHOREPLY回显应答 + { + // 正常就退出循环 + print_info("icmp succecss ............. \n"); + break; + } + else if(cnt<3) + { + // 否则继续等 + cnt++; + continue; + } + else + { + close(sockfd); + iRet = -1; + break; + } + } + close(sockfd); + return iRet; +} +int get_netlink_status(const char *if_name) +{ + int skfd; + struct ifreq ifr; + struct ethtool_value edata; + edata.cmd = ETHTOOL_GLINK; + edata.data = 0; + memset(&ifr, 0, sizeof(ifr)); + strncpy(ifr.ifr_name, if_name, sizeof(ifr.ifr_name) - 1); + ifr.ifr_data = (char *)&edata; + if ((skfd = socket(AF_INET, SOCK_DGRAM, 0)) == 0) + return -1; + if (ioctl(skfd, SIOCETHTOOL, &ifr) == -1) + { + close(skfd); + return -1; + } + close(skfd); + return edata.data; +} + static const char* JSON_FIELD_CMD = "cmd";//协议: 命令字段 static const char* JSON_FIELD_NAME = "dataWatchName";//协议: 终端名称 diff --git a/common/SH_CommonFunc.hpp b/common/SH_CommonFunc.hpp index 12bb465..b3bb258 100644 --- a/common/SH_CommonFunc.hpp +++ b/common/SH_CommonFunc.hpp @@ -26,10 +26,19 @@ #include //ipc #include #include "dirent.h" +#include +#include +#include +#include +#include +#include +#include "Mutex.h" +typedef struct statfs DISK,*pDISK; - - +#define SECTION_MAX_LEN 256 +#define STRVALUE_MAX_LEN 256 +#define LINE_CONTENT_MAX_LEN 256 //配置文件位置 #define NETWORK "/etc/network/interfaces" #define SYSTEMINFOFILE "/opt/configenv/SystemInfo.json" //系统信息 @@ -43,6 +52,7 @@ #define SN "/opt/system/sn" //设备序列号 #define SYSTEMSTART "/opt/system/start" //系统启动类型标志 0:正常启动 1:重启 2: #define BUILD_UINT16(x,y) (((x & 0x00FFu) << 8u) | (y & 0x00FFu)) +#define BUILD_UINT2(x,y) (((x) << 2u) | (y)) // 生成UINT32 数据 #define BUILD_UINT32(u,v,x,y) (((u & 0x00FFu) << 24u) | (v & 0x00FFu) << 16u) | (((x & 0x00FFu) << 8u) | (y & 0x00FFu)) // 获取UINT32的高低字节 @@ -50,16 +60,18 @@ #define UINT32_HIGH_2(x) ((x & 0x00FF0000u) >> 16u) #define UINT32_LOW_1(x) ((x & 0x0000FF00u) >> 8u) #define UINT32_LOW_2(x) ((x & 0x000000FFu)) - +#define GET_BIT(x, bit) ((x & (1 << bit)) >> bit) /* 获取第bit位 */ // 获取UINT32的高低字节 #define UINT16_HIGH(x) ((x & 0xFF00u) >> 8u) #define UINT16_LOW(x) ((x & 0x00FFu)) -#define onlineCheck 21600 #define GENERAL_BUF_SIZE 128*1024*10 using namespace std; + + + enum TIME_SIZE{ TIME_MINUTE=5, TIME_SECEOND=8 @@ -108,6 +120,8 @@ struct ZigbeeInfo { std::string PanID; std::string MyAddr; std::string DstAddr; + std::string RetryNum; + std::string TranTimeout; }; struct ZIGBEE { @@ -183,7 +197,9 @@ struct DataNodeInfo { std::string ConfigDate;//配置时间 int VIntegralFilterFrequency;//速度积分滤波频率 - + DataNodeInfo(){ + FeatureInterVal = 0;WaveInterVal = 0; + } }; @@ -205,6 +221,7 @@ struct DataRecvDym { float Amp3; float Amp4; float Amp5; + long Time; float Phase1; float Phase2; float Phase3; @@ -221,6 +238,7 @@ struct TopicList{ std::string mPubWaveSecondData; //原始数据发布主题 std::string mPubCmd; //命令控制发布主题 std::string mPubRep; + std::string mPubTiming; //校时 std::string mPubLocalWifi; std::string mPubLocalWaveServer; @@ -263,6 +281,25 @@ typedef struct { } WAVE_GENERAL; +typedef struct{ + int zigAckrep; + int zigAckreset; + int zigReset; + int zigDef; + int alarmLight; + int commPower;//4G,5G 电源开关 + int vol3_8;//5G 3.8v电源 + int commRest;//4G,5G复位 + int wifiPower;//WiFi 电源开关 + int wifiReset;//WiFi 复位 + int hardWatchDog; + int power; + int runLed; + int errorLed; + int netResetNet0; + int netResetNet1; +} GPIOInfo; + struct Param_01 { int mMode; //0:登陆 1:更改密码 std::string mUserName; @@ -302,7 +339,10 @@ struct Param_23 { std::string mServerIp; std::string mPort; std::string mCommMode; // 通信模式,有线通信模式 = 1;4G LTE 无线通信模式 = 2 - Param_23():mMode(0),mCmdSerial(""), mServerIp(""),mPort(""),mCommMode(""){}; + std::string mUserName; + std::string mPassword; + std::string mAPN; + Param_23():mMode(0),mCmdSerial(""), mServerIp(""),mPort(""),mCommMode(""),mUserName("chaos"),mPassword("HSD272*#xkd"),mAPN(""){}; }; @@ -317,6 +357,7 @@ struct Param_24 { struct Param_25 { int mMode; + std::string mNet; std::string mCmdSerial; std::string mDnsName; std::string mNetworkPortStatus; @@ -327,12 +368,29 @@ struct Param_25 { Param_25():mMode(0),mCmdSerial(""), mDnsName(""),mGateway(""),mSubnetMask(""),mIp(""),mHostName(""){}; }; - +struct Param_09 { + int mPackageFlag; + Param_09():mPackageFlag(0){}; +}; +struct Param_10 { + std::string strDataNode; + std::string strStatic; + std::string straxis; + std::string timeStart; + std::string timeEnd; + int mPackageFlag; + Param_10():strDataNode(""),strStatic(""),mPackageFlag(0){}; +}; +struct Param_11 { + std::string DataNodeNo; + Param_11():DataNodeNo(""){}; +}; struct Param_26 { int mMode; std::string mCmdSerial; std::string mDataNodeNo; - Param_26():mMode(0),mCmdSerial(""),mDataNodeNo(""){}; + int mPackageFlag; + Param_26():mMode(0),mCmdSerial(""),mDataNodeNo(""),mPackageFlag(0){}; }; @@ -368,6 +426,34 @@ struct Param_30 { int mPackageFlag; Param_30():mMode(0),mChannelId(""),mDataNodeNo(""),mPackageFlag(0){}; }; +struct Param_40 { + int mMode; + std::string mChannelId; + std::string mDataNodeNo; + int mPackageFlag; + int StartFrequency; + int EndFrequency; + Param_40():mMode(0),mChannelId(""),mDataNodeNo(""),mPackageFlag(0),StartFrequency(0),EndFrequency(0){}; +}; +struct Param_41 { + std::string mdataNodeNo; + int mfeatureInterVal; + int mwaveInterVal; + int msamplingRate; + int mrange; + int mAccSampleTime; + std::string mstartBrands; + std::string mstopBrands; + std::string menvelopeBandPass; + int mviff; + std::string mfaultFrequency; + Param_41():mdataNodeNo(""),mfeatureInterVal(0),mwaveInterVal(0),msamplingRate(0),mrange(0),mAccSampleTime(0),\ + mstartBrands(""),mstopBrands(""),menvelopeBandPass(""),mviff(0),mfaultFrequency(""){}; +}; +struct Param_42 { + string fileName; + Param_42():fileName(""){}; +}; struct Param_31 { int mMode; @@ -376,13 +462,13 @@ struct Param_31 { Param_31():mMode(0),mChannelId(""){}; }; + struct Param_32 { - int mMode; - std::string mChannelId; + int mMode; + std::string mChannelId; int mPackageFlag; Param_32():mMode(0),mChannelId(""),mPackageFlag(0){}; }; - struct Param_33 { int mMode; std::string mUnit; @@ -443,11 +529,53 @@ struct Param_47 { std::string mFileName; Param_47():mMode(0),mFileName(""){}; }; +struct Param_51 { + int mMode; + string strGateWayMAC; + string strGateWayLocation; + Param_51():mMode(-1),strGateWayLocation(""){}; +}; +struct Param_52 { + int mMode; + std::string mCmdSerial; + string mSsid; + string mPassWord; +}; +struct Param_53 { + int mMode; + string mdataNodeNo; + string mUpdateKey; + string mUpdateValue; + string mUpdateKey2; + string mUpdateValue2; + string mUpdateKey3; + string mUpdateValue3; + Param_53():mUpdateKey2(""),mUpdateValue2(""),mUpdateKey3(""),mUpdateValue3(""){}; +}; + +typedef struct DataNodeUpdate{ + std::string strUpdataFileName; + std::string strSoftVersion; + std::vector hwVersion; +}; +struct ethtool_value { + unsigned int cmd; + unsigned int data; +}; - - +extern std::string GBKToUTF8(const std::string& strGBK); +extern std::string UTFtoGBK(const char* utf8); +extern string GetLocalTimeWithMs(void); +extern void InitGpio(unsigned int gpioN,unsigned int inout); +extern int gpio_set(unsigned int gpioN,char x); +extern int gpio_read(unsigned int gpioN); +extern int config_uart(const char* Port,speed_t speed); +extern int write_data(int fd, char *buff, int len); +extern int read_data(int fd, char *buff, int len, int timeout); +extern int ModifyMac(char* buff); +//extern int str_recv(int fd, char srcshow,char* buffer); /** * @brief 系统运行时输入入参进行系统软件版本查询 * @param argv 输入参数 -vV版本查询 --debugmode日志调试模式 @@ -477,7 +605,6 @@ extern int system_custom(const char *cmd, char *buf); */ extern void WriteMemoryInfo(); - /** * @brief 获取当前日期 * @return 当前日期的string @@ -497,7 +624,7 @@ extern void GetTime_(char * time_buff,TIME_SIZE len) ; * @return void */ extern void GetTimeNet(char* timebuf, int type); - +extern std::string GetRTC(char* timebuf, int& millisecond); /** * @brief 从配置文件中读取数据 * @param filename 配置文件名 @@ -521,7 +648,7 @@ extern int WriteStr2Config(std::string filename, std::string config, std::string * @brief 获取设备的MAC地址做为设备的唯一标识 * @return std::string Mac地址 */ -extern std::string GetLocalMac(); +extern std::string GetLocalMac(const char* net); /** * @brief 获取设备IP @@ -597,14 +724,45 @@ extern void ZoneConfig(std::string zoneid); * @return std::string CPU MEM DISK info */ extern std::string GetSysStatus(); - +double GetHardDiskFree(); extern bool CheckIP(const char *ip); bool IsValidMask(std::string mask); //read update config file -extern std::vector ReadStrByOpt(std::string filename,std::string& strUpdataFileName); +extern std::vector ReadStrUpdate(std::string filename); +extern void ReadStrConfig(std::string filename); +extern int UpdataDataNodeConfig(std::string filename); +extern char* solve(char *dest,const char *src); extern void swap(char *data); +extern int OpenWatchDog(); +extern int WriteWatchDog(int fd); +extern int CloseWatchDog(int fd); +//获取4G信号强度 +extern int getcsq(); +extern std::string GetGwIp_(const char *eth_name); +extern string GetOneContent(const char* szData, int nRow, const char* szSeparate); +extern int readStringValue(const char* section, char* key, char* val, const char* file); +extern int writeStringVlaue(const char* section, char* key, char* val, const char* file); +extern int readIntValue(const char* section, char* key, const char* file); +extern int writeIntValue(const char* section, char* key, int val, const char* file); +int getDiskInfo(char* diskTotal,char* diskFree); + +void timeout(int signo); +unsigned short cal_chksum(unsigned short *addr,int len); +int pack(int pkt_no,char *sendpacket); +int send_packet(int pkt_no,char *sendpacket); +int recv_packet(int pkt_no,char *recvpacket); +int unpack(int cur_seq,char *buf,int len); +void tv_sub(struct timeval *out,struct timeval *in); +void _CloseSocket(); + +int socketHeart(const char* pSendData); + +extern bool NetIsOk(); +extern int Ping( const char *ips, int timeout); +extern int get_netlink_status(const char *if_name); +extern Mutex g_tDbMutex; #endif diff --git a/common/SH_global.h b/common/SH_global.h index c89673c..ed934cf 100644 --- a/common/SH_global.h +++ b/common/SH_global.h @@ -10,6 +10,8 @@ #include "SH_CommonFunc.hpp" #include "../mqttclient/SH_MqttClient.h" + +#define SECTION_MAX_LEN 1024 //******************** 全局变量********************** enum enumZigBeeTransmitStatus { NO_ENTER_TRANSMITTING_STATUS = 0, @@ -17,6 +19,13 @@ enum enumZigBeeTransmitStatus { }; +//#define NR5G_MODULE +//#define Q4G_MODULE +//#define WIFI_MODULE +//#define NR5G_MEIGE +#define G2UL_GATEWAY +//#define IMX6UL_GATEWAY + class GlobalConfig { public : @@ -24,17 +33,25 @@ public : static int QuitFlag_G; //程序退出标志 static int LinkStatus_G; //和服务器连接状态 static int LinkCount; + static int NetSignal; + static int serverStatus; + static int net0Status; + static std::string NR5GTemp; + static std::string NetStatus; + static std::string NetType; static std::string Version; //软件版本号 static std::string MacAddr_G; //设备MAC地址 + static std::string MacAddr_G2; //设备光纤MAC地址 static std::string IpAddr_G; //设备IP static std::string DbName_G; //数据库名字 + static std::string Config_G; //配置文件 static std::string ServerIP; //服务器地址 static int ServerPort; //服务器端口 static std::string UartName_G; static TopicList Topic_G; //发布的主题 static ZigbeeInfo ZigbeeInfo_G; //gateway zigbee info static ZIGBEE Zigbee_G; - + static GPIOInfo GPIO_G; static enumZigBeeTransmitStatus EnterZigBeeWaveTransmittingFlag_G; // 进入ZigBee网络原始数据传输状态标志 static int EnterZigBeeWaveTransmittingCnt_G; // 进入ZigBee网络原始数据传输状态计数器,以秒为单位进行计数 }; @@ -56,6 +73,17 @@ public : #define LIGHT_GRAY "\033[0;37m" #define WHITE "\033[1;37m" +#ifdef IMX6UL_GATEWAY +#define SAVE_COUNT 2058 //2058,4800 +#define OneWeek 259359//259359,604800 +#endif +#ifdef G2UL_GATEWAY +#define SAVE_COUNT 4800*4 +#define OneWeek 604800*7 +#endif + + + #define perror_info(info) { \ if (GlobalConfig::RUN_MODE) { \ perror(info); \ diff --git a/datatransfer/SH_Datatrans.cpp b/datatransfer/SH_Datatrans.cpp index c032ace..7c44c71 100644 --- a/datatransfer/SH_Datatrans.cpp +++ b/datatransfer/SH_Datatrans.cpp @@ -54,6 +54,7 @@ static size_t OnWriteData(void* buffer, size_t size, size_t nmemb, void* lpVoid) static size_t my_fwrite(void *buffer, size_t size, size_t nmemb, void *stream) { + printf("size = %d\n",size); struct DowloadFile *out=(struct DowloadFile *)stream; if(out && !out->stream) { out->stream=fopen(out->filename, "wb");//打开文件进行写入 @@ -116,6 +117,73 @@ int DataTrans::download(char* pFilename,string& strUrl,string& strResponse,bool curl_global_cleanup(); return 0; } +//下载文件数据接收函数 + +size_t writedata2file(void *ptr, size_t size, size_t nmemb, FILE *stream) { + size_t written = fwrite(ptr, size, nmemb, stream); + return written; +} +//http POST请求文件下载 +int DataTrans::dl_curl_post_req(const string &url, const string &postParams, string& filename) +{ + CURL *curl; + FILE *fp; + CURLcode res; + /* 调用curl_global_init()初始化libcurl */ + res = curl_global_init(CURL_GLOBAL_ALL); + if (CURLE_OK != res) + { + printf("init libcurl failed."); + curl_global_cleanup(); + return -1; + } + /* 调用curl_easy_init()函数得到 easy interface型指针 */ + curl = curl_easy_init(); + if (curl) { + fp = fopen(filename.c_str(),"wb"); + + /* 调用curl_easy_setopt()设置传输选项 */ + res = curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); + if (res != CURLE_OK) + { + fclose(fp); + curl_easy_cleanup(curl); + return -1; + } + /* 根据curl_easy_setopt()设置的传输选项,实现回调函数以完成用户特定任务 */ + res = curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writedata2file); + if (res != CURLE_OK){ + fclose(fp); + curl_easy_cleanup(curl); + return -1; + } + /* 根据curl_easy_setopt()设置的传输选项,实现回调函数以完成用户特定任务 */ + res = curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); + if (res != CURLE_OK) + { + fclose(fp); + curl_easy_cleanup(curl); + return -1; + } + + res = curl_easy_perform(curl); + // 调用curl_easy_perform()函数完成传输任务 + fclose(fp); + /* Check for errors */ + if(res != CURLE_OK){ + fprintf(stderr, "curl_easy_perform() failed: %s\n",curl_easy_strerror(res)); + curl_easy_cleanup(curl); + return -1; + } + + /* always cleanup */ + curl_easy_cleanup(curl); + // 调用curl_easy_cleanup()释放内存 + + } + curl_global_cleanup(); + return 0; +} int DataTrans::Post(const std::string & strUrl, const std::string & strPost, std::string & strResponse) { diff --git a/datatransfer/SH_Datatrans.hpp b/datatransfer/SH_Datatrans.hpp index c7caea6..d2439b5 100644 --- a/datatransfer/SH_Datatrans.hpp +++ b/datatransfer/SH_Datatrans.hpp @@ -95,7 +95,7 @@ public: int Send_Dir_socket(const char *dirname); int download(char* pFilename,string& strUrl,string& strResponse,bool bDownload); - + int dl_curl_post_req(const string &url, const string &postParams, string& filename); public: void SetDebug(bool bDebug); private: diff --git a/dbaccess/SH_SqlDB.cpp b/dbaccess/SH_SqlDB.cpp index 10e7335..11b0423 100644 --- a/dbaccess/SH_SqlDB.cpp +++ b/dbaccess/SH_SqlDB.cpp @@ -2,6 +2,7 @@ #include "../API_log/SH_log.h" #include "../common/SH_global.h" #include +#include "../calculation/Calculation.hpp" bool SqlSwitch() { @@ -12,6 +13,7 @@ bool SqlSwitch() } SqliteDB *sql_ctl = SqliteDB::instance(); +Calculation *pCalculation = Calculation::instance(); SqliteDB::SqliteDB() { @@ -28,7 +30,7 @@ void SqliteDB::SqliteInit(const char *pDbName, bool isDB2) //创建传感器信息存储表 memset(sql_exec, 0, 2048); - sprintf(sql_exec, "create table if not exists %s(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s);", + sprintf(sql_exec, "create table if not exists %s(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s);", T_SENSOR_INFO(TNAME), T_SENSOR_INFO(DATANODENO), T_SENSOR_INFO(DATANODENAME), @@ -43,6 +45,11 @@ void SqliteDB::SqliteInit(const char *pDbName, bool isDB2) T_SENSOR_INFO(BPNO), T_SENSOR_INFO(SERIALNO), T_SENSOR_INFO(FIRSTPOWERNO), + "WakeupTime", + "StaticTime", + "WaveTime", + "BateryV", + "ProductNo", T_SENSOR_INFO(CONFIGFLAG), T_SENSOR_INFO(STARTBRANDS), T_SENSOR_INFO(STOPBRANDS), @@ -58,15 +65,32 @@ void SqliteDB::SqliteInit(const char *pDbName, bool isDB2) T_SENSOR_INFO(ZIGBEESHORTADDR), T_SENSOR_INFO(ZIGBEELONGADDR), T_SENSOR_INFO(ZIGBEEDESADDR), + "ZigbeePower", + "ZigbeeRetry", + "ZigbeeRetryGap", + "ACCSampleTime", T_SENSOR_INFO(STATUS), T_SENSOR_INFO(TIMESTAMP), T_SENSOR_INFO(VIFF), - T_SENSOR_INFO(RSSI)), + T_SENSOR_INFO(RSSI), + "UpdateFlag", + "LooseValue", + "batteryPower"), CreateTable(sql_exec, isDB2); + int iRet = GetTableRows(" sqlite_master "," name = 't_sensor_info' and sql LIKE '%LooseValue%' "); + if(iRet == 0){ + CreateTable("ALTER TABLE t_sensor_info ADD COLUMN 'LooseValue'"); + } + + iRet = GetTableRows(" sqlite_master "," name = 't_sensor_info' and sql LIKE '%batteryPower%' "); + if(iRet == 0){ + CreateTable("ALTER TABLE t_sensor_info ADD COLUMN 'batteryPower'"); + } + //创建传感器数据存储表 memset(sql_exec, 0, 2048); - sprintf(sql_exec, "create table if not exists %s(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s);", + sprintf(sql_exec, "create table if not exists %s(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s integer,%s,%s);", T_DATA_INFO(TNAME), T_DATA_INFO(DATANODENO), T_DATA_INFO(CHANNELID), @@ -84,14 +108,20 @@ void SqliteDB::SqliteInit(const char *pDbName, bool isDB2) T_DATA_INFO(PHASE2), T_DATA_INFO(PHASE3), T_DATA_INFO(PHASE4), - T_DATA_INFO(TIMESTAMP)); + T_DATA_INFO(STATICINDEX), + T_DATA_INFO(TIMESTAMP), + T_DATA_INFO(SENDMSG), + T_DATA_INFO(NODERESEND)); CreateTable(sql_exec, isDB2); - + iRet = GetTableRows(" sqlite_master "," name = 't_data_info' and sql LIKE '%nodeResend%' "); + if(iRet == 0){ + CreateTable("ALTER TABLE t_data_info ADD COLUMN 'nodeResend'"); + } //创建传感器静态数据存储表 memset(sql_exec, 0, 2048); - sprintf(sql_exec, "create table if not exists %s(%s,%s,%s,%s,%s,%s,%s);", + sprintf(sql_exec, "create table if not exists %s(%s,%s,%s,%s,%s,%s,%s,%s integer,%s,%s);", T_DATASTATIC_INFO(TNAME), T_DATASTATIC_INFO(DATANODENO), T_DATASTATIC_INFO(CHANNELID), @@ -99,10 +129,152 @@ void SqliteDB::SqliteInit(const char *pDbName, bool isDB2) T_DATASTATIC_INFO(TEMBOT), T_DATASTATIC_INFO(DIP), T_DATASTATIC_INFO(VOLTAGE), - T_DATASTATIC_INFO(TIMESTAMP)); - CreateTable(sql_exec, isDB2); + "Battery", + T_DATASTATIC_INFO(STATICINDEX), + T_DATASTATIC_INFO(TIMESTAMP), + T_DATASTATIC_INFO(SENDMSG), + T_DATASTATIC_INFO(NODERESEND)); + CreateTable(sql_exec, isDB2); + iRet = GetTableRows(" sqlite_master "," name = 't_datastatic_info' and sql LIKE '%nodeResend%' "); + if(iRet == 0){ + CreateTable("ALTER TABLE t_datastatic_info ADD COLUMN 'nodeResend'"); + } + + memset(sql_exec, 0, 2048); + sprintf(sql_exec, "create table if not exists %s(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s);", + T_GATEWAY_INFO(TNAME), + T_GATEWAY_INFO(GATEWAYMAC), + T_GATEWAY_INFO(SENSORVER), + T_GATEWAY_INFO(GATEWAYLOCATION), + T_GATEWAY_INFO(ZIGBEEPANID), + T_GATEWAY_INFO(ZIGBEECHANNEL), + T_GATEWAY_INFO(COMMUNICATIONTYPE), + T_GATEWAY_INFO(SIGNAL), + T_GATEWAY_INFO(LOCALIP), + T_GATEWAY_INFO(SYSTEMVERSION), + T_GATEWAY_INFO(PROGRAMVERSION), + T_GATEWAY_INFO(WEBVERSION), + T_GATEWAY_INFO(SERVERIP), + T_GATEWAY_INFO(SERVERPORT), + T_GATEWAY_INFO(STATUS), + T_GATEWAY_INFO(GATEWAYUPDATE), + T_GATEWAY_INFO(MAC2)); + CreateTable(sql_exec, isDB2); + + memset(sql_exec, 0, 2048); + sprintf(sql_exec, "create table if not exists %s(%s,%s,%s,%s,%s);", + "t_data_waveSend","channelID","waveName","timeStamp","sendMsg","save"); + CreateTable(sql_exec, isDB2); + + iRet = GetTableRows(" sqlite_master "," name = 't_data_waveSend' and sql LIKE '%sendMsg%' "); + if(iRet == 0){ + CreateTable("ALTER TABLE t_data_waveSend ADD COLUMN 'sendMsg'"); + } + iRet = GetTableRows(" sqlite_master "," name = 't_data_waveSend' and sql LIKE '%save%' "); + if(iRet == 0){ + CreateTable("ALTER TABLE t_data_waveSend ADD COLUMN 'save'"); + } + /*memset(sql_exec, 0, 2048); + sprintf(sql_exec, "create table if not exists %s(%s,%s,%s,%s,%s integer,%s integer ,%s integer ,%s integer,%s integer);", + T_DATANODE_TIME(TNAME), + T_DATANODE_TIME(DATANODENO), + T_DATANODE_TIME(SHORTADDR), + T_DATANODE_TIME(STATICCYCLE), + T_DATANODE_TIME(WAVECYCLE), + T_DATANODE_TIME(NODEGROUP), + T_DATANODE_TIME(NODEINDEX), + T_DATANODE_TIME(NODEWAVEINDEX), + T_DATANODE_TIME(STATICTIME), + T_DATANODE_TIME(STATICSTARTTIME)); + CreateTable(sql_exec, isDB2);*/ + +} +void SqliteDB::Createtable(const char *ptableName) +{ + char sql_exec[2048]; + //创建传感器数据存储表 + memset(sql_exec, 0, 2048); + sprintf(sql_exec, "create table if not exists %s(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s integer,%s,%s,%s);", + ptableName, + T_DATA_INFO(DATANODENO), + T_DATA_INFO(CHANNELID), + T_DATA_INFO(DIAGNOSISEAK), + T_DATA_INFO(INTEGRATPK), + T_DATA_INFO(INTEGRATRMS), + T_DATA_INFO(RMSVALUES), + T_DATA_INFO(ENVELOPNERGY), + T_DATA_INFO(AMP1), + T_DATA_INFO(AMP2), + T_DATA_INFO(AMP3), + T_DATA_INFO(AMP4), + T_DATA_INFO(AMP5), + T_DATA_INFO(PHASE1), + T_DATA_INFO(PHASE2), + T_DATA_INFO(PHASE3), + T_DATA_INFO(PHASE4), + "StaticIndex", + T_DATA_INFO(TIMESTAMP), + "sendMsg", + "nodeResend"); + CreateTable(sql_exec, 0); + memset(sql_exec, 0, 2048); + sprintf(sql_exec,"CREATE INDEX %s_1 \ + ON %s (%s)",ptableName,ptableName,T_DATA_INFO(DATANODENO)); + CreateTable(sql_exec, 0); } +void SqliteDB::SqliteInitDel(const char *pDbName) +{ + Deletetable(T_DATA_INFO(TNAME)); + Deletetable(T_DATASTATIC_INFO(TNAME)); + vec_t vecResult = GetDataMultiLineOfOneColumn(T_SENSOR_INFO(TNAME),T_SENSOR_INFO(ZIGBEELONGADDR),NULL); + for(int i = 0; i < vecResult.size() && vecResult.size() > 0;i++) + { + char sztableName[100]={0x00}; + sprintf(sztableName,"t_data_%s",vecResult[i].c_str()); + Deletetable(sztableName); + sprintf(sztableName,"t_dataStatic_%s",vecResult[i].c_str()); + Deletetable(sztableName); + } +} +void SqliteDB::Deletetable(const char *ptableName) +{ + char sql_exec[2048]; + //创建传感器数据存储表 + memset(sql_exec, 0, 2048); + sprintf(sql_exec,"DROP TABLE %s ;",ptableName); + int iRet = sqlite3_exec(GetDbHandle(false), sql_exec, 0, 0, NULL); + if (iRet != SQLITE_OK) { + perror_info("sqlite3_exec"); + } + +} +void SqliteDB::CreatedataStatictable(const char *ptableName) +{ + char sql_exec[2048]; + //创建传感器数据存储表 + memset(sql_exec, 0, 2048); + sprintf(sql_exec, "create table if not exists %s(%s,%s,%s,%s,%s,%s,%s,%s integer,%s,%s,%s);", + ptableName, + T_DATASTATIC_INFO(DATANODENO), + T_DATASTATIC_INFO(CHANNELID), + T_DATASTATIC_INFO(TEMTOP), + T_DATASTATIC_INFO(TEMBOT), + T_DATASTATIC_INFO(DIP), + T_DATASTATIC_INFO(VOLTAGE), + "zigbeeSignal", + "StaticIndex", + T_DATASTATIC_INFO(TIMESTAMP), + "sendMsg", + "nodeResend" + //"zigbeeRSSIType" + ); + CreateTable(sql_exec, 0); + memset(sql_exec, 0, 2048); + sprintf(sql_exec,"CREATE INDEX %s_1 \ + ON %s (%s)",ptableName,ptableName,T_DATA_INFO(DATANODENO)); + CreateTable(sql_exec, 0); +} bool SqliteDB::OpenDB(const char *pDbName, bool isDB2) { if (isDB2 == false) { @@ -255,11 +427,36 @@ vec_t SqliteDB::GetDataSingleLine(const char *tablename, const char *column, con return vecResult; } - +char* SqliteDB::GetDataChar(const char *tablename, const char *column, const char *whereCon) +{ + char szRes[100]={0x00}; + std::string strSql = "select "; + if (whereCon != NULL) { + strSql = strSql + column + " from " + tablename + " where " + whereCon + ";"; + } + else { + strSql = strSql + column + " from " + tablename + ";"; + } + print_light_green("%s\n", strSql.c_str()); + // if (SqlSwitch()) log_system->log_write_system("[info]","%s\n", strSql.c_str()); + sqlite3_stmt *stmt; + if (sqlite3_prepare_v2(mDBAcess, strSql.c_str(), -1, &stmt, 0) != SQLITE_OK) { + print_error("sqlite3_prepare_v2:%s\n", sqlite3_errmsg(mDBAcess)); + sqlite3_finalize(stmt); + return NULL; + } + int retStep = sqlite3_step(stmt); + if (retStep == SQLITE_ROW) { + char *columninfo = (char*)sqlite3_column_text(stmt, 0); + memcpy(szRes,columninfo,sizeof(szRes)); + } + sqlite3_finalize(stmt); + return szRes; +} std::string SqliteDB::GetData(const char *tablename, const char *column, const char *whereCon) { - std::string strRes; + std::string strRes = ""; std::string strSql = "select "; if (whereCon != NULL) { strSql = strSql + column + " from " + tablename + " where " + whereCon + ";"; @@ -270,9 +467,11 @@ std::string SqliteDB::GetData(const char *tablename, const char *column, const c print_light_green("%s\n", strSql.c_str()); // if (SqlSwitch()) log_system->log_write_system("[info]","%s\n", strSql.c_str()); sqlite3_stmt *stmt; + g_tDbMutex.Lock(); if (sqlite3_prepare_v2(mDBAcess, strSql.c_str(), -1, &stmt, 0) != SQLITE_OK) { print_error("sqlite3_prepare_v2:%s\n", sqlite3_errmsg(mDBAcess)); sqlite3_finalize(stmt); + g_tDbMutex.UnLock(); return strRes; } int retStep = sqlite3_step(stmt); @@ -281,6 +480,7 @@ std::string SqliteDB::GetData(const char *tablename, const char *column, const c strRes = columninfo != NULL ? columninfo : ""; } sqlite3_finalize(stmt); + g_tDbMutex.UnLock(); return strRes; } @@ -294,12 +494,15 @@ array_t SqliteDB::GetDataMultiLine(const char *tablename, const char *column, co else { strSql = strSql + column + " from " + tablename + ";"; } + print_light_green("%s\n", strSql.c_str()); // if (SqlSwitch()) log_system->log_write_system("[info]","%s\n", strSql.c_str()); sqlite3_stmt *stmt; + g_tDbMutex.Lock(); if (sqlite3_prepare_v2(mDBAcess, strSql.c_str(), -1, &stmt, 0) != SQLITE_OK) { print_error("sqlite3_prepare_v2:%s\n", sqlite3_errmsg(mDBAcess)); sqlite3_finalize(stmt); + g_tDbMutex.UnLock(); return arrResult; } int retStep = sqlite3_step(stmt); @@ -315,9 +518,47 @@ array_t SqliteDB::GetDataMultiLine(const char *tablename, const char *column, co retStep = sqlite3_step(stmt); } sqlite3_finalize(stmt); + g_tDbMutex.UnLock(); return arrResult; } +array_t SqliteDB::GetDataMultiLineTransaction(const char *tablename, const char *column, const char *whereCon) +{ + array_t arrResult; + std::string strSql = "select "; + if (whereCon != NULL) { + strSql = strSql + column + " from " + tablename + " where " + whereCon + ";"; + } + else { + strSql = strSql + column + " from " + tablename + ";"; + } + print_light_green("%s\n", strSql.c_str()); +// if (SqlSwitch()) log_system->log_write_system("[info]","%s\n", strSql.c_str()); + sqlite3_exec(mDBAcess, "BEGIN", 0, 0, NULL); + sqlite3_stmt *stmt; + if (sqlite3_prepare_v2(mDBAcess, strSql.c_str(), -1, &stmt, 0) != SQLITE_OK) { + print_error("sqlite3_prepare_v2:%s\n", sqlite3_errmsg(mDBAcess)); + sqlite3_finalize(stmt); + return arrResult; + } + sqlite3_reset(stmt); + sqlite3_bind_int(stmt, 1, 0); + int retStep = sqlite3_step(stmt); + int column_count = sqlite3_column_count(stmt); + while (retStep == SQLITE_ROW) { + vec_t vecResult; + for (int iCol = 0; iCol < column_count; iCol++) { + char *columninfo = (char*)sqlite3_column_text(stmt, iCol); + std::string str = columninfo != NULL ? columninfo : ""; + vecResult.push_back(str); + } + arrResult.push_back(vecResult); + retStep = sqlite3_step(stmt); + } + sqlite3_finalize(stmt); + sqlite3_exec(mDBAcess, "COMMIT", 0, 0, NULL); + return arrResult; +} vec_t SqliteDB::GetDataMultiLineOfOneColumn(const char *tablename, const char *column, const char *whereCon) { vec_t vecResult; @@ -346,7 +587,33 @@ vec_t SqliteDB::GetDataMultiLineOfOneColumn(const char *tablename, const char *c sqlite3_finalize(stmt); return vecResult; } - +vec_Value SqliteDB::GetDataMultiLineOfOneColumnDouble(const char *tablename, const char *column, const char *whereCon) +{ + vec_Value vecResult; + std::string strSql = "select "; + if (whereCon != NULL) { + strSql = strSql + column + " from " + tablename + " where " + whereCon + ";"; + } + else { + strSql = strSql + column + " from " + tablename + ";"; + } + print_light_green("%s\n", strSql.c_str()); + // if (SqlSwitch()) log_system->log_write_system("[info]","%s\n", strSql.c_str()); + sqlite3_stmt *stmt; + if (sqlite3_prepare_v2(mDBAcess, strSql.c_str(), -1, &stmt, 0) != SQLITE_OK) { + print_error("sqlite3_prepare_v2:%s\n", sqlite3_errmsg(mDBAcess)); + sqlite3_finalize(stmt); + return vecResult; + } + int retStep = sqlite3_step(stmt); + while (retStep == SQLITE_ROW) { + double columninfo = sqlite3_column_double(stmt, 0); + vecResult.push_back(columninfo); + retStep = sqlite3_step(stmt); + } + sqlite3_finalize(stmt); + return vecResult; +} int SqliteDB::DeleteTableData(const char* tablename, const char* whereCond, bool isDB2) @@ -358,6 +625,7 @@ int SqliteDB::DeleteTableData(const char* tablename, const char* whereCond, bool else { strSql = strSql + tablename + ";"; } + // LOG_INFO("strSql = %s",strSql.c_str()); print_light_green("%s\n", strSql.c_str()); // if (SqlSwitch()) log_system->log_write_system("[info]","%s\n", strSql.c_str()); char *msg; @@ -390,7 +658,34 @@ int SqliteDB::DeleteTableDataOneConditon(const char* tablename, const char* cond } return iRet; } +int SqliteDB::UpdateNodeNameData(const char* tablename, const char* updateColumn, const char* whereCond, bool isDB2) +{ + std::string strSql = "update "; + char szSql[1024] = {0x00}; + strcat(szSql,"update "); + if (whereCond != NULL) { + strcat(szSql,tablename); + strcat(szSql," set "); + strcat(szSql,updateColumn); + strcat(szSql," where "); + strcat(szSql,whereCond); + strcat(szSql,";"); + strSql = strSql + tablename + " set " + updateColumn + " where " + whereCond + ";"; + } + else { + strSql = strSql + tablename + " set " + updateColumn + ";"; + } + print_light_green("%s\n", strSql.c_str()); + // if (SqlSwitch()) log_system->log_write_system("[info]","%s\n", strSql.c_str()); + char *msg; + int iRet = sqlite3_exec(GetDbHandle(isDB2), szSql, 0, 0, &msg); + if (iRet != SQLITE_OK) { + print_error("sqlite3 error: code=%d msg=%s\n", iRet, msg); + sqlite3_free(msg); + } + return iRet; +} int SqliteDB::UpdateTableData(const char* tablename, const char* updateColumn, const char* whereCond, bool isDB2) { std::string strSql = "update "; @@ -403,12 +698,14 @@ int SqliteDB::UpdateTableData(const char* tablename, const char* updateColumn, c print_light_green("%s\n", strSql.c_str()); // if (SqlSwitch()) log_system->log_write_system("[info]","%s\n", strSql.c_str()); char *msg; + g_tDbMutex.Lock(); int iRet = sqlite3_exec(GetDbHandle(isDB2), strSql.c_str(), 0, 0, &msg); if (iRet != SQLITE_OK) { print_error("sqlite3 error: code=%d msg=%s\n", iRet, msg); sqlite3_free(msg); } + g_tDbMutex.UnLock(); return iRet; } @@ -484,7 +781,357 @@ int SqliteDB::InsertData(const char* tablename, const char* insertValues, int re } return iRet; } +int SqliteDB::InsertData(const char* insertSql) +{ + char *msg; + int iRet = sqlite3_exec(GetDbHandle(false), insertSql, 0, 0, &msg); + if (iRet != SQLITE_OK) { + print_error("sqlite3 error: code=%d msg=%s\n", iRet, msg); + sqlite3_free(msg); + } + return iRet; +} +int SqliteDB::CalculateBattery() +{ + float dayStaticPower = 6.5,dayWavePower = 237;// + char whereCon[1024] = {0}; + char selectSql[1024] = { 0 }; + memset(whereCon,0x00,sizeof(whereCon)); + memset(selectSql,0x00,sizeof(selectSql)); + sprintf(selectSql," DataNodeNo,StaticTime,WaveTime,featureInterVal,waveInterVal,samplingRate "); + array_t vecRes ; + vecRes = GetDataMultiLine(T_SENSOR_INFO(TNAME), selectSql, NULL); + if(vecRes.size() > 0){ + for(int i = 0; i < vecRes.size(); i++){ + if(vecRes[i][5] == "12800"){ + }else if(vecRes[i][5] == "3200"){ + + } + float dayStaticTime = 0.0; + float dayWaveTime = 0.0; + if(atoi(vecRes[i][3].c_str()) == 0){ + dayStaticTime = 0; + }else{ + dayStaticTime = 24*60/atoi(vecRes[i][3].c_str()); + } + if(atoi(vecRes[i][4].c_str()) == 0){ + dayWaveTime = 0; + }else{ + dayWaveTime = 24*60/atoi(vecRes[i][4].c_str()); + } + + float dayPower = dayStaticTime * dayStaticPower + dayWaveTime * dayWavePower + 24*3.26;//static + wave + sleep + float usePower = atoi(vecRes[i][1].c_str()) * dayStaticPower + atoi(vecRes[i][2].c_str()) * dayWavePower; + if(dayPower == 0) + dayPower = 1; + float remainDay = (19000000*0.5 - usePower)/dayPower; + float bateryProportion = remainDay/(19000000*0.5/dayPower); + char updateSql[1024] = { 0x00 }; + char tmpParam[1024] = {0x00}; + memset(whereCon,0x00,sizeof(whereCon)); + memset(updateSql,0x00,sizeof(updateSql)); + sprintf(whereCon,"dataNodeNo = '%s' ",vecRes[i][0].c_str()); + sprintf(updateSql,"batteryPower = '%f,%f' ",bateryProportion,remainDay); + int iRet = UpdateTableData(T_SENSOR_INFO(TNAME), updateSql, whereCon); + print_info("iRet = %d\n",iRet); + string strData = sql_ctl->GetNodeConfigureInfor(whereCon); + data_publish(strData.c_str(), GlobalConfig::Topic_G.mPubConfig.c_str()); + } + } + + print_info("CalculateBattery \n"); + return 0; +} +int SqliteDB::CalculateDip() +{ + char whereCon[1024] = {0}; + char selectSql[1024] = { 0 }; + char updateSql[1024] = { 0 }; + memset(whereCon,0x00,sizeof(whereCon)); + memset(selectSql,0x00,sizeof(selectSql)); + sprintf(selectSql," DataNodeNo"); + array_t vecRes ; + vecRes = GetDataMultiLine(T_SENSOR_INFO(TNAME), selectSql, NULL); + for(int i = 0 ; i < vecRes.size(); i++){ + char szTablename[32]={0x00}; + sprintf(szTablename,"t_dataStatic_%s",vecRes[i][0].c_str()); + vec_Value vecResDip = GetDataMultiLineOfOneColumnDouble(szTablename," Dip ", NULL); + float sample_variance = pCalculation->getSample_variance(vecResDip); + print_info("sample_variance = %f\n",sample_variance); + memset(whereCon,0x00,sizeof(whereCon)); + memset(updateSql,0x00,sizeof(updateSql)); + sprintf(whereCon,"dataNodeNo = '%s' ",vecRes[i][0].c_str()); + sprintf(updateSql,"LooseValue = '%f' ",sample_variance); + UpdateTableData(T_SENSOR_INFO(TNAME),updateSql,whereCon); + } +} +int SqliteDB::InintGateway() +{ + //更新网关配置表 + string strIP = GetGwIp_("eth0"); + string strServerIP = ReadStrByOpt(SERVERCONFIG, "Server", "localServerIpAddress"); + string strServerPort = ReadStrByOpt(SERVERCONFIG, "Server", "localServerPort"); + string strwebVersion = ReadStrByOpt(SYSTEMINFOFILE, "Version", "WebVersion"); + string strsystemVersion = ReadStrByOpt(SYSTEMINFOFILE, "Version", "SystemVersion"); + string strGatewayVersion = ReadStrByOpt(SYSTEMINFOFILE, "Version", "GateWayVersion"); + std::string strchan = ReadStrByOpt(ZIGBEECONFIG, "Zigbee", "channel"); + if(0 == sql_ctl->GetTableRows(T_GATEWAY_INFO(TNAME), NULL)){ + + char strSql[1024] = { 0 }; + sprintf(strSql,"insert into t_gateway_info(gatewayMAC,zigbeePanID,zigbeeChannel,\ + localIP,systemVersion,programVersion,webVersion,serverIP,serverPort,MAC2)\ + values('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s');",GlobalConfig::MacAddr_G.c_str(),GlobalConfig::MacAddr_G.substr(8).c_str(),strchan.c_str(),strIP.c_str(),\ + strsystemVersion.c_str(),strGatewayVersion.c_str(),strwebVersion.c_str(),strServerIP.c_str(),strServerPort.c_str(),GlobalConfig::MacAddr_G2.c_str()); + sql_ctl->InsertData(strSql); + print_info("strSql = %s\n",strSql); + }else{ + char whereCon[1024] = {0}; + char updateSql[1024] = { 0 }; + sprintf(updateSql, "zigbeePanID = '%s',zigbeeChannel = '%s',localIP = '%s',systemVersion='%s',programVersion='%s',webVersion='%s',serverIP='%s',serverPort='%s'",\ + GlobalConfig::MacAddr_G.substr(8).c_str(),strchan.c_str(),strIP.c_str(),\ + strsystemVersion.c_str(),strGatewayVersion.c_str(),strwebVersion.c_str(),strServerIP.c_str(),strServerPort.c_str()); + sprintf(whereCon, "gatewayMAC='%s'", GlobalConfig::MacAddr_G.c_str()); + sql_ctl->UpdateTableData(T_GATEWAY_INFO(TNAME), updateSql, whereCon); + } + + //上传网关配置到MQTT + Json::Value jsSystemSetting; + Json::Value jsBody; + Json::FastWriter showValue; + Json::Value jsonVal; + jsonVal.clear(); + + jsonVal["cmd"] = "23"; + jsonVal["dataNodeGatewayNo"] = GlobalConfig::MacAddr_G; + jsSystemSetting["WebVersion"] = strwebVersion; + jsSystemSetting["SystemVersion"] = strsystemVersion; + jsSystemSetting["GateWayVersion"] = strGatewayVersion; + jsBody["localServerIpAddress"] = ReadStrByOpt(SERVERCONFIG, "Server", "localServerIpAddress"); + jsBody["localServerPort"] = atoi(ReadStrByOpt(SERVERCONFIG, "Server", "localServerPort").c_str()); + jsBody["CommMode"] = atoi(ReadStrByOpt(SERVERCONFIG, "Server", "CommMode").c_str()); + jsBody["Password"] = (ReadStrByOpt(SERVERCONFIG, "Server", "Password")); + jsBody["UserName"] = (ReadStrByOpt(SERVERCONFIG, "Server", "UserName")); + std::string dataBody = showValue.write(jsBody); + jsonVal["cmdBody"] = dataBody; + data_publish(showValue.write(jsonVal).c_str(), GlobalConfig::Topic_G.mPubConfig.c_str()); + + jsBody.clear(); + jsonVal["cmd"] = "25"; + jsBody["dnsName"] = ReadStrByOpt(NETWORKCONFIG, "Net", "dnsName"); + jsBody["networkPortStatus"] = ReadStrByOpt(NETWORKCONFIG, "Net", "networkPortStatus"); + jsBody["gateway"] = ReadStrByOpt(NETWORKCONFIG, "Net", "gateway"); + jsBody["subnetMask"] = ReadStrByOpt(NETWORKCONFIG, "Net", "subnetMask"); + jsBody["dataWatchIpAddress"] = ReadStrByOpt(NETWORKCONFIG, "Net", "ipAddress"); + jsBody["hostName"] = ReadStrByOpt(NETWORKCONFIG, "Net", "hostName"); + + dataBody = showValue.write(jsBody); + jsonVal["cmdBody"] = dataBody; + data_publish(showValue.write(jsonVal).c_str(), GlobalConfig::Topic_G.mPubConfig.c_str()); +} + +std::string SqliteDB::GetNodeConfigureInfor(const char* whereCon) +{ + vec_t vecRes = GetDataSingleLine(T_SENSOR_INFO(TNAME), "*", whereCon); + printf("vecRes = %d\n",vecRes.size()); + if(vecRes.size() < 1) + return ""; + Json::Value jsSensorData; + Json::Value jsonVal; + jsonVal.clear(); + jsonVal["dataNodeGatewayNo"] = GlobalConfig::MacAddr_G; + jsonVal["cmd"] = "26"; + jsSensorData["dataNodeNo"] = vecRes[0]; + jsSensorData["dataNodeName"] = vecRes[1]; + jsSensorData["initFlag"] = atoi(vecRes[2].c_str()); + jsSensorData["accFlag"] = atoi(vecRes[3].c_str()); + jsSensorData["zigbeeFlag"] = atoi(vecRes[4].c_str()); + jsSensorData["temTopFlag"] = atoi(vecRes[5].c_str()); + jsSensorData["temBotFlag"] = atoi(vecRes[6].c_str()); + jsSensorData["hardVersion"] = vecRes[8]; + jsSensorData["softVersion"] = vecRes[9]; + jsSensorData["bpNo"] = vecRes[10]; + jsSensorData["serialNo"] = vecRes[11]; + jsSensorData["firstPowerTime"] = vecRes[12]; + jsSensorData["WakeupTime"] = atoi(vecRes[13].c_str()); + jsSensorData["StaticTime"] = atoi(vecRes[14].c_str()); + jsSensorData["WaveTime"] = atoi(vecRes[15].c_str()); + jsSensorData["BateryV"] = vecRes[16]; + jsSensorData["ProductNo"] = vecRes[17]; + jsSensorData["configFlag"] = atoi(vecRes[18].c_str()); + jsSensorData["startBrands"] = vecRes[19]; + jsSensorData["stopBrands"] = vecRes[20]; + jsSensorData["featureInterVal"] = (vecRes[21]); + jsSensorData["waveInterVal"] = atoi(vecRes[22].c_str()); + jsSensorData["samplingRate"] = atoi(vecRes[23].c_str()); + jsSensorData["range"] = atoi(vecRes[25].c_str()); + jsSensorData["envelopeBandPass"] = vecRes[26]; + jsSensorData["faultFrequency"] = vecRes[27]; + jsSensorData["zigbeePanId"] = vecRes[28]; + jsSensorData["zigbeeChannel"] = (vecRes[29]); + jsSensorData["zigbeeAddr"] = vecRes[30]; + jsSensorData["zigbeeLongAddr"] = vecRes[31]; + jsSensorData["zigbeeDesAddr"] = vecRes[32]; + jsSensorData["ZigbeePower"] = atoi(vecRes[33].c_str()); + jsSensorData["ZigbeeRetry"] = atoi(vecRes[34].c_str()); + jsSensorData["ZigbeeRetryGap"] = atoi(vecRes[35].c_str()); + jsSensorData["ACCSampleTime"] = atoi(vecRes[36].c_str()); + jsSensorData["status"] = atoi(vecRes[37].c_str()); + jsSensorData["timeStamp"] = vecRes[38]; + jsSensorData["viff"] = atoi(vecRes[39].c_str()); + jsSensorData["RSSI"] = atoi(vecRes[40].c_str()); + jsSensorData["Update"] = atoi(vecRes[41].c_str()); + jsSensorData["LooseValue"] = (vecRes[42].c_str()); + jsSensorData["batteryPower"] = (vecRes[43].c_str()); + + Json::FastWriter showValue; + Json::Value jsBody; + jsBody["dataNodeGatewayNo"] = GlobalConfig::MacAddr_G; + jsBody["dataNodeData"] = jsSensorData; + std::string dataBody = showValue.write(jsBody); + jsonVal["cmdBody"] = dataBody; + return showValue.write(jsonVal); +} + +int SqliteDB::QueryofflineData() +{ + vec_t vecRet = GetDataMultiLineOfOneColumn(T_SENSOR_INFO(TNAME),T_SENSOR_INFO(DATANODENO),NULL); + for(int i = 0; i < vecRet.size();i++){ + char StaticTableName[50]={0x00}; + sprintf(StaticTableName,"t_dataStatic_%s",vecRet[i].c_str()); + + array_t arrRetData = GetDataMultiLine(StaticTableName, "*","sendMsg = '0' order by timeStamp asc"); + LOG_INFO("mqttresend check datanodeNo %s,data count %d\n",vecRet[i].c_str(),arrRetData.size()); + if(arrRetData.size() < 1) + continue; + for(int j = 0; j < arrRetData.size();j++){ + char dataTableName[50]={0x00}; + sprintf(dataTableName,"t_data_%s",vecRet[i].c_str()); + char tmpWhere[128]={0x00}; + sprintf(tmpWhere,"sendMsg = '0' and timeStamp = '%s'",arrRetData[j][8].c_str()); + array_t arrRet = GetDataMultiLine(dataTableName, "*","sendMsg = '0'"); + if(arrRet.size() > 0){ + Json::Value valNodeData; + Json::Value valNodeFeature; + for(int k = 0; k < arrRet.size();k++){ + + valNodeFeature["dataNodeNo"] = arrRet[k][0].c_str(); + valNodeFeature["ChannelId"] = arrRet[k][1].c_str(); + valNodeFeature["diagnosisPk"] = atof(arrRet[k][2].c_str()); + valNodeFeature["integratPk"] = atof(arrRet[k][3].c_str()); + valNodeFeature["integratRMS"] = atof(arrRet[k][4].c_str()); + valNodeFeature["rmsValues"] = atof(arrRet[k][5].c_str()); + valNodeFeature["envelopEnergy"] = atof(arrRet[k][6].c_str()); + valNodeFeature["Amp1"] = atof(arrRet[k][7].c_str()); + valNodeFeature["Amp2"] = atof(arrRet[k][8].c_str()); + valNodeFeature["Amp3"] = atof(arrRet[k][9].c_str()); + valNodeFeature["Amp4"] = atof(arrRet[k][10].c_str()); + valNodeFeature["Amp5"] = atof(arrRet[k][1].c_str()); + valNodeFeature["Phase1"] = atof(arrRet[k][12].c_str()); + valNodeFeature["Phase2"] = atof(arrRet[k][13].c_str()); + valNodeFeature["Phase3"] = atof(arrRet[k][14].c_str()); + valNodeFeature["Phase4"] = atof(arrRet[k][15].c_str()); + valNodeFeature["timeStamp"] = atoi(arrRet[k][17].c_str()); + valNodeData.append(valNodeFeature); + } + } + //无线传感器信息 + Json::Value root; + Json::Value valdatastatic; + Json::Value valNodeData; + valdatastatic["TemperatureTop"] = atof(arrRetData[j][2].c_str()); + valdatastatic["TemperatureBot"] = atof(arrRetData[j][3].c_str()); + valdatastatic["Dip"] = atof(arrRetData[j][4].c_str()); + valdatastatic["Voltage"] = atof(arrRetData[j][5].c_str()); + valdatastatic["ChannelType"] = "STATUS"; + valdatastatic["ChannelId"] = (arrRetData[j][1].c_str()); + valdatastatic["TimeStamp"] = atoi(arrRetData[j][8].c_str()); + + valdatastatic["dataNodeNo"] = arrRetData[j][0].c_str(); + valNodeData.append(valdatastatic); + + root["data"] = valNodeData; + root["TimeStamp"] = atoi(arrRetData[j][8].c_str()); + root["dataNodeNo"] = arrRetData[j][0].c_str(); + root["dataNodeGatewayNo"] = GlobalConfig::MacAddr_G; + root["status"] = "resend"; + Json::FastWriter featureValue; + std::string strstatisticData = featureValue.write(root); + + int iRet = data_publish(strstatisticData.c_str(), GlobalConfig::Topic_G.mPubData.c_str()); + //print_info("dataNodeNo = '%s' and TimeStamp = '%s',MQTT ret = %d\n",arrRetData[j][0].c_str(),nowTimetamp.c_str(),iRet); + if(iRet == 0){ + char updateSql[1024] = { 0 }; + char whereCon[64] = { 0 }; + memset(whereCon, 0, 64); + sprintf(whereCon, "dataNodeNo = '%s' and TimeStamp = '%s'", arrRetData[j][0].c_str(),arrRetData[j][8].c_str()); + memcpy(updateSql, "sendMsg='1'",sizeof(updateSql)); + sql_ctl->UpdateTableData(StaticTableName, updateSql, whereCon); + sql_ctl->UpdateTableData(dataTableName, updateSql, whereCon); + LOG_INFO("resend success dataNodeNo = %s,TimeStamp = '%s'\n",arrRetData[j][0].c_str(),arrRetData[j][8].c_str()); + } + sleep(1); + } + } + char whereCon[1024] = {0x00}; + sprintf(whereCon, " SendMsg = 0 "); + array_t arrRetData = GetDataMultiLine("t_data_waveSend", "*",whereCon); + LOG_INFO("mqttresend check wave count %d\n",arrRetData.size()); + if(arrRetData.size() > 0){ + for(int i = 0; i < arrRetData.size();i++){ + std::string strWaveData = ""; + if (access(arrRetData[i][1].c_str(), 0) >= 0) + { + std::vector vecWave; + char localtimestamp[32] = { 0 }; + float fTemp = 0; + std::ifstream inFile(arrRetData[i][1].c_str(),ios::in|ios::binary); + inFile.read((char *)localtimestamp,sizeof(localtimestamp)); + while(inFile.read((char *)&fTemp,sizeof(fTemp))){ + vecWave.push_back(fTemp); + } + + for (int i = 0; i < vecWave.size(); i++) { + char buf[33]={0x00}; + memset(buf,0x00,sizeof(buf)); + sprintf(buf, "%.2f", vecWave[i]); + std::string waveTemp(buf); + if(i == 0){ + strWaveData = waveTemp; + } + strWaveData = strWaveData + "," + waveTemp; + } + inFile.close(); + } + Json::Value valWaveData; + int length = strWaveData.length(); + valWaveData["number"] = length; + valWaveData["channelId"] = arrRetData[i][0]; + valWaveData["dataNodeNo"] = arrRetData[i][0]; + valWaveData["dataNodeGatewayNo"] = GlobalConfig::MacAddr_G; + valWaveData["SensorEngineeringUnit"] = ""; + valWaveData["timeStamp"] = arrRetData[i][2]; + valWaveData["waveData"] = strWaveData; + Json::FastWriter WaveValue; + std::string WaveData = WaveValue.write(valWaveData); + int iRet = data_publish(WaveData.c_str(), GlobalConfig::Topic_G.mPubWaveData.c_str()); + if(iRet == 0){ + char whereCon[1024] = {0x00}; + char updateSql[1024] = {0x00}; + sprintf(whereCon, "channelID='%s' and timeStamp = '%s' ", arrRetData[i][0].c_str(),arrRetData[i][2].c_str()); + sprintf(updateSql, "SendMsg = 1"); + sql_ctl->UpdateTableData("t_data_waveSend", updateSql, whereCon); + //char whereCon[64]={0x00}; + //sprintf(whereCon,"waveName = '%s'",arrRetData[i][1].c_str()); + //DeleteTableData("t_data_waveSend", whereCon); + std::string strCmd = "rm " + arrRetData[i][1]; + system(strCmd.c_str()); + LOG_INFO("resend success waveName = %s\n",arrRetData[i][1].c_str()); + } + } + + } +} int SqliteDB::TransBegin() { return sqlite3_exec(mDBAcess, "begin;", 0, 0, 0); diff --git a/dbaccess/SH_SqlDB.hpp b/dbaccess/SH_SqlDB.hpp index 43f942e..afd1a7b 100644 --- a/dbaccess/SH_SqlDB.hpp +++ b/dbaccess/SH_SqlDB.hpp @@ -14,9 +14,12 @@ extern "C"{ #define T_SENSOR_INFO(x) T_SENSOR_INFO[T_SENSOR_INFO_##x] #define T_DATA_INFO(x) T_DATA_INFO[T_DATA_INFO_##x] #define T_DATASTATIC_INFO(x) T_DATASTATIC_INFO[T_DATASTATIC_INFO_##x] +#define T_GATEWAY_INFO(x) T_GATEWAY_INFO[T_GATEWAY_INFO_##x] +#define T_DATANODE_TIME(x) T_DATANODE_TIME[T_DATANODE_TIME_##x] typedef std::map map_t; typedef std::vector vec_t; +typedef std::vector vec_Value; typedef std::vector array_t; class SqliteDB : public MySingleton < SqliteDB > { @@ -25,6 +28,10 @@ public: virtual ~SqliteDB(); bool OpenDB(const char *pDbName, bool isDB2=false); void SqliteInit(const char *pDbName, bool isDB2=false); + void SqliteInitDel(const char *pDbName); + void Createtable(const char *ptableName); + void Deletetable(const char *ptableName); + void CreatedataStatictable(const char *ptableName); int TransBegin(); int TransRollback(); int TransCommit(); @@ -34,14 +41,24 @@ public: int AlterTable(const char *tablename, const char *column, bool isAdd = true, bool isDB2=false); vec_t GetDataSingleLine(const char *tablename, const char *column, const char *whereCon); std::string GetData(const char *tablename, const char *column, const char *whereCon); + char* GetDataChar(const char *tablename, const char *column, const char *whereCon); array_t GetDataMultiLine(const char *tablename, const char *column, const char *whereCon); + array_t GetDataMultiLineTransaction(const char *tablename, const char *column, const char *whereCon); vec_t GetDataMultiLineOfOneColumn(const char *tablename, const char *column, const char *whereCon); + vec_Value GetDataMultiLineOfOneColumnDouble(const char *tablename, const char *column, const char *whereCon); int DeleteTableData(const char* tablename, const char* whereCond = NULL, bool isDB2=false); int DeleteTableDataOneConditon(const char* tablename, const char* condColumnName, const char * condColumnValue, bool isDB2=false); int UpdateTableData(const char* tablename, const char* updateColumn, const char* whereCond, bool isDB2 = false); + int UpdateNodeNameData(const char* tablename, const char* updateColumn, const char* whereCond, bool isDB2 = false); int UpdateTableDataOneColumn(const char* tablename, const char* columnName, const char* columnValue, const char* whereColName = NULL, const char * whereColValue = NULL, bool isDB2 = false); int UpdateTableData(const char* directSql, bool isDB2 = false); int InsertData(const char* tablename, const char* insertValues, int replace = 0, bool expandalbe = false, bool isDB2 = false); + int InsertData(const char* insertSql); + int CalculateBattery(); + int CalculateDip(); + int InintGateway(); + int QueryofflineData(); + std::string GetNodeConfigureInfor(const char* whereCon); int CloseDB(); private: @@ -107,9 +124,12 @@ typedef enum { T_DATA_INFO_PHASE2, T_DATA_INFO_PHASE3, T_DATA_INFO_PHASE4, + T_DATA_INFO_STATICINDEX, T_DATA_INFO_TIMESTAMP, + T_DATA_INFO_SENDMSG, + T_DATA_INFO_NODERESEND }T_DATA_INFO_Index; -const static char* T_DATA_INFO[] = { "t_data_info", "dataNodeNo", "channelID", "diagnosisPk", "integratPk","integratRMS","rmsValues","envelopEnergy","Amp1","Amp2","Amp3","Amp4","Amp5","Phase1","Phase2","Phase3","Phase4","timeStamp"}; +const static char* T_DATA_INFO[] = { "t_data_info", "dataNodeNo", "channelID", "diagnosisPk", "integratPk","integratRMS","rmsValues","envelopEnergy","Amp1","Amp2","Amp3","Amp4","Amp5","Phase1","Phase2","Phase3","Phase4","StaticIndex","timeStamp","sendMsg","nodeResend"}; typedef enum { @@ -120,8 +140,46 @@ typedef enum { T_DATASTATIC_INFO_TEMBOT, T_DATASTATIC_INFO_DIP, T_DATASTATIC_INFO_VOLTAGE, + T_DATASTATIC_INFO_STATICINDEX, T_DATASTATIC_INFO_TIMESTAMP, + T_DATASTATIC_INFO_SENDMSG, + T_DATASTATIC_INFO_NODERESEND }T_DATASTATIC_INFO_Index; -const static char* T_DATASTATIC_INFO[] = { "t_datastatic_info","dataNodeNo","channelID","temTop","temBot","dip","voltage","timeStamp"}; +const static char* T_DATASTATIC_INFO[] = { "t_datastatic_info","dataNodeNo","channelID","temTop","temBot","dip","voltage","StaticIndex","timeStamp","sendMsg","nodeResend"}; +typedef enum { + T_DATANODE_TIME_TNAME = 0, + T_DATANODE_TIME_DATANODENO, + T_DATANODE_TIME_SHORTADDR, + T_DATANODE_TIME_STATICCYCLE, + T_DATANODE_TIME_WAVECYCLE, + T_DATANODE_TIME_NODEGROUP, + T_DATANODE_TIME_NODEINDEX, + T_DATANODE_TIME_NODEWAVEINDEX, + T_DATANODE_TIME_STATICTIME, + T_DATANODE_TIME_STATICSTARTTIME +}T_DATANODE_TIME_Index; +const static char* T_DATANODE_TIME[] = { "t_datanode_time","dataNodeNo","shortaddr","staticcycle","wavecycle","nodegroup","nodeindex","nodewaveindex","statictime","staticstarttime"}; + + +typedef enum { + T_GATEWAY_INFO_TNAME = 0, + T_GATEWAY_INFO_GATEWAYMAC, + T_GATEWAY_INFO_SENSORVER, + T_GATEWAY_INFO_GATEWAYLOCATION, + T_GATEWAY_INFO_ZIGBEEPANID, + T_GATEWAY_INFO_ZIGBEECHANNEL, + T_GATEWAY_INFO_COMMUNICATIONTYPE, + T_GATEWAY_INFO_SIGNAL, + T_GATEWAY_INFO_LOCALIP, + T_GATEWAY_INFO_SYSTEMVERSION, + T_GATEWAY_INFO_PROGRAMVERSION, + T_GATEWAY_INFO_WEBVERSION, + T_GATEWAY_INFO_SERVERIP, + T_GATEWAY_INFO_SERVERPORT, + T_GATEWAY_INFO_STATUS, + T_GATEWAY_INFO_GATEWAYUPDATE, + T_GATEWAY_INFO_MAC2, +}T_GATEWAY_INFO_Index; +const static char* T_GATEWAY_INFO[] = { "t_gateway_info","gatewayMAC","sensorVersion","gatewayLocation","zigbeePanID","zigbeeChannel","communicationType","signal","localIP","systemVersion","programVersion","webVersion","serverIP","serverPort","status","gateWayUpdate","MAC2"}; #endif diff --git a/dial5G/Dial.cpp b/dial5G/Dial.cpp new file mode 100644 index 0000000..d1158f1 --- /dev/null +++ b/dial5G/Dial.cpp @@ -0,0 +1,296 @@ +/* + * Dial.cpp + * + * Created on: 2023年6月13日 + * Author: chaos + */ +#include +#include +#include +#include +#include +#include +#include "../common/SH_CommonFunc.hpp" +#include "Dial.h" + + +Dial::Dial() { + // TODO Auto-generated constructor stub + m_fd = 0; + m_curState = CPIN; + m_dial = 0; + m_APN = 0; +} + +Dial::~Dial() { + // TODO Auto-generated destructor stub +} + +int Dial::openPort(const char* pPort) +{ + m_fd = config_uart(pPort,115200); + print_info("m_fd = %d\n",m_fd); + return m_fd; +} +int Dial::parseData(Event event,const char* pData) +{ + print_info("m_curState = %d,event = %d\n",m_curState,event); + string signal; + string ret; + std::string str; + int pos = 0; + switch(event){ + case Event_CPIN: + if(!strncmp(pData,"READY",5)){ + m_curState = QCFGNET; + }else if(!strncmp(pData,"NOT READY",9)){ + m_curState = CPIN; + GlobalConfig::NetStatus = "\"LIMSRV\""; + } + break; + case Event_QCFGNET: + case Event_QCFGSMS: + /*ret = GetOneContent(pData,1,","); + if(ret == "0") + { + m_curState = QICSGPAPN; + }*/ + break; + case Event_QICSGPAPN: + //if(!strcmp(pData,"OK")) + { + m_curState = QNETDEVCTL; + } + break; + case Event_QENG: + GlobalConfig::NetStatus = GetOneContent(pData,1,","); + GlobalConfig::NetType = GetOneContent(pData,2,","); + signal = GetOneContent(pData,12,","); + GlobalConfig::NetSignal = atoi(signal.c_str()); + print_info("NetStatus = %s,NetSignal = %d\n",GlobalConfig::NetStatus.c_str(),GlobalConfig::NetSignal); + break; + case Event_QNETDEVCTL: + print_info("m_curState Event_QNETDEVCTL = %d\n",m_curState); + if(m_dial == 1){ + m_curState = QNETDEVSTATUS; + } + break; + case Event_QNETDEVSTATUS: + ret = GetOneContent(pData,3,","); + if(ret == "0" || ret == "") + m_curState = QDCHPC; + else + m_curState = QNETDEVSTATUS; + break; + case Event_OK: + if(m_curState == QNETDEVCTL && m_dial == 1) + { + m_dial = 0; + m_curState = QNETDEVSTATUS; + } + if(m_curState == Event_QCFGNET){ + m_curState = QNETDEVCTL; + } + if(m_curState == QICSGPAPN && m_APN == 1) + { + m_APN = 0; + m_curState = QNETDEVCTL; + } + + break; + case Event_ERROR: + if(m_curState == CPIN && !strcmp(pData,"3")){ + m_curState = CPIN; + GlobalConfig::NetStatus = "\"LIMSRV\""; + } + if(m_curState == QNETDEVCTL){ + m_curState = QNETDEVSTATUS; + } + break; + case Event_TEMP: + str = string(pData); + pos = str.find("soc-thermal"); + if(pos > 0){ + std::string socTmp = str.substr(pos+14,2); + GlobalConfig::NR5GTemp = socTmp; + print_info("NR5GTemp = %s\n",GlobalConfig::NR5GTemp.c_str()); + } + + + break; + default: + break; + } +} +int Dial::recvData() +{ + + char szbuffer[200]={0x00}; + int offSize = 0; + int timeoutflag = 0; + while(1) + { + char buff[1024]={0x00}; + + int ret = read_data(m_fd, buff, 1024, 10); + if(ret <= 0){ + timeoutflag ++; + if(timeoutflag > 5) + { + timeoutflag = 0; + const char *strQENG = "+QENG: "; + const char *strQNETDEVCTL = "+QNETDEVCTL: "; + const char *strQICSGP = "+QICSGP: "; + const char *strQNETDEVSTATUS= "+QNETDEVSTATUS: "; + const char *strQCFG= "+QCFG: "; + const char *strCPIN= "+CPIN: "; + const char *strERROR= "+CME ERROR: "; + const char *strQTEMP= "+QTEMP: "; + const char *strOK= "OK"; + char data[128] = {0}; + char *pdata = strstr((char*)szbuffer, strQENG); + if(pdata){ + strncpy(data, pdata+7, sizeof(data)); + print_purple("strQENG = %s\n",data); + parseData(Event_QENG,data); + } + pdata = strstr((char*)szbuffer, strQNETDEVCTL); + if(pdata){ + strncpy(data, pdata+13, sizeof(data)); + print_purple("strQNETDEVCTL = %s\n",data); + parseData(Event_QNETDEVCTL,data); + } + pdata = strstr((char*)szbuffer, strQICSGP); + if(pdata){ + strncpy(data, pdata+9, sizeof(data)); + print_purple("strQICSGP = %s\n",data); + parseData(Event_QICSGPAPN,data); + } + pdata = strstr((char*)szbuffer, strQNETDEVSTATUS); + if(pdata){ + strncpy(data, pdata+16, sizeof(data)); + print_purple("strQNETDEVSTATUS = %s\n",data); + parseData(Event_QNETDEVSTATUS,data); + } + pdata = strstr((char*)szbuffer, strQCFG); + if(pdata){ + strncpy(data, pdata+7, sizeof(data)); + print_purple("strQCFG = %s\n",data); + parseData(Event_QCFGNET,data); + } + pdata = strstr((char*)szbuffer, strCPIN); + if(pdata){ + strncpy(data, pdata+7, sizeof(data)); + print_purple("strCPIN = %s\n",data); + parseData(Event_CPIN,data); + } + pdata = strstr((char*)szbuffer, strQTEMP); + if(pdata){ + strncpy(data, pdata+8, sizeof(data)); + print_purple("strQTEMP = %s\n",data); + parseData(Event_TEMP,data); + } + pdata = strstr((char*)szbuffer, strERROR); + if(pdata){ + strncpy(data, pdata+12, sizeof(data)); + print_purple("strERROR = %s\n",data); + parseData(Event_ERROR,data); + } + pdata = strstr((char*)szbuffer, strOK); + if(pdata){ + parseData(Event_OK,data); + } + memset(szbuffer,0x00,sizeof(szbuffer)); + offSize = 0; + } + usleep(100); + }else if(ret > 0){ + print_info("ret = %d,buff = %s\n",ret,buff); + memcpy(szbuffer + offSize,buff,ret); + offSize = offSize + ret; + print_info("szbuffer = %s\n",szbuffer); + continue; + } + usleep(500000); + } +} +int Dial::queryPin() +{ + int iRet = write_data(m_fd,"AT+CPIN?\r\n",12); +} +int Dial::configNet() +{ + write_data(m_fd,"AT+QCFG=\"NAT\"\r\n",19); +} +int Dial::configApn() +{ + m_APN = 1; + std::string strAPN = ReadStrByOpt(SERVERCONFIG, "Server", "APN"); + char szCmd[100]={0x00}; + sprintf(szCmd,"AT+QICSGP=1,1,\"%s\",\"\",\"\",1\r\n",strAPN.c_str()); + int iRet = write_data(m_fd,szCmd,strlen(strAPN.c_str()) + 34); + print_info("configApn = %d,data = %s\n",iRet,szCmd); +} +int Dial::getCsq() +{ + write_data(m_fd,"AT+QENG=\"servingcell\"\r\n",27); +} +int Dial::getTemp() +{ + write_data(m_fd,"AT+QTEMP\r\n",12); +} +int Dial::conncectUSB() +{ + int iRet = write_data(m_fd,"AT+QNETDEVCTL=1,1,1\r\n",23); + print_info("conncectUSB = %d\n",iRet); +} +int Dial::dial5G() +{ + while(1){ + + if(m_curState == CPIN){ + queryPin(); + } + if(m_curState == QCFGNET){ + configNet(); + //configims(); + } + if(m_curState == QICSGPAPN){ + configApn(); + } + if(m_curState == QENG){ + getCsq(); + + } + if(m_curState == QNETDEVCTL){ + conncectUSB(); + m_dial = 1; + } + if(m_curState == QNETDEVSTATUS){ + write_data(m_fd,"AT+QNETDEVSTATUS=1\r\n",22); + } + if(m_curState == QDCHPC){ + configdhcp(); + m_curState = QENG; + } + sleep(5); + getTemp(); + sleep(15); + } +} +int Dial::configims() +{ + write_data(m_fd,"AT+QCFG=\"ims\",0\r\n",21); +} +int Dial::configdhcp() +{ + system("busybox udhcpc -f -n -q -t 5 -i usb0"); +} +int Dial::setState() +{ + m_curState = CPIN; +} +int Dial::closePort() +{ + close(m_fd); +} diff --git a/dial5G/Dial.h b/dial5G/Dial.h new file mode 100644 index 0000000..e4b18cd --- /dev/null +++ b/dial5G/Dial.h @@ -0,0 +1,70 @@ +/* + * Dial.h + * + * Created on: 2023年6月13日 + * Author: chaos + */ + +#ifndef DIAL5G_DIAL_H_ +#define DIAL5G_DIAL_H_ +#include +#include "../common/SH_global.h" +using namespace std; +class Dial { +public: + Dial(); + virtual ~Dial(); + + //枚举所有状态 + enum State + { + CPIN = 0, + QCFGNET, + QICSGPAPN, + QCFGSMS, + QENG, + QNETDEVCTL, + QNETDEVSTATUS, + QDCHPC, + NORMAL + }; + + //枚举所有事件 + enum Event + { + Event_CPIN = 0, + Event_QCFGNET, + Event_QICSGPAPN, + Event_QCFGSMS, + Event_QENG, + Event_QNETDEVCTL, + Event_QNETDEVSTATUS, + Event_OK, + Event_ERROR, + Event_TEMP + }; + + State m_curState; + int m_fd; + int m_dial; + int m_APN; + int openPort(const char* pPort); + int closePort(); + int recvData(); + int queryPin(); + int configNet(); + int configApn(); + int getCsq(); + int getTemp(); + int conncectUSB(); + int dial5G(); + int configims(); + int configdhcp(); + int parseData(Event event,const char* pData); + int setState(); + + + +}; + +#endif /* DIAL5G_DIAL_H_ */ diff --git a/jsonparse/SH_JsonCmd.cpp b/jsonparse/SH_JsonCmd.cpp index 4484706..9d488d0 100644 --- a/jsonparse/SH_JsonCmd.cpp +++ b/jsonparse/SH_JsonCmd.cpp @@ -1,6 +1,8 @@ #include "SH_JsonCmd.hpp" #include "../dbaccess/SH_SqlDB.hpp" #include "../platform/SH_PlatformInit.hpp" +#include "../MD5/md5.h" + namespace{ PlatformInit *platform = PlatformInit::instance(); @@ -35,7 +37,15 @@ std::string JsonData::JsonCmd_20(Param_20 ¶m) Json::Value jsSystemInfo; Json::Value jsBody; - + + string strwebVersion = ReadStrByOpt(SYSTEMINFOFILE, "Version", "WebVersion"); + string strsystemVersion = ReadStrByOpt(SYSTEMINFOFILE, "Version", "SystemVersion"); + string strGatewayVersion = ReadStrByOpt(SYSTEMINFOFILE, "Version", "GateWayVersion"); + + jsSystemInfo["WebVersion"] = strwebVersion; + jsSystemInfo["SystemVersion"] = strsystemVersion; + jsSystemInfo["GateWayVersion"] = strGatewayVersion; + jsSystemInfo[JSON_FIELD_NAME] = ReadStrByOpt(SYSTEMINFOFILE, "SystemInfo", "dataNodeGatewayName"); jsSystemInfo[JSON_FIELD_dataNodeGatewayNo] = GlobalConfig::MacAddr_G; jsSystemInfo[JSON_FIELD_ASSETID] = ReadStrByOpt(SYSTEMINFOFILE, "SystemInfo", "dataNodeGatewayAssetId"); @@ -50,8 +60,8 @@ std::string JsonData::JsonCmd_20(Param_20 ¶m) jsSystemInfo["zigbeeChannel"] = GlobalConfig::ZigbeeInfo_G.Channel; jsSystemInfo["zigbeeAddr"] = GlobalConfig::ZigbeeInfo_G.MyAddr; jsSystemInfo[JSON_FIELD_SERVERIP] = ReadStrByOpt(SERVERCONFIG, "Server", "localServerIpAddress"); - jsSystemInfo[JSON_FIELD_SERVERPORT] = boost::lexical_cast(ReadStrByOpt(SERVERCONFIG, "Server", "localServerPort")); - jsSystemInfo[JSON_FIELD_CommMode] = boost::lexical_cast(ReadStrByOpt(SERVERCONFIG, "Server", "CommMode")); + jsSystemInfo[JSON_FIELD_SERVERPORT] = atoi(ReadStrByOpt(SERVERCONFIG, "Server", "localServerPort").c_str()); + jsSystemInfo[JSON_FIELD_CommMode] = atoi(ReadStrByOpt(SERVERCONFIG, "Server", "CommMode").c_str()); jsBody["SystemInfo"] = jsSystemInfo; std::string dataBody = showValue.write(jsBody); @@ -96,11 +106,18 @@ std::string JsonData::JsonCmd_23(Param_23 ¶m) WriteStr2Config(SERVERCONFIG, "Server", "localServerIpAddress", param.mServerIp); WriteStr2Config(SERVERCONFIG, "Server", "localServerPort", param.mPort); WriteStr2Config(SERVERCONFIG, "Server", "CommMode", param.mCommMode); - printf("param.mCommMode = %s\n",param.mCommMode.c_str()); + WriteStr2Config(SERVERCONFIG, "Server", "Password", param.mPassword); + WriteStr2Config(SERVERCONFIG, "Server", "UserName", param.mUserName); + print_info("param.mCommMode = %s\n",param.mCommMode.c_str()); if("1" == param.mCommMode){//有线连接 system("mv /etc/init.d/S91quectel-CM.sh /etc/init.d/wireless.sh"); - }else if("2" == param.mCommMode){//无线连接 - system("mv /etc/init.d/wireless.sh /etc/init.d/S91quectel-CM.sh"); + system("mv /etc/init.d/S95check5G /etc/init.d/wireless5G"); + }else if("2" == param.mCommMode){//无线连接 4G + system("mv /etc/init.d/wireless4G /etc/init.d/S91check4G"); + system("mv /etc/init.d/S95check5G /etc/init.d/wireless5G"); + }else if("3" == param.mCommMode){//无线连接 5G + system("mv /etc/init.d/wireless5G /etc/init.d/S95check5G"); + system("mv /etc/init.d/S91check4G /etc/init.d/wireless4G"); } sleep(1); system("reboot"); @@ -114,9 +131,23 @@ std::string JsonData::JsonCmd_23(Param_23 ¶m) Json::Value jsSystemSetting; Json::Value jsBody; + Json::Value jsHeart; + Json::FastWriter fw; + jsHeart["dataNodeGatewayNo"] = GlobalConfig::MacAddr_G; + jsHeart["status"] = "online_V1.0.1"; + std::string strJson = fw.write(jsHeart); + int iRet = data_publish(strJson.c_str(), GlobalConfig::Topic_G.mPubHeart.c_str()); + if(iRet == 0){ + jsBody["status"] = 0; + }else{ + jsBody["status"] = -1; + } + jsBody[JSON_FIELD_SERVERIP] = ReadStrByOpt(SERVERCONFIG, "Server", "localServerIpAddress"); - jsBody[JSON_FIELD_SERVERPORT] = boost::lexical_cast(ReadStrByOpt(SERVERCONFIG, "Server", "localServerPort")); - jsBody[JSON_FIELD_CommMode] = boost::lexical_cast(ReadStrByOpt(SERVERCONFIG, "Server", "CommMode")); + jsBody[JSON_FIELD_SERVERPORT] = atoi(ReadStrByOpt(SERVERCONFIG, "Server", "localServerPort").c_str()); + jsBody[JSON_FIELD_CommMode] = atoi(ReadStrByOpt(SERVERCONFIG, "Server", "CommMode").c_str()); + jsBody["Password"] = (ReadStrByOpt(SERVERCONFIG, "Server", "Password")); + jsBody["UserName"] = (ReadStrByOpt(SERVERCONFIG, "Server", "UserName")); std::string dataBody = showValue.write(jsBody); jsonVal["cmdBody"] = dataBody; @@ -128,39 +159,62 @@ std::string JsonData::JsonCmd_23(Param_23 ¶m) std::string JsonData::JsonCmd_25(Param_25 ¶m) { - Json::Value jsonVal; - jsonVal.clear(); - jsonVal["success"] = true; - jsonVal["message"] = ""; - if (0 == param.mMode) { - WriteStr2Config(NETWORKCONFIG, "Net", "dnsName", param.mDnsName); - WriteStr2Config(NETWORKCONFIG, "Net", "networkPortStatus", param.mNetworkPortStatus); - WriteStr2Config(NETWORKCONFIG, "Net", "gateway", param.mGateway); - WriteStr2Config(NETWORKCONFIG, "Net", "subnetMask", param.mSubnetMask); - WriteStr2Config(NETWORKCONFIG, "Net", "ipAddress", param.mIp); - WriteStr2Config(NETWORKCONFIG, "Net", "hostName", param.mHostName); - system("reboot"); - } + Json::Value jsonVal; + jsonVal.clear(); + jsonVal["success"] = true; + jsonVal["message"] = " "; + jsonVal["cmd"] = "25"; + bool bFlag1 = CheckIP(param.mGateway.c_str()); + bool bFlag2 = IsValidMask(param.mSubnetMask); + bool bFlag3 = CheckIP(param.mIp.c_str()); + bool bFlag4 = false; + if(param.mDnsName.size()>0){ + bFlag4 = CheckIP(param.mDnsName.c_str()); + }else{ + bFlag4 = true; + } + print_info("bFlag1 = %d,bFlag2 = %d,bFlag3 = %d,bFlag4 = %d\n",bFlag1,bFlag2,bFlag3,bFlag4); - jsonVal["cmd"] = "25"; - jsonVal["dataNodeGatewayNo"] = GlobalConfig::MacAddr_G; - jsonVal["cmdSerial"] = param.mCmdSerial; + if (0 == param.mMode &&(bFlag1 && bFlag2 && bFlag3 && bFlag4) && param.mNetworkPortStatus == "STATIC") { + WriteStr2Config(NETWORKCONFIG, param.mNet, "dnsName", param.mDnsName); + WriteStr2Config(NETWORKCONFIG, param.mNet, "networkPortStatus", param.mNetworkPortStatus); + WriteStr2Config(NETWORKCONFIG, param.mNet, "gateway", param.mGateway); + WriteStr2Config(NETWORKCONFIG, param.mNet, "subnetMask", param.mSubnetMask); + WriteStr2Config(NETWORKCONFIG, param.mNet, "ipAddress", param.mIp); + WriteStr2Config(NETWORKCONFIG, param.mNet, "hostName", param.mHostName); - Json::Value jsSystemSetting; - Json::Value jsBody; +#ifdef IMX6UL_GATEWAY + char GateWay[100]={0x00}; + sprintf(GateWay,"sed -i '7c route add default gw %s' /etc/init.d/S90start_userapp.sh",param.mGateway.c_str()); + print_info("GateWay = %s\n",GateWay); + system(GateWay); +#endif + platform->EquipIpInit(param.mNet); + }else if(0 == param.mMode && param.mNetworkPortStatus == "DHCP"){ + WriteStr2Config(NETWORKCONFIG, param.mNet, "dnsName", ""); + WriteStr2Config(NETWORKCONFIG, param.mNet, "networkPortStatus", param.mNetworkPortStatus); + WriteStr2Config(NETWORKCONFIG, param.mNet, "gateway", ""); + WriteStr2Config(NETWORKCONFIG, param.mNet, "subnetMask", ""); + WriteStr2Config(NETWORKCONFIG, param.mNet, "ipAddress", ""); + WriteStr2Config(NETWORKCONFIG, param.mNet, "hostName", ""); - jsBody["dnsName"] = ReadStrByOpt(NETWORKCONFIG, "Net", "dnsName"); - jsBody["networkPortStatus"] = ReadStrByOpt(NETWORKCONFIG, "Net", "networkPortStatus"); - jsBody["gateway"] = ReadStrByOpt(NETWORKCONFIG, "Net", "gateway"); - jsBody["subnetMask"] = ReadStrByOpt(NETWORKCONFIG, "Net", "subnetMask"); - jsBody["dataWatchIpAddress"] = ReadStrByOpt(NETWORKCONFIG, "Net", "ipAddress"); - jsBody["hostName"] = ReadStrByOpt(NETWORKCONFIG, "Net", "hostName"); +#ifdef IMX6UL_GATEWAY + system("sed -i '7c udhcpc -i eth0 > /dev/null &' /etc/init.d/S90start_userapp.sh"); +#endif + platform->EquipIpInit(param.mNet); - std::string dataBody = showValue.write(jsBody); - jsonVal["cmdBody"] = dataBody; + }else if(0 == param.mMode &&(!bFlag1 || !bFlag2 || !bFlag3 || !bFlag4) && param.mNetworkPortStatus == "STATIC"){ + jsonVal["success"] = false; + } - return showValue.write(jsonVal); + jsonVal["content"]["dnsName"] = ReadStrByOpt(NETWORKCONFIG, param.mNet, "dnsName"); + jsonVal["content"]["networkPortStatus"] = ReadStrByOpt(NETWORKCONFIG, param.mNet, "networkPortStatus"); + jsonVal["content"]["gateway"] = ReadStrByOpt(NETWORKCONFIG, param.mNet, "gateway"); + jsonVal["content"]["subnetMask"] = ReadStrByOpt(NETWORKCONFIG, param.mNet, "subnetMask"); + jsonVal["content"]["dataWatchIpAddress"] = ReadStrByOpt(NETWORKCONFIG, param.mNet, "ipAddress"); + jsonVal["content"]["hostName"] = ReadStrByOpt(NETWORKCONFIG, param.mNet, "hostName"); + return showValue.write(jsonVal); } @@ -182,45 +236,46 @@ std::string JsonData::JsonCmd_26(Param_26 ¶m) Json::Value jsSensorData; jsSensorData["dataNodeNo"] = arrRes[j][0]; jsSensorData["dataNodeName"] = arrRes[j][1]; - jsSensorData["initFlag"] = boost::lexical_cast(arrRes[j][2]); - jsSensorData["accFlag"] = boost::lexical_cast(arrRes[j][3]); - jsSensorData["zigbeeFlag"] = boost::lexical_cast(arrRes[j][4]); - jsSensorData["temTopFlag"] = boost::lexical_cast(arrRes[j][5]); - jsSensorData["temBotFlag"] = boost::lexical_cast(arrRes[j][6]); + jsSensorData["initFlag"] = atoi(arrRes[j][2].c_str()); + jsSensorData["accFlag"] = atoi(arrRes[j][3].c_str()); + jsSensorData["zigbeeFlag"] = atoi(arrRes[j][4].c_str()); + jsSensorData["temTopFlag"] = atoi(arrRes[j][5].c_str()); + jsSensorData["temBotFlag"] = atoi(arrRes[j][6].c_str()); + jsSensorData["equipsta"] = atoi(arrRes[j][7].c_str()); jsSensorData["hardVersion"] = arrRes[j][8]; jsSensorData["softVersion"] = arrRes[j][9]; jsSensorData["bpNo"] = arrRes[j][10]; jsSensorData["serialNo"] = arrRes[j][11]; jsSensorData["firstPowerTime"] = arrRes[j][12]; - jsSensorData["WakeupTime"] = boost::lexical_cast(arrRes[j][13]); - jsSensorData["StaticTime"] = boost::lexical_cast(arrRes[j][14]); - jsSensorData["WaveTime"] = boost::lexical_cast(arrRes[j][15]); + jsSensorData["WakeupTime"] = atoi(arrRes[j][13].c_str()); + jsSensorData["StaticTime"] = atoi(arrRes[j][14].c_str()); + jsSensorData["WaveTime"] = atoi(arrRes[j][15].c_str()); jsSensorData["BateryV"] = arrRes[j][16]; jsSensorData["ProductNo"] = arrRes[j][17]; - jsSensorData["configFlag"] = boost::lexical_cast(arrRes[j][18]); + jsSensorData["configFlag"] = atoi(arrRes[j][18].c_str()); jsSensorData["startBrands"] = arrRes[j][19]; jsSensorData["stopBrands"] = arrRes[j][20]; - jsSensorData["featureInterVal"] = boost::lexical_cast(arrRes[j][21]); - jsSensorData["waveInterVal"] = boost::lexical_cast(arrRes[j][22]); - jsSensorData["samplingRate"] = boost::lexical_cast(arrRes[j][23]); - printf("stopBrands11111 = %s\n",arrRes[j][20].c_str()); - // jsSensorData["scope"] = boost::lexical_cast(arrRes[j][24]); - jsSensorData["range"] = boost::lexical_cast(arrRes[j][25]); + jsSensorData["featureInterVal"] = (arrRes[j][21]); + jsSensorData["waveInterVal"] = atoi(arrRes[j][22].c_str()); + jsSensorData["samplingRate"] = atoi(arrRes[j][23].c_str()); + // jsSensorData["scope"] = atoi(arrRes[j][24]); + jsSensorData["range"] = atoi(arrRes[j][25].c_str()); jsSensorData["envelopeBandPass"] = arrRes[j][26]; jsSensorData["faultFrequency"] = arrRes[j][27]; jsSensorData["zigbeePanId"] = arrRes[j][28]; - jsSensorData["zigbeeChannel"] = boost::lexical_cast(arrRes[j][29]); + jsSensorData["zigbeeChannel"] = (arrRes[j][29]); jsSensorData["zigbeeAddr"] = arrRes[j][30]; jsSensorData["zigbeeLongAddr"] = arrRes[j][31]; jsSensorData["zigbeeDesAddr"] = arrRes[j][32]; - jsSensorData["ZigbeePower"] = boost::lexical_cast(arrRes[j][33]); - jsSensorData["ZigbeeRetry"] = boost::lexical_cast(arrRes[j][34]); - jsSensorData["ZigbeeRetryGap"] = boost::lexical_cast(arrRes[j][35]); - jsSensorData["ACCSampleTime"] = boost::lexical_cast(arrRes[j][36]); - jsSensorData["status"] = boost::lexical_cast(arrRes[j][37]); + jsSensorData["ZigbeePower"] = atoi(arrRes[j][33].c_str()); + jsSensorData["ZigbeeRetry"] = atoi(arrRes[j][34].c_str()); + jsSensorData["ZigbeeRetryGap"] = atoi(arrRes[j][35].c_str()); + jsSensorData["ACCSampleTime"] = atoi(arrRes[j][36].c_str()); + jsSensorData["status"] = atoi(arrRes[j][37].c_str()); jsSensorData["timeStamp"] = arrRes[j][38]; - jsSensorData["viff"] = boost::lexical_cast(arrRes[j][39]); - jsSensorData["RSSI"] = boost::lexical_cast(arrRes[j][40]); + jsSensorData["viff"] = atoi(arrRes[j][39].c_str()); + jsSensorData["RSSI"] = atoi(arrRes[j][40].c_str()); + jsSensorData["Update"] = atoi(arrRes[j][41].c_str()); jsArray.append(jsSensorData); } } else { @@ -257,6 +312,7 @@ std::string JsonData::JsonCmd_27(Json::Value & recvBody) sql_ctl->DeleteTableData(T_SENSOR_INFO(TNAME), whereCon); sql_ctl->DeleteTableData(T_DATA_INFO(TNAME), whereCon); sql_ctl->DeleteTableData(T_DATASTATIC_INFO(TNAME), whereCon); + sql_ctl->DeleteTableData(T_DATANODE_TIME(TNAME), whereCon); } } else { jsonVal["success"] = false; @@ -277,22 +333,42 @@ std::string JsonData::JsonCmd_50(Json::Value & recvBody) std::string updateDevice = recvBody["updateDevice"].asString();//1 DataNode 2 GateWay std::string updateURL = recvBody["updateURL"].asString(); std::string updateName = recvBody["updateName"].asString(); + std::string md5 = recvBody["MD5"].asString(); std::string strResponse; - updateName = "/opt/update/DataNode/" + updateName; - bool bDownload = 1; - int iRet = pDataTrans->download( (char*)updateName.c_str(),updateURL, strResponse, bDownload); + updateName = "/opt/" + updateName; + if (access(updateName.c_str(), 0) == 0){ + char cmd[100]={0x00}; + sprintf(cmd,"rm -rf %s",updateName.c_str()); + system(cmd); + } + sleep(2); +// int iRet = pDataTrans->download( (char*)updateName.c_str(),updateURL, strResponse, bDownload); + int iRet = pDataTrans->dl_curl_post_req( updateURL,"",updateName); if(iRet != 0){ jsonVal["success"] = false; jsonVal["message"] = "download failed"; return showValue.write(jsonVal); } + string md5Val = md5file(updateName.c_str()); + printf("md5Val = %s\n",md5Val.c_str()); + printf("md5 = %s\n",md5.c_str()); + if(md5 != md5Val){ + jsonVal["success"] = false; + jsonVal["message"] = "download file check failed"; + return showValue.write(jsonVal); + } if(updateDevice == "1"){ - string strcmd = "tar zxvf "; + string strcmd = "tar xvf "; strcmd = strcmd + updateName; - strcmd = strcmd + " -C /opt/update/DataNode/"; + strcmd = strcmd + " -C /opt/"; system(strcmd.c_str()); - }else{ - + }else if (updateDevice == "2"){ + /* string strcmd = "tar xvf "; + strcmd = strcmd + updateName; + strcmd = strcmd + " -C /opt/update/"; + system(strcmd.c_str());*/ + sleep(3); + system("/opt/opt.sh"); } return showValue.write(jsonVal); } @@ -316,7 +392,104 @@ std::string JsonData::JsonCmd_51(Json::Value & recvBody) } return showValue.write(jsonVal); } +std::string JsonData::JsonCmd_52() +{ + Json::Value jsonVal; + jsonVal.clear(); + jsonVal["success"] = true; + jsonVal["message"] = ""; + char whereCon[512] = {}; + std::string strTimeStamp = ""; + char selectCon[128] = { 0 }; + memcpy(selectCon,"sendMsg = '0'",sizeof(selectCon)); + int count = sql_ctl->GetTableRows(T_DATASTATIC_INFO(TNAME), selectCon); + if(count < 1){ + return ""; + } + for(int i = 0 ; i < count ;i++) + { + Json::Value jsSensor; + std::string strDataNodeNo = ""; + jsonVal.clear(); + jsonVal["cmd"] = "52"; + memcpy(whereCon, "sendMsg = '0' ORDER BY timeStamp DESC LIMIT 0,3",sizeof(whereCon)); + // 自数据库获取传感器特征数据 + array_t arrRes; + arrRes = sql_ctl->GetDataMultiLine(T_DATA_INFO(TNAME), "*", whereCon); + int iResult = arrRes.size(); + if (iResult > 0) { + for (int j = 0; j < iResult; j++) { + Json::Value jsChannelData; + strDataNodeNo = arrRes[j][0]; + jsChannelData["ChannelId"] = arrRes[j][1]; + jsChannelData["ChannelType"] = "ACCELEROMETER"; + jsChannelData["DiagnosisPeak"] = atof(arrRes[j][2].c_str()); + jsChannelData["IntegratPk2Pk/2"] = atof(arrRes[j][3].c_str()); + jsChannelData["IntegratRMS"] = atof(arrRes[j][4].c_str()); + jsChannelData["RMSValues"] = atof(arrRes[j][5].c_str()); + jsChannelData["EnvelopEnergy"] = atof(arrRes[j][6].c_str()); + jsChannelData["1xAmp"] = atof(arrRes[j][7].c_str()); + jsChannelData["2xAmp"] = atof(arrRes[j][8].c_str()); + jsChannelData["3xAmp"] = atof(arrRes[j][9].c_str()); + jsChannelData["4xAmp"] = atof(arrRes[j][10].c_str()); + jsChannelData["5xAmp"] = atof(arrRes[j][11].c_str()); + jsChannelData["1xPhase"] = atof(arrRes[j][12].c_str()); + jsChannelData["2xPhase"] = atof(arrRes[j][13].c_str()); + jsChannelData["3xPhase"] = atof(arrRes[j][14].c_str()); + jsChannelData["4xPhase"] = atof(arrRes[j][15].c_str()); + jsChannelData["TimeStamp"] = atof(arrRes[j][17].c_str()); + strTimeStamp = std::string(arrRes[j][16]); + jsSensor.append(jsChannelData); + } + } + memset(selectCon,0x00,sizeof(selectCon)); + sprintf(selectCon, "dataNodeNo='%s' and sendMsg = '0' ORDER BY timeStamp DESC LIMIT 0,1", strDataNodeNo.c_str()); + vec_t vecRes = sql_ctl->GetDataSingleLine(T_DATASTATIC_INFO(TNAME), "*", selectCon); + Json::Value jsStaticData; + if(vecRes.size()>0){ + jsStaticData["TemperatureTop"] = atof(vecRes[2].c_str()); + jsStaticData["TemperatureBot"] = atof(vecRes[3].c_str()); + jsStaticData["Dip"] = atof(vecRes[4].c_str()); + jsStaticData["Voltage"] = atof(vecRes[5].c_str()); + jsStaticData["ChannelType"] = "STATUS"; + jsStaticData["ChannelId"] = vecRes[1]; + jsStaticData["TimeStamp"] = vecRes[7]; + jsStaticData["dataNodeNo"] = strDataNodeNo; + } + + jsSensor.append(jsStaticData); + + jsonVal["content"].append(jsSensor); + std::string data = showValue.write(jsonVal); + memset(whereCon,0x00,sizeof(whereCon)); + sprintf(whereCon,"sendMsg = '0' and timeStamp = '%s'",strTimeStamp.c_str()); + int iRet = data_publish(data.c_str(), GlobalConfig::Topic_G.mPubCmd.c_str()); + if(iRet == 0){ + sql_ctl->DeleteTableData(T_DATA_INFO(TNAME),whereCon,0); + sql_ctl->DeleteTableData(T_DATASTATIC_INFO(TNAME),whereCon,0); + } + usleep(100); + } + return ""; +} +std::string JsonData::JsonCmd_53(Json::Value & recvBody) +{ + Json::Value jsonVal; + jsonVal.clear(); + jsonVal["success"] = true; + jsonVal["message"] = ""; + jsonVal["cmd"] = "53"; + jsonVal["dataNodeGatewayNo"] = GlobalConfig::MacAddr_G; + std::string looseValue = recvBody["looseValue"].asString(); + + int iRet = writeStringVlaue("config", "loose",(char*)looseValue.c_str(),(char*)GlobalConfig::Config_G.c_str()); + if(iRet != 0){ + jsonVal["success"] = false; + jsonVal["message"] = "update failed"; + } + return showValue.write(jsonVal); +} std::string JsonData::JsonCmd_29(Param_29 ¶m) { Json::Value jsonVal; @@ -325,23 +498,22 @@ std::string JsonData::JsonCmd_29(Param_29 ¶m) jsonVal.clear(); jsonVal["cmd"] = "29"; jsonVal["dataNodeGatewayNo"] = GlobalConfig::MacAddr_G; - jsonVal["cmdSerial"] = param.mCmdSerial; - +// jsonVal["cmdSerial"] = param.mCmdSerial; array_t arrRes; arrRes = sql_ctl->GetDataMultiLine(T_SENSOR_INFO(TNAME), "*", NULL); int iResult = arrRes.size(); +// LOG_INFO("iResult = %d",iResult); if (iResult > 0) { for (int i = 0; i < iResult; i++) { Json::Value jsDataNode; - jsDataNode["dataNodeNo"] = arrRes[i][1]; - jsDataNode["status"] = boost::lexical_cast(arrRes[i][24]); + jsDataNode["dataNodeNo"] = arrRes[i][0]; + jsDataNode["status"] = atoi(arrRes[i][37].c_str()); jsBody["dataNodeArray"].append(jsDataNode); } } - + std::string strBody = showValue.write(jsBody); jsonVal["cmdBody"] = strBody; - return showValue.write(jsonVal); } @@ -382,34 +554,38 @@ void JsonData::JsonCmd_39(Json::Value &recvBody) } void JsonData::DataNodeStatusCheck() { - vec_t vetRes = sql_ctl->GetDataMultiLineOfOneColumn(T_SENSOR_INFO(TNAME), T_SENSOR_INFO(DATANODENO), NULL); + array_t vetRes = sql_ctl->GetDataMultiLine(T_SENSOR_INFO(TNAME), "*", NULL); int nSize = vetRes.size(); char localtimestamp[32] = { 0 }; GetTimeNet(localtimestamp, 1); std::string nowTimetamp = std::string(localtimestamp); - int lNowTime = boost::lexical_cast(nowTimetamp); - + int lNowTime = atoi(nowTimetamp.c_str()); + int onlineCheck = readIntValue( "config", "online",(char*)GlobalConfig::Config_G.c_str()); + int loseTime = readIntValue( "config", "loseTime",(char*)GlobalConfig::Config_G.c_str()); if (nSize > 0) { for (int i = 0; i < nSize; i++) { - std::string strDataNodeNo = vetRes[i]; + std::string strDataNodeNo = vetRes[i][0]; std::string strChannelId= strDataNodeNo + "-X"; - char whereCon[64] = {}; + char whereCon[512] = {0x00},tablename[128]={0x00}; sprintf(whereCon, "dataNodeNo='%s' and channelID='%s' ORDER BY timeStamp DESC LIMIT 0,1", strDataNodeNo.c_str(), strChannelId.c_str()); - array_t arrRes; - std::string strTimeRes = sql_ctl->GetData(T_DATA_INFO(TNAME), T_DATA_INFO(TIMESTAMP), whereCon); + sprintf(tablename,"t_data_%s",strDataNodeNo.c_str()); + std::string strTimeRes = sql_ctl->GetData(tablename, "timeStamp", whereCon); if (strTimeRes.length() > 0) { - int llastTime = boost::lexical_cast(strTimeRes); + int llastTime = atoi(strTimeRes.c_str()); int lTimeTemp = lNowTime - llastTime; - LOG_INFO("lNowTime = %d,llastTime = %d",lNowTime,llastTime); lTimeTemp = abs(lTimeTemp); - if (lTimeTemp > onlineCheck) { - LOG_INFO("0-lTimeTemp = %d,onlineCheck = %d",lTimeTemp,onlineCheck); + if (lTimeTemp > onlineCheck){ + LOG_DEBUG("离线 DataNodeStatusCheck lNowTime = %d,llastTime = %d,interval = %s\n",lNowTime,llastTime,vetRes[i][21].c_str()); char whereCon[32] = { 0 }; sprintf(whereCon, "dataNodeNo='%s'", strDataNodeNo.c_str()); sql_ctl->UpdateTableData(T_SENSOR_INFO(TNAME), "status='0'", whereCon); + }else if(lTimeTemp > (loseTime * atoi(vetRes[i][21].c_str()) * 60)){ + LOG_DEBUG("掉线 DataNodeStatusCheck lNowTime = %d,llastTime = %d,interval = %s\n",lNowTime,llastTime,vetRes[i][21].c_str()); + char whereCon[32] = { 0 }; + sprintf(whereCon, "dataNodeNo='%s'", strDataNodeNo.c_str()); + sql_ctl->UpdateTableData(T_SENSOR_INFO(TNAME), "status='2'", whereCon); }else { - LOG_INFO("1-lTimeTemp = %d,onlineCheck = %d",lTimeTemp,onlineCheck); char whereCon[32] = { 0 }; sprintf(whereCon, "dataNodeNo='%s'", strDataNodeNo.c_str()); sql_ctl->UpdateTableData(T_SENSOR_INFO(TNAME), "status='1'", whereCon); @@ -481,7 +657,7 @@ std::string JsonData::JsonCmd_Cgi_02(Param_02 ¶m) if (0 == param.mMode) { jsonVal["type"] = "SET"; SetTime((unsigned long)param.mTimeStamp); - boost::this_thread::sleep(boost::posix_time::milliseconds(200)); + usleep(200); system("hwclock -w"); } else if (1 == param.mMode) { char cmd[256] = { 0 }; @@ -489,7 +665,7 @@ std::string JsonData::JsonCmd_Cgi_02(Param_02 ¶m) GetTimeNet(localtimestamp, 1); std::string nowTimetamp = std::string(localtimestamp); jsonVal["type"] = "GET"; - jsonVal["timeStamp"] = boost::lexical_cast(nowTimetamp); + jsonVal["timeStamp"] = atoi(nowTimetamp.c_str()); } return showValue.write(jsonVal); @@ -554,81 +730,290 @@ std::string JsonData::JsonCmd_Cgi_08() return showValue.write(jsonVal); } -std::string JsonData::JsonCmd_Cgi_09() +std::string JsonData::JsonCmd_Cgi_09(Param_09 ¶m) { - Json::Value jsonVal; - jsonVal.clear(); + Json::Value jsonVal; + jsonVal.clear(); - jsonVal[JSON_FIELD_CMD] = "09"; - jsonVal["success"] = true; - jsonVal["message"] = " "; + jsonVal[JSON_FIELD_CMD] = "09"; + jsonVal["success"] = true; + jsonVal["message"] = " "; - vec_t vetRes = sql_ctl->GetDataMultiLineOfOneColumn(T_SENSOR_INFO(TNAME), T_SENSOR_INFO(DATANODENO), NULL); - int nSize = vetRes.size(); - - if (nSize > 0) { - for (int i = 0; i < nSize; i++) { - print_info("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@vetRes=%s\n",vetRes[i].c_str()); - Json::Value jsSensor; - std::string strDataNodeNo = vetRes[i]; - char whereCon[64] = {}; - sprintf(whereCon, "dataNodeNo='%s' ORDER BY timeStamp DESC LIMIT 0,3", strDataNodeNo.c_str()); - // 自数据库获取传感器特征数据 - array_t arrRes; - arrRes = sql_ctl->GetDataMultiLine(T_DATA_INFO(TNAME), "*", whereCon); - int iResult = arrRes.size(); - if (iResult > 0) { - for (int j = 0; j < iResult; j++) { - Json::Value jsChannelData; - jsChannelData["ChannelId"] = arrRes[j][1]; - jsChannelData["ChannelType"] = "ACCELEROMETER"; - jsChannelData["DiagnosisPeak"] = boost::lexical_cast(arrRes[j][2]); - jsChannelData["IntegratPk2Pk/2"] = boost::lexical_cast(arrRes[j][3]); - jsChannelData["IntegratRMS"] = boost::lexical_cast(arrRes[j][4]); - jsChannelData["RMSValues"] = boost::lexical_cast(arrRes[j][5]); - jsChannelData["EnvelopEnergy"] = boost::lexical_cast(arrRes[j][6]); - jsChannelData["1xAmp"] = boost::lexical_cast(arrRes[j][7]); - jsChannelData["2xAmp"] = boost::lexical_cast(arrRes[j][8]); - jsChannelData["3xAmp"] = boost::lexical_cast(arrRes[j][9]); - jsChannelData["4xAmp"] = boost::lexical_cast(arrRes[j][10]); - jsChannelData["5xAmp"] = boost::lexical_cast(arrRes[j][11]); - jsChannelData["1xPhase"] = boost::lexical_cast(arrRes[j][12]); - jsChannelData["2xPhase"] = boost::lexical_cast(arrRes[j][13]); - jsChannelData["3xPhase"] = boost::lexical_cast(arrRes[j][14]); - jsChannelData["4xPhase"] = boost::lexical_cast(arrRes[j][15]); - jsChannelData["TimeStamp"] = boost::lexical_cast(arrRes[j][16]); - jsSensor.append(jsChannelData); - } - } - - char selectCon[128] = { 0 }; - sprintf(selectCon, "dataNodeNo='%s' ORDER BY timeStamp DESC LIMIT 0,1", strDataNodeNo.c_str()); - vec_t vecRes = sql_ctl->GetDataSingleLine(T_DATASTATIC_INFO(TNAME), "*", selectCon); - Json::Value jsStaticData; - if(vecRes.size()>0){ - jsStaticData["TemperatureTop"] = boost::lexical_cast(vecRes[2]); - jsStaticData["TemperatureBot"] = boost::lexical_cast(vecRes[3]); - jsStaticData["Dip"] = boost::lexical_cast(vecRes[4]); - jsStaticData["Voltage"] = boost::lexical_cast(vecRes[5]); - jsStaticData["ChannelType"] = "STATUS"; - jsStaticData["ChannelId"] = vecRes[1]; - jsStaticData["TimeStamp"] = vecRes[6]; - jsStaticData["dataNodeNo"] = strDataNodeNo; - } + char localtimestamp[32] = { 0 }; + GetTimeNet(localtimestamp, 1); + std::string nowTimetamp = std::string(localtimestamp); + char looseValue[10]={0x00}; + readStringValue("config", "loose",looseValue,(char*)GlobalConfig::Config_G.c_str()); - jsSensor.append(jsStaticData); + vec_t vetRes = sql_ctl->GetDataMultiLineOfOneColumn(T_SENSOR_INFO(TNAME), T_SENSOR_INFO(DATANODENO), NULL); + int nSize = vetRes.size(); + if (nSize > 0) { + int packgeNo = param.mPackageFlag; + int packgeMax = 0; + int packgeNum = 0; + jsonVal["package"] = packgeNo; + int lastSize = nSize % 10; + int index = nSize / 10; + if(lastSize > 0 && index > 0){ + packgeMax = index +1; + if(packgeNo +1 == packgeMax){ + packgeNum = nSize; + jsonVal["packageMax"] = index + 1; + } + else{ + packgeNum = (packgeNo+1) * 10; + jsonVal["packageMax"] = index +1; + } + } + else if(lastSize == 0 && index > 0){ + packgeNum = (packgeNo+1) * 10; + packgeMax = index; + jsonVal["packageMax"] = index; + }else if(lastSize > 0 && index == 0){ + packgeNum = lastSize; + packgeMax = index+1; + jsonVal["packageMax"] = index+1; + } - jsonVal["content"].append(jsSensor); - } - } else { - jsonVal["content"].resize(0); - } + printf("09 packgeNo = %d,packgeNum = %d,lastSize = %d,index = %d\n",packgeNo,packgeNum,lastSize,index); + for (int i = packgeNo * 10; i < packgeNum; i++) { + print_info("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@vetRes=%s\n",vetRes[i].c_str()); + Json::Value jsSensor; + std::string strDataNodeNo = vetRes[i]; + char whereCon[512] = {}; + sprintf(whereCon, "dataNodeNo='%s' ORDER BY timeStamp DESC LIMIT 0,3", strDataNodeNo.c_str()); + // 自数据库获取传感器特征数据 + array_t arrRes; + arrRes = sql_ctl->GetDataMultiLineTransaction(T_DATA_INFO(TNAME), "*", whereCon); + int iResult = arrRes.size(); + if (iResult > 0) { + for (int j = 0; j < iResult; j++) { + Json::Value jsChannelData; + jsChannelData["ChannelId"] = arrRes[j][1]; + jsChannelData["ChannelType"] = "ACCELEROMETER"; + jsChannelData["DiagnosisPeak"] = atof(arrRes[j][2].c_str()); + jsChannelData["IntegratPk2Pk/2"] = atof(arrRes[j][3].c_str()); + jsChannelData["IntegratRMS"] = atof(arrRes[j][4].c_str()); + jsChannelData["RMSValues"] = atof(arrRes[j][5].c_str()); + jsChannelData["EnvelopEnergy"] = atof(arrRes[j][6].c_str()); + jsChannelData["1xAmp"] = atof(arrRes[j][7].c_str()); + jsChannelData["2xAmp"] = atof(arrRes[j][8].c_str()); + jsChannelData["3xAmp"] = atof(arrRes[j][9].c_str()); + jsChannelData["4xAmp"] = atof(arrRes[j][10].c_str()); + jsChannelData["5xAmp"] = atof(arrRes[j][11].c_str()); + jsChannelData["1xPhase"] = atof(arrRes[j][12].c_str()); + jsChannelData["2xPhase"] = atof(arrRes[j][13].c_str()); + jsChannelData["3xPhase"] = atof(arrRes[j][14].c_str()); + jsChannelData["4xPhase"] = atof(arrRes[j][15].c_str()); + jsChannelData["TimeStamp"] = atof(arrRes[j][17].c_str()); + jsSensor.append(jsChannelData); + } + } - return showValue.write(jsonVal); + char selectCon[128] = { 0 }; + char column[128]={0}; + char tablename[256]={0}; + sprintf(selectCon, "t_datastatic_%s.dataNodeNo='%s' ORDER BY timeStamp DESC LIMIT 0,1",strDataNodeNo.c_str(),strDataNodeNo.c_str()); + sprintf(column," t_datastatic_%s.*,t_sensor_info.status,t_sensor_info.LooseValue,t_sensor_info.batteryPower ",strDataNodeNo.c_str()); + sprintf(tablename," t_datastatic_%s LEFT JOIN t_sensor_info \ + ON t_datastatic_%s.dataNodeNo = t_sensor_info.dataNodeNo ",strDataNodeNo.c_str(),strDataNodeNo.c_str()); + + + vec_t vecRes = sql_ctl->GetDataSingleLine(tablename,column, selectCon); + Json::Value jsStaticData; + if(vecRes.size()>0){ + jsStaticData["TemperatureTop"] = atof(vecRes[2].c_str()); + jsStaticData["TemperatureBot"] = atof(vecRes[3].c_str()); + jsStaticData["Dip"] = atof(vecRes[4].c_str()); + jsStaticData["Voltage"] = atof(vecRes[5].c_str()); + jsStaticData["ChannelType"] = "STATUS"; + jsStaticData["ChannelId"] = vecRes[1]; + jsStaticData["TimeStamp"] = vecRes[8]; + jsStaticData["battery"] = vecRes[13]; + jsStaticData["dataNodeNo"] = strDataNodeNo; + jsStaticData["status"] = vecRes[11]; + if(atof(looseValue) < atof(vecRes[12].c_str())){ + jsStaticData["loose"] = "1"; + }else{ + jsStaticData["loose"] = "0"; + } + }else{ + jsStaticData["TemperatureTop"] = ""; + jsStaticData["TemperatureBot"] = ""; + jsStaticData["Dip"] = ""; + jsStaticData["Voltage"] = ""; + jsStaticData["ChannelType"] = "STATUS"; + jsStaticData["ChannelId"] = ""; + jsStaticData["TimeStamp"] = ""; + jsStaticData["battery"] = ""; + jsStaticData["dataNodeNo"] = strDataNodeNo; + jsStaticData["status"] = "0"; + jsStaticData["loose"] = "0"; + } + + jsSensor.append(jsStaticData); + + jsonVal["content"].append(jsSensor); + } + + } else { + jsonVal["success"] = true; + jsonVal["content"].resize(0); + } + + return showValue.write(jsonVal); +} +std::string JsonData::JsonCmd_Cgi_10(Param_10 ¶m) +{ + Json::Value jsonVal; + jsonVal.clear(); + + jsonVal[JSON_FIELD_CMD] = "10"; + jsonVal["success"] = true; + jsonVal["message"] = " "; + vec_t vetRes = sql_ctl->GetDataMultiLineOfOneColumn(T_SENSOR_INFO(TNAME), T_SENSOR_INFO(DATANODENO), NULL); + int nSize = vetRes.size(); + if (nSize > 0) { + char selectCon[256] = { 0 },szTableName[100] = {0x00},whereCon[256]={0x00}; + sprintf(selectCon, "%s,channelID,timeStamp",param.strStatic.c_str()); + if(param.straxis == "S") + { + sprintf(szTableName,"t_dataStatic_%s",param.strDataNode.c_str()); + }else{ + sprintf(szTableName,"t_data_%s",param.strDataNode.c_str()); + } + if(param.timeEnd == ""){ + sprintf(whereCon,"dataNodeNo = '%s' and %s <> '' ",\ + param.strDataNode.c_str(),param.strStatic.c_str()); + }else{ + sprintf(whereCon,"dataNodeNo = '%s' and %s <> '' and timeStamp < '%s' and timeStamp > '%s' ",\ + param.strDataNode.c_str(),param.strStatic.c_str(),param.timeEnd.c_str(),param.timeStart.c_str()); + } + int rows = sql_ctl->GetTableRows(szTableName,whereCon); + printf("rows : %d\n",rows); + int packgeNo = param.mPackageFlag; + int packgeMax = 0; + int packgeNum = 0; + jsonVal["package"] = packgeNo; + int lastSize = rows % 550; + int index = rows / 550; + if(lastSize > 0 && index > 0){ + packgeMax = index +1; + if(packgeNo +1 == packgeMax){ + packgeNum = rows-lastSize; + jsonVal["packageMax"] = index + 1; + } + else{ + packgeNum = (packgeNo) * 550; + jsonVal["packageMax"] = index +1;} + } + else if(lastSize == 0 && index > 0){ + packgeNum = (packgeNo+1) * 550; + packgeMax = index; + jsonVal["packageMax"] = index; + }else if(lastSize > 0 && index == 0){ + packgeNum = 0; + packgeMax = index+1; + jsonVal["packageMax"] = index; + } + + printf("10 packgeNo = %d,packgeNum = %d,lastSize = %d,index = %d\n",packgeNo,packgeNum,lastSize,index); + memset(whereCon,0x00,sizeof(whereCon)); + + if(param.timeEnd == ""){ + sprintf(whereCon,"dataNodeNo = '%s' and %s <> '' order by timeStamp asc LIMIT %d OFFSET %d",\ + param.strDataNode.c_str(),param.strStatic.c_str(),550,packgeNum); + }else{ + sprintf(whereCon,"dataNodeNo = '%s' and %s <> '' and timeStamp < '%s' and timeStamp > '%s' order by timeStamp asc LIMIT %d OFFSET %d",\ + param.strDataNode.c_str(),param.strStatic.c_str(),param.timeEnd.c_str(),param.timeStart.c_str(),550,packgeNum); + } + array_t vecRes; + + vecRes = sql_ctl->GetDataMultiLine(szTableName, selectCon,whereCon); + + if(vecRes.size() > 0){ + Json::Value jsStaticData ; + for(int i = 0 ; i < vecRes.size(); i++){ + Json::Value iTem; + if(vecRes[i][1] == param.strDataNode + "-X"){ + iTem.append(vecRes[i][0]); + iTem.append(vecRes[i][2]); + jsStaticData["X"].append(iTem); + }if(vecRes[i][1] == param.strDataNode + "-Y"){ + iTem.append(vecRes[i][0]); + iTem.append(vecRes[i][2]); + jsStaticData["Y"].append(iTem); + }if(vecRes[i][1] == param.strDataNode + "-Z"){ + iTem.append(vecRes[i][0]); + iTem.append(vecRes[i][2]); + jsStaticData["Z"].append(iTem); + } + if(vecRes[i][1] == param.strDataNode + "-S"){ + iTem.append(vecRes[i][0]); + iTem.append(vecRes[i][2]); + jsStaticData["S"].append(iTem); + } + //jsStaticData.append(value) + } + jsonVal["content"] = (jsStaticData); + jsonVal["Static"] = param.strStatic; + print_info("vecRes = %d,channelID = %s\n",vecRes.size(),vecRes[0][0].c_str()); + }else{ + jsonVal["success"] = false; + jsonVal["content"].resize(0); + } + }else{ + jsonVal["success"] = false; + jsonVal["content"].resize(0); + } + return showValue.write(jsonVal); } +std::string JsonData::JsonCmd_Cgi_11(Param_11 ¶m) +{ + Json::Value jsonVal,jsSensor; + jsonVal.clear(); + jsonVal[JSON_FIELD_CMD] = "11"; + jsonVal["success"] = true; + jsonVal["message"] = " "; + char whereCon[512] = {}; + sprintf(whereCon, "dataNodeNo='%s' ORDER BY timeStamp DESC LIMIT 0,3", param.DataNodeNo.c_str()); + // 自数据库获取传感器特征数据 + array_t arrRes; + arrRes = sql_ctl->GetDataMultiLineTransaction(T_DATA_INFO(TNAME), "*", whereCon); + int iResult = arrRes.size(); + print_info("iResult = %d\n",iResult); + if (iResult > 0) { + for (int j = 0; j < iResult; j++) { + Json::Value jsChannelData; + jsChannelData["ChannelId"] = arrRes[j][1]; + jsChannelData["ChannelType"] = "ACCELEROMETER"; + jsChannelData["DiagnosisPeak"] = atof(arrRes[j][2].c_str()); + jsChannelData["IntegratPk2Pk/2"] = atof(arrRes[j][3].c_str()); + jsChannelData["IntegratRMS"] = atof(arrRes[j][4].c_str()); + jsChannelData["RMSValues"] = atof(arrRes[j][5].c_str()); + jsChannelData["EnvelopEnergy"] = atof(arrRes[j][6].c_str()); + jsChannelData["1xAmp"] = atof(arrRes[j][7].c_str()); + jsChannelData["2xAmp"] = atof(arrRes[j][8].c_str()); + jsChannelData["3xAmp"] = atof(arrRes[j][9].c_str()); + jsChannelData["4xAmp"] = atof(arrRes[j][10].c_str()); + jsChannelData["5xAmp"] = atof(arrRes[j][11].c_str()); + jsChannelData["1xPhase"] = atof(arrRes[j][12].c_str()); + jsChannelData["2xPhase"] = atof(arrRes[j][13].c_str()); + jsChannelData["3xPhase"] = atof(arrRes[j][14].c_str()); + jsChannelData["4xPhase"] = atof(arrRes[j][15].c_str()); + jsChannelData["TimeStamp"] = atof(arrRes[j][17].c_str()); + jsSensor.append(jsChannelData); + } + }else { + jsonVal["success"] = false; + jsonVal["content"].resize(0); + } + jsonVal["content"] = jsSensor; + return showValue.write(jsonVal); +} std::string JsonData::JsonCmd_Cgi_20(Param_20 ¶m) { @@ -669,6 +1054,44 @@ std::string JsonData::JsonCmd_Cgi_20(Param_20 ¶m) jsSystemInfo["zigbeePanId"] = GlobalConfig::ZigbeeInfo_G.PanID; jsSystemInfo["zigbeeChannel"] = GlobalConfig::ZigbeeInfo_G.Channel; jsSystemInfo["zigbeeAddr"] = GlobalConfig::ZigbeeInfo_G.MyAddr; + jsSystemInfo["GateWayVersion"] = ReadStrByOpt(SYSTEMINFOFILE, "Version", "GateWayVersion"); + jsSystemInfo["SystemVersion"] = ReadStrByOpt(SYSTEMINFOFILE, "Version", "SystemVersion"); + jsSystemInfo["WebVersion"] = ReadStrByOpt(SYSTEMINFOFILE, "Version", "WebVersion"); + jsSystemInfo["GateWayHwVesion"] = ReadStrByOpt(SYSTEMINFOFILE, "Version", "GateWayHwVesion"); + jsSystemInfo["GateWayProduct"] = ReadStrByOpt(SYSTEMINFOFILE, "Version", "GateWayProduct"); + jsSystemInfo["serverStatus"] = GlobalConfig::serverStatus ; + + if(GlobalConfig::NetType == "\"NR5G-SA\"" || GlobalConfig::NetType == "\"NR5G-NSA\"" || + GlobalConfig::NetType == "\"NR5G\""){ + GlobalConfig::NetType = "5G"; + }else if(GlobalConfig::NetType == "\"LTE\""){ + GlobalConfig::NetType = "4G"; + } + if(GlobalConfig::NetStatus == "\"NOCONN\"" || GlobalConfig::NetStatus == "\"CONNECT\""){ + + if(GlobalConfig::NetSignal == 0){ + jsSystemInfo["communicationSignal"] = GlobalConfig::NetType + ",未知"; + } + else if(GlobalConfig::NetSignal > -80){ + jsSystemInfo["communicationSignal"] = GlobalConfig::NetType + ",优"; + }else if(GlobalConfig::NetSignal > -90 && GlobalConfig::NetSignal < -80){ + jsSystemInfo["communicationSignal"] = GlobalConfig::NetType + ",良"; + }else if(GlobalConfig::NetSignal > -105 && GlobalConfig::NetSignal < -90){ + jsSystemInfo["communicationSignal"] = GlobalConfig::NetType + ",一般"; + }else if(GlobalConfig::NetSignal < -105){ + jsSystemInfo["communicationSignal"] = GlobalConfig::NetType + ",弱"; + }else if(GlobalConfig::NetSignal < -115){ + jsSystemInfo["communicationSignal"] = GlobalConfig::NetType + ",不稳定"; + } + + }else if(GlobalConfig::NetStatus == "\"SEARCH\""){ + jsSystemInfo["communicationSignal"] = GlobalConfig::NetType + ",搜索网络"; + }else if(GlobalConfig::NetStatus == "\"LIMSRV\""){ + jsSystemInfo["communicationSignal"] = GlobalConfig::NetType + ",未插卡"; + }else{ + jsSystemInfo["communicationSignal"] = "未知"; + } + jsBody["SystemInfo"] = jsSystemInfo; @@ -719,7 +1142,13 @@ std::string JsonData::JsonCmd_Cgi_23(Param_23 ¶m) WriteStr2Config(SERVERCONFIG, "Server", "localServerIpAddress", param.mServerIp); WriteStr2Config(SERVERCONFIG, "Server", "localServerPort", param.mPort); - WriteStr2Config(SERVERCONFIG, "Server", "CommMode", param.mCommMode); + WriteStr2Config(SERVERCONFIG, "Server", "CommMode", /*param.mCommMode*/"2"); + WriteStr2Config(SERVERCONFIG, "Server", "UserName", param.mUserName); + WriteStr2Config(SERVERCONFIG, "Server", "Password", param.mPassword); + WriteStr2Config(SERVERCONFIG, "Server", "APN", param.mAPN); + char APN[100]={0x00}; + sprintf(APN,"sed -i '15c \t\t\t\t/opt/quectel-CM/quectel-CM -s %s > /dev/null &' /etc/init.d/S95check5G",param.mAPN.c_str()); + system(APN); system("reboot"); }else if(0 == param.mMode && !(CheckIP(param.mServerIp.c_str()))){ jsonVal["success"] = false; @@ -729,11 +1158,16 @@ std::string JsonData::JsonCmd_Cgi_23(Param_23 ¶m) Json::Value jsBody; jsSystemSetting["ServerIpAddress"] = ReadStrByOpt(SERVERCONFIG, "Server", "localServerIpAddress"); - jsSystemSetting["ServerPort"] = boost::lexical_cast(ReadStrByOpt(SERVERCONFIG, "Server", "localServerPort")); - jsSystemSetting["CommMode"] = boost::lexical_cast(ReadStrByOpt(SERVERCONFIG, "Server", "CommMode")); - + jsSystemSetting["ServerPort"] = atoi(ReadStrByOpt(SERVERCONFIG, "Server", "localServerPort").c_str()); + jsSystemSetting["CommMode"] = atoi(ReadStrByOpt(SERVERCONFIG, "Server", "CommMode").c_str()); + jsSystemSetting["ServerStatus"] = 1; + jsSystemSetting["UserName"] = ReadStrByOpt(SERVERCONFIG, "Server", "UserName"); + jsSystemSetting["Password"] = ReadStrByOpt(SERVERCONFIG, "Server", "Password"); + jsSystemSetting["APN"] = ReadStrByOpt(SERVERCONFIG, "Server", "APN"); jsBody["SystemSettings"] = jsSystemSetting; - jsonVal["content"] = jsBody; + jsonVal["content"] = jsBody; + + return showValue.write(jsonVal); } @@ -743,6 +1177,7 @@ std::string JsonData::JsonCmd_Cgi_23(Param_23 ¶m) std::string JsonData::JsonCmd_Cgi_25(Param_25 ¶m) { Json::Value jsonVal; + Json::Value jsonValnet; jsonVal.clear(); jsonVal["success"] = true; jsonVal["message"] = " "; @@ -750,32 +1185,71 @@ std::string JsonData::JsonCmd_Cgi_25(Param_25 ¶m) bool bFlag1 = CheckIP(param.mGateway.c_str()); bool bFlag2 = IsValidMask(param.mSubnetMask); bool bFlag3 = CheckIP(param.mIp.c_str()); - bool bFlag4 = CheckIP(param.mDnsName.c_str()); + bool bFlag4 = false; + if(param.mDnsName.size()>0){ + bFlag4 = CheckIP(param.mDnsName.c_str()); + }else{ + bFlag4 = true; + } + print_info("bFlag1 = %d,bFlag2 = %d,bFlag3 = %d,bFlag4 = %d\n",bFlag1,bFlag2,bFlag3,bFlag4); - if (0 == param.mMode &&(bFlag1 && bFlag2 && bFlag3 && bFlag4)) { - WriteStr2Config(NETWORKCONFIG, "Net", "dnsName", param.mDnsName); - WriteStr2Config(NETWORKCONFIG, "Net", "networkPortStatus", param.mNetworkPortStatus); - WriteStr2Config(NETWORKCONFIG, "Net", "gateway", param.mGateway); - WriteStr2Config(NETWORKCONFIG, "Net", "subnetMask", param.mSubnetMask); - WriteStr2Config(NETWORKCONFIG, "Net", "ipAddress", param.mIp); - WriteStr2Config(NETWORKCONFIG, "Net", "hostName", param.mHostName); - platform->EquipIpInit(); - system("reboot"); - }else if(0 == param.mMode &&(!bFlag1 || !bFlag2 || !bFlag3 || !bFlag4)){ + if (0 == param.mMode &&(bFlag1 && bFlag2 && bFlag3 && bFlag4) && param.mNetworkPortStatus == "STATIC") { + WriteStr2Config(NETWORKCONFIG, param.mNet, "dnsName", param.mDnsName); + WriteStr2Config(NETWORKCONFIG, param.mNet, "networkPortStatus", param.mNetworkPortStatus); + WriteStr2Config(NETWORKCONFIG, param.mNet, "gateway", param.mGateway); + WriteStr2Config(NETWORKCONFIG, param.mNet, "subnetMask", param.mSubnetMask); + WriteStr2Config(NETWORKCONFIG, param.mNet, "ipAddress", param.mIp); + WriteStr2Config(NETWORKCONFIG, param.mNet, "hostName", param.mHostName); + +#ifdef IMX6UL_GATEWAY + char GateWay[100]={0x00}; + sprintf(GateWay,"sed -i '7c route add default gw %s' /etc/init.d/S90start_userapp.sh",param.mGateway.c_str()); + print_info("GateWay = %s\n",GateWay); + system(GateWay); +#endif + platform->EquipIpInit(param.mNet); + + }else if(0 == param.mMode && param.mNetworkPortStatus == "DHCP"){ + WriteStr2Config(NETWORKCONFIG, param.mNet, "dnsName", ""); + WriteStr2Config(NETWORKCONFIG, param.mNet, "networkPortStatus", param.mNetworkPortStatus); + WriteStr2Config(NETWORKCONFIG, param.mNet, "gateway", ""); + WriteStr2Config(NETWORKCONFIG, param.mNet, "subnetMask", ""); + WriteStr2Config(NETWORKCONFIG, param.mNet, "ipAddress", ""); + WriteStr2Config(NETWORKCONFIG, param.mNet, "hostName", ""); + +#ifdef IMX6UL_GATEWAY + system("sed -i '7c udhcpc -i eth0 > /dev/null &' /etc/init.d/S90start_userapp.sh"); +#endif + platform->EquipIpInit(param.mNet); + + }else if(0 == param.mMode &&(!bFlag1 || !bFlag2 || !bFlag3 || !bFlag4) && param.mNetworkPortStatus == "STATIC"){ jsonVal["success"] = false; } - jsonVal["content"]["dnsName"] = ReadStrByOpt(NETWORKCONFIG, "Net", "dnsName"); - jsonVal["content"]["networkPortStatus"] = ReadStrByOpt(NETWORKCONFIG, "Net", "networkPortStatus"); - jsonVal["content"]["gateway"] = ReadStrByOpt(NETWORKCONFIG, "Net", "gateway"); - jsonVal["content"]["subnetMask"] = ReadStrByOpt(NETWORKCONFIG, "Net", "subnetMask"); - jsonVal["content"]["dataWatchIpAddress"] = ReadStrByOpt(NETWORKCONFIG, "Net", "ipAddress"); - jsonVal["content"]["hostName"] = ReadStrByOpt(NETWORKCONFIG, "Net", "hostName"); + jsonValnet["dnsName"] = ReadStrByOpt(NETWORKCONFIG, "eth0", "dnsName"); + jsonValnet["networkPortStatus"] = ReadStrByOpt(NETWORKCONFIG, "eth0", "networkPortStatus"); + jsonValnet["gateway"] = ReadStrByOpt(NETWORKCONFIG, "eth0" ,"gateway"); + jsonValnet["subnetMask"] = ReadStrByOpt(NETWORKCONFIG, "eth0", "subnetMask"); + jsonValnet["dataWatchIpAddress"] = ReadStrByOpt(NETWORKCONFIG, "eth0", "ipAddress"); + jsonValnet["hostName"] = ReadStrByOpt(NETWORKCONFIG, "eth0", "hostName"); + jsonVal["content"]["eth0"] = jsonValnet; + jsonVal["content"]["gatewaytype"] = 0; + +#ifdef G2UL_GATEWAY + jsonValnet["dnsName"] = ReadStrByOpt(NETWORKCONFIG, "eth1", "dnsName"); + jsonValnet["networkPortStatus"] = ReadStrByOpt(NETWORKCONFIG, "eth1", "networkPortStatus"); + jsonValnet["gateway"] = ReadStrByOpt(NETWORKCONFIG, "eth1", "gateway"); + jsonValnet["subnetMask"] = ReadStrByOpt(NETWORKCONFIG, "eth1", "subnetMask"); + jsonValnet["dataWatchIpAddress"] = ReadStrByOpt(NETWORKCONFIG, "eth1", "ipAddress"); + jsonValnet["hostName"] = ReadStrByOpt(NETWORKCONFIG, "eth1", "hostName"); + jsonVal["content"]["eth1"] =jsonValnet; + jsonVal["content"]["gatewaytype"] = 1; +#endif return showValue.write(jsonVal); } -std::string JsonData::JsonCmd_Cgi_26() +std::string JsonData::JsonCmd_Cgi_26(Param_26 ¶m) { Json::Value jsonVal; jsonVal.clear(); @@ -785,59 +1259,107 @@ std::string JsonData::JsonCmd_Cgi_26() jsonVal["success"] = true; jsonVal["message"] = " "; + char looseValue[10]={0x00}; + readStringValue("config", "loose",looseValue,(char*)GlobalConfig::Config_G.c_str()); + print_debug("loose = %f \n",atof(looseValue)); Json::Value jsArray; array_t arrRes; - arrRes = sql_ctl->GetDataMultiLine(T_SENSOR_INFO(TNAME), "*", NULL); + arrRes = sql_ctl->GetDataMultiLineTransaction(T_SENSOR_INFO(TNAME), "*", NULL); int iResult = arrRes.size(); - printf("iResult = %d\n",iResult); if (iResult > 0) { - for (int j = 0; j < iResult; j++) { + int packgeNo = param.mPackageFlag; + int packgeMax = 0; + int packgeNum = 0; + jsonVal["package"] = packgeNo; + int lastSize = iResult % 10; + int index = iResult / 10; + if(lastSize > 0 && index > 0){ + packgeMax = index +1; + if(packgeNo +1 == packgeMax){ + packgeNum = iResult; + jsonVal["packageMax"] = index + 1; + } + else{ + packgeNum = (packgeNo+1) * 10; + jsonVal["packageMax"] = index +1;} + } + else if(lastSize == 0 && index > 0){ + packgeNum = (packgeNo+1) * 10; + packgeMax = index; + jsonVal["packageMax"] = index; + }else if(lastSize > 0 && index == 0){ + packgeNum = lastSize; + packgeMax = index+1; + jsonVal["packageMax"] = index; + } + + printf("26 packgeNo = %d,packgeNum = %d,lastSize = %d,index = %d\n",packgeNo,packgeNum,lastSize,index); + for (int j = packgeNo * 10; j < packgeNum; j++) { Json::Value jsSensorData; jsSensorData["dataNodeNo"] = arrRes[j][0]; jsSensorData["dataNodeName"] = arrRes[j][1]; - jsSensorData["initFlag"] = boost::lexical_cast(arrRes[j][2]); - jsSensorData["accFlag"] = boost::lexical_cast(arrRes[j][3]); - jsSensorData["zigbeeFlag"] = boost::lexical_cast(arrRes[j][4]); - jsSensorData["temTopFlag"] = boost::lexical_cast(arrRes[j][5]); - jsSensorData["temBotFlag"] = boost::lexical_cast(arrRes[j][6]); + jsSensorData["initFlag"] = atoi(arrRes[j][2].c_str()); + jsSensorData["accFlag"] = atoi(arrRes[j][3].c_str()); + jsSensorData["zigbeeFlag"] = atoi(arrRes[j][4].c_str()); + jsSensorData["temTopFlag"] = atoi(arrRes[j][5].c_str()); + jsSensorData["temBotFlag"] = atoi(arrRes[j][6].c_str()); jsSensorData["hardVersion"] = arrRes[j][8]; jsSensorData["softVersion"] = arrRes[j][9]; jsSensorData["bpNo"] = arrRes[j][10]; jsSensorData["serialNo"] = arrRes[j][11]; jsSensorData["firstPowerTime"] = arrRes[j][12]; - jsSensorData["WakeupTime"] = boost::lexical_cast(arrRes[j][13]); - jsSensorData["StaticTime"] = boost::lexical_cast(arrRes[j][14]); - jsSensorData["WaveTime"] = boost::lexical_cast(arrRes[j][15]); + jsSensorData["WakeupTime"] = atoi(arrRes[j][13].c_str()); + jsSensorData["StaticTime"] = atoi(arrRes[j][14].c_str()); + jsSensorData["WaveTime"] = atoi(arrRes[j][15].c_str()); jsSensorData["BateryV"] = arrRes[j][16]; jsSensorData["ProductNo"] = arrRes[j][17]; - jsSensorData["configFlag"] = boost::lexical_cast(arrRes[j][18]); + jsSensorData["configFlag"] = atoi(arrRes[j][18].c_str()); jsSensorData["startBrands"] = arrRes[j][19]; jsSensorData["stopBrands"] = arrRes[j][20]; - jsSensorData["featureInterVal"] = boost::lexical_cast(arrRes[j][21]); - jsSensorData["waveInterVal"] = boost::lexical_cast(arrRes[j][22]); - jsSensorData["samplingRate"] = boost::lexical_cast(arrRes[j][23]); - // jsSensorData["scope"] = boost::lexical_cast(arrRes[j][24]); - jsSensorData["range"] = boost::lexical_cast(arrRes[j][25]); + jsSensorData["featureInterVal"] = atoi(arrRes[j][21].c_str()); + jsSensorData["waveInterVal"] = atoi(arrRes[j][22].c_str()); + jsSensorData["samplingRate"] = atoi(arrRes[j][23].c_str()); + // jsSensorData["scope"] = atoi(arrRes[j][24]); + jsSensorData["range"] = atoi(arrRes[j][25].c_str()); jsSensorData["envelopeBandPass"] = arrRes[j][26]; jsSensorData["faultFrequency"] = arrRes[j][27]; jsSensorData["zigbeePanId"] = arrRes[j][28]; - jsSensorData["zigbeeChannel"] = boost::lexical_cast(arrRes[j][29]); + jsSensorData["zigbeeChannel"] = (arrRes[j][29]); jsSensorData["zigbeeAddr"] = arrRes[j][30]; jsSensorData["zigbeeLongAddr"] = arrRes[j][31]; jsSensorData["zigbeeDesAddr"] = arrRes[j][32]; - jsSensorData["ZigbeePower"] = boost::lexical_cast(arrRes[j][33]); - jsSensorData["ZigbeeRetry"] = boost::lexical_cast(arrRes[j][34]); - jsSensorData["ZigbeeRetryGap"] = boost::lexical_cast(arrRes[j][35]); - jsSensorData["ACCSampleTime"] = boost::lexical_cast(arrRes[j][36]); - jsSensorData["status"] = boost::lexical_cast(arrRes[j][37]); + jsSensorData["ZigbeePower"] = atoi(arrRes[j][33].c_str()); + jsSensorData["ZigbeeRetry"] = atoi(arrRes[j][34].c_str()); + jsSensorData["ZigbeeRetryGap"] = atoi(arrRes[j][35].c_str()); + jsSensorData["ACCSampleTime"] = atoi(arrRes[j][36].c_str()); + jsSensorData["status"] = atoi(arrRes[j][37].c_str()); jsSensorData["timeStamp"] = arrRes[j][38]; - jsSensorData["viff"] = boost::lexical_cast(arrRes[j][39]); - jsSensorData["RSSI"] = boost::lexical_cast(arrRes[j][40]); + jsSensorData["viff"] = atoi(arrRes[j][39].c_str()); + if(atof(looseValue) < atof(arrRes[j][42].c_str())){ + jsSensorData["loose"] = "1"; + }else{ + jsSensorData["loose"] = "0"; + } + + //获取最新zigbee信号 + char szTableName[50]={0x00},selectCon[128]={0x00}; + sprintf(szTableName,"t_dataStatic_%s",arrRes[j][0].c_str()); + memset(selectCon,0x00,sizeof(selectCon)); + sprintf(selectCon, "zigbeeSignal <> '' ORDER BY timeStamp desc LIMIT 0,1"); + string strZigbeeSignal = sql_ctl->GetData(szTableName, "zigbeeSignal", selectCon); + if(strZigbeeSignal == "") + jsSensorData["RSSI"] = arrRes[j][40]; + else + jsSensorData["RSSI"] = strZigbeeSignal; + jsSensorData["update"] = atoi(arrRes[j][41].c_str()); jsArray.append(jsSensorData); } } else { jsArray.resize(0); + jsonVal["success"] = true; } + jsonVal["gatewayMac"] = GlobalConfig::MacAddr_G ; + jsonVal["gatewayIP"] = GlobalConfig::IpAddr_G ; jsonVal["content"]["dataNodeArray"] = jsArray; return showValue.write(jsonVal); } @@ -859,6 +1381,13 @@ std::string JsonData::JsonCmd_Cgi_27(Param_27 ¶m) sql_ctl->DeleteTableData(T_SENSOR_INFO(TNAME), whereCon); sql_ctl->DeleteTableData(T_DATA_INFO(TNAME), whereCon); sql_ctl->DeleteTableData(T_DATASTATIC_INFO(TNAME), whereCon); + sql_ctl->DeleteTableData(T_DATANODE_TIME(TNAME), whereCon); + char szTableName[50]={0x00}; + sprintf(szTableName,"DROP TABLE t_data_%s",param.mDataNodeNo.c_str()); + sql_ctl->CreateTable(szTableName, 0); + memset(szTableName,0x00,sizeof(szTableName)); + sprintf(szTableName,"DROP TABLE t_dataStatic_%s",param.mDataNodeNo.c_str()); + sql_ctl->CreateTable(szTableName, 0); } else { jsonVal["success"] = false; jsonVal["message"] = "没有传感器号"; @@ -900,6 +1429,12 @@ std::string JsonData::JsonCmd_Cgi_29(Param_29 ¶m) jsonVal["dataNodeGatewayNo"] = GlobalConfig::MacAddr_G; jsonVal["success"] = true; jsonVal["message"] = " "; + std::vector vecWave; + /* 新增代码 */ + char whereCon[64] = {}; + sprintf(whereCon, "dataNodeNo='%s'",param.mDataNodeNo.c_str()); + vec_t res = sql_ctl->GetDataSingleLine(T_SENSOR_INFO(TNAME)," * ",whereCon); + char localtimestamp[32] = { 0 }; std::string strWaveData = ""; std::string filename = "/opt/data/" + param.mChannelId + ".dat"; if (access(filename.c_str(), 0) >= 0) { @@ -910,10 +1445,21 @@ std::string JsonData::JsonCmd_Cgi_29(Param_29 ¶m) jsonVal["message"] = "error"; } else { float fTemp = 0; - std::vector vecWave; + + //std::vector hanningWave; + inFile.read((char *)localtimestamp,sizeof(localtimestamp)); while (inFile.read((char *)&fTemp, sizeof(fTemp))) { vecWave.push_back(fTemp); } + //测试正弦波 + //pCalculation->GenerateSin(vecWave); + + //添加汉宁窗 + /*pCalculation->Hanning(vecWave, hanningWave); + for(int i = 0; i < vecWave.size();i++){ + vecWave[i] = (vecWave[i]*hanningWave[i]); + }*/ + int flag = param.mPackageFlag; flag = (flag + 1) * 1024; int number = vecWave.size(); @@ -952,8 +1498,18 @@ std::string JsonData::JsonCmd_Cgi_29(Param_29 ¶m) jsBody["channelId"] = param.mChannelId; jsBody["package"] = param.mPackageFlag; - jsBody["Data"] = strWaveData; + print_info("vecWave.size() = %d,sample = %d,second = %f\n",vecWave.size(),atoi(res[23].c_str()),float(vecWave.size()/atoi(res[23].c_str()))); + string::size_type comper = param.mChannelId.find("Z"); + if (comper != string::npos && res[17]=="02"){ + jsBody["second"] = float((float)vecWave.size()/(float)atoi(res[23].c_str())); + }else if(res[17]=="01"){ + jsBody["second"] = float((float)vecWave.size()/(float)atoi(res[23].c_str())); + }else{ + jsBody["second"] = 1; + } + jsBody["Data"] = strWaveData; + jsBody["timestamp"] = string(localtimestamp); jsonVal["content"] = jsBody; return showValue.write(jsonVal); @@ -961,52 +1517,7 @@ std::string JsonData::JsonCmd_Cgi_29(Param_29 ¶m) std::string JsonData::JsonCmd_Cgi_30(Param_30 ¶m) { - /*Json::Value jsonVal; - jsonVal.clear(); - jsonVal["cmd"] = "30"; - jsonVal["success"] = true; - jsonVal["message"] = ""; - Json::Value jsBody; - std::string strWaveData; - // if (GlobalConfig::WaveCgi.flag == 1) { - // int number = GlobalConfig::WaveCgi.number; - // char buf[32]; - // int flag = param.mPackageFlag; - // flag = (flag + 1) * 1024; - // int start = param.mPackageFlag * 1024; - // if ( number < 1024) { - // flag = number; - // start = 0; - // } - - // for (int i = start; i < flag; i++) { - // if ( i == start ) { - // strWaveData = (boost::lexical_cast(GlobalConfig::WaveCgi.waveData[i])).substr(0.4); - // } else { - // memset(buf, 0, 32); - // sprintf(buf, "%.2f", GlobalConfig::WaveCgi.waveData[i]); - // std::string waveTemp(buf); - // strWaveData = strWaveData + "," + waveTemp; - // } - // } - // int max = number / 1024; - // if (max == 0 && number > 0) { - // max = 1; - // } - // jsBody["packageMax"] = max; - // } else { - // jsonVal["success"] = false; - // jsonVal["message"] = "数据获取失败"; - // } - - - jsBody["channelId"] = param.mChannelId; - jsBody["package"] = param.mPackageFlag; - jsBody["Data"] = strWaveData; - - jsonVal["content"] = jsBody; - return showValue.write(jsonVal);*/ Json::Value jsonVal; Json::Value jsBody; Json::Value SystemSetting; @@ -1019,6 +1530,16 @@ std::string JsonData::JsonCmd_Cgi_30(Param_30 ¶m) int i = 0; std::string strWaveData; std::string filename = "/opt/data/" + param.mChannelId + ".dat"; + char localtimestamp[32] = { 0 }; + std::vector vecWave; + std::vector hanningWave; + std::vector addhanningWave; + std::vector fftWave; + int sampleRateReference = 0; + /* 新增代码 */ + char whereCon[64] = {}; + sprintf(whereCon, "dataNodeNo='%s'",param.mDataNodeNo.c_str()); + vec_t res = sql_ctl->GetDataSingleLine(T_SENSOR_INFO(TNAME)," * ",whereCon); if (access(filename.c_str(), 0) >= 0) { std::ifstream inFile(filename.c_str(),ios::in|ios::binary); @@ -1029,109 +1550,64 @@ std::string JsonData::JsonCmd_Cgi_30(Param_30 ¶m) jsonVal["message"] = "error"; }else{ float fTemp = 0; - std::vector vecWave; - std::vector fftWave; - while(inFile.read((char *)&fTemp,sizeof(fTemp))) - { // 取8K进行计算 - if(i < 8192) - { - vecWave.push_back(fTemp); - }else{ - break; + + + inFile.read((char *)localtimestamp,sizeof(localtimestamp)); + string::size_type comper = param.mChannelId.find("Z"); + if (comper != string::npos && res[17]=="02") { + while(inFile.read((char *)&fTemp,sizeof(fTemp))) + { + vecWave.push_back(fTemp); } - i++; - } - /*std::string strWaveData1 = ""; - char buff[32] = {0}; - for(int j=0;j %s,vecWave.size()=%d\n", strWaveData1.c_str(),vecWave.size());*/ - //进行傅立叶变换 - pCalculation->FFTSpec(vecWave, fftWave); - printf("2---------------------------------------------->%d\n",fftWave.size()); - printf("2---------------------------------------------->%f\n",fftWave[10]); - /*std::string strWaveData2 = ""; - char bufff[32] = {0}; - for(int k=0;kfftWave.size()=%d\n", fftWave.size()); - //print_info("after fft---------------------------------------------------> %s,fftWave.size()=%d\n", strWaveData2.c_str(),fftWave.size()); - /* int flag = param.mPackageFlag; - //print_info("*********************************param.mPackageFlag=%d\n",param.mPackageFlag); - flag = (flag + 1) * 1024; - int number = fftWave.size(); - int start = param.mPackageFlag * 1024; - if (number < 1024) - { - flag = number; - start = 0; - } - char buf[32] = {0}; - //print_info("start=%d,flag=%d\n",start,flag); - for (int i = start; i < flag; i++) - { - if (i == start) - { - memset(buf, 0, 32); - sprintf(buf, "%.2f", fftWave[i]); - std::string waveTemp(buf); - if (0 == i) + //进行傅立叶变换 + pCalculation->FFTSpec(vecWave, fftWave); + sampleRateReference = 1000; + + }else{ + while(inFile.read((char *)&fTemp,sizeof(fTemp))) + { // 取8K进行计算 + if(i < 8192) { - strWaveData = boost::lexical_cast(0); + vecWave.push_back(fTemp); }else{ - strWaveData = waveTemp; + break; } - }else{ - memset(buf, 0, 32); - sprintf(buf, "%.2f", fftWave[i]); - std::string waveTemp(buf); - strWaveData = strWaveData + "," + waveTemp; - } + i++; + } + //测试正弦波 + //pCalculation->GenerateSin(vecWave); + + if(vecWave.size() < 8192){ + for(int i = vecWave.size(); i < 8192;i++){ + vecWave.push_back(0); + } + } + //添加汉宁窗 + pCalculation->Hanning(vecWave, hanningWave); + for(int i = 0; i < vecWave.size();i++){ + addhanningWave.push_back(vecWave[i]*hanningWave[i]); + } + + //进行傅立叶变换 + pCalculation->FFTSpec(addhanningWave, fftWave); + sampleRateReference = 1024; } - //print_info("@strwavedata=%s@,strWaveData.sizeof=%d,fftWave.size()=%d\n",strWaveData.c_str(),strWaveData.size(),fftWave.size()); - int max = number / 1024; - //print_info("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&max=%d\n",max); - if (max == 0 && number > 0) - { - max = 1; - } - jsBody["packageMax"] = max; */ + /*for(int i = 0; i < fftWave.size();i++){ + fftWave[i] = fftWave[i]*2; + }*/ + printf("2---------------------------------------------->vecWave = %d,fftWave = %d\n",vecWave.size(),fftWave.size()); + int flag = param.mPackageFlag; - flag = (flag + 1) * 1024; + flag = (flag + 1) * sampleRateReference; int number = fftWave.size(); - int start = param.mPackageFlag * 1024; + printf("number---------------------------------------------->%d\n",number); + int start = param.mPackageFlag * sampleRateReference; printf("param.mPackageFlag = %d\n",param.mPackageFlag); printf("param.start = %d\n",start); printf("param.flag = %d\n",flag); - if (number < 1024) { - flag = number; - start = 0; + if (number < sampleRateReference) { + flag = number; + start = 0; } char buf[32]; for (int i = start; i < flag; i++) { @@ -1149,29 +1625,51 @@ std::string JsonData::JsonCmd_Cgi_30(Param_30 ¶m) } } - int max = number / 1024; + int max = number / sampleRateReference; if (max == 0 && number > 0) { - max = 1; + max = 1; } jsBody["packageMax"] = max; + + + } } else { - jsonVal["success"] = false; - jsonVal["message"] = "数据获取失败"; - } + jsonVal["success"] = false; + jsonVal["message"] = "没有数据文件"; + } jsBody["channelId"] = param.mChannelId; jsBody["package"] = param.mPackageFlag; + jsBody["timestamp"] = string(localtimestamp); jsBody["Data"] = strWaveData; - /* 新增代码 */ - char whereCon[64] = {}; - sprintf(whereCon, "dataNodeNo='%s'",param.mDataNodeNo.c_str()); - std::string sample_rate = sql_ctl->GetData(T_SENSOR_INFO(TNAME), T_SENSOR_INFO(SAMPLINGRATE), whereCon); - printf("@@@@@@@@@@@@@@@@@@@@sample_rate=%s\n",sample_rate.c_str()); - int SampleRate = boost::lexical_cast(sample_rate.c_str()); - double resolution = (double)SampleRate / 8192; - printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@the sample rate is %d,the resolution %f\n",SampleRate,resolution); + + + + double resolution = 0.0; + int SampleRate =0; + print_info("sensor type %s\n",res[17].c_str()); + if(res[17]=="01"){ + SampleRate = atoi(res[23].c_str()); + printf("@@@@@@@@@@@@@@@@@@@@sample_rate=%d\n",SampleRate); + resolution = (((double)SampleRate/1000)*1024)/ 8192; + + }else if(res[17]=="02"){ + string::size_type comper = param.mChannelId.find("Z"); + if (comper != string::npos) { + SampleRate = atoi(res[23].c_str()); + resolution = (double)SampleRate/vecWave.size(); + //resolution = (((double)vecWave.size()/1000)*1024)/ (SampleRate * ((vecWave.size()/SampleRate))); + printf("@@@@@@@@@@@@@@@@@@@@sample_rate=%d,resolution = %f\n",SampleRate,resolution); + }else{ + SampleRate = 8000; + printf("@@@@@@@@@@@@@@@@@@@@sample_rate=%d\n",SampleRate); + resolution = (((double)SampleRate/1024)*1024)/ 8192; + } + } + + print_info("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@the sample rate is %d,the resolution %f\n",SampleRate,resolution); char buf[32]; memset(buf, 0, 32); sprintf(buf, "%f", resolution); @@ -1180,6 +1678,253 @@ std::string JsonData::JsonCmd_Cgi_30(Param_30 ¶m) jsonVal["content"] = jsBody; return showValue.write(jsonVal); } +std::string JsonData::JsonCmd_Cgi_40(Param_40 ¶m) +{ + + Json::Value jsonVal; + Json::Value jsBody; + Json::Value SystemSetting; + jsonVal.clear(); + + jsonVal["cmd"] = "40"; + jsonVal["dataNodeGatewayNo"] = GlobalConfig::MacAddr_G; + jsonVal["success"] = true; + jsonVal["message"] = ""; + int i = 0; + int sampleRateReference = 0; + std::vector vecWave; + /* 新增代码 */ + char whereCon[64] = {}; + sprintf(whereCon, "dataNodeNo='%s'",param.mDataNodeNo.c_str()); + vec_t res = sql_ctl->GetDataSingleLine(T_SENSOR_INFO(TNAME)," * ",whereCon); + std::string strWaveData; + std::string filename = "/opt/data/" + param.mChannelId + ".dat"; + char localtimestamp[32] = { 0 }; + if (access(filename.c_str(), 0) >= 0) + { + std::ifstream inFile(filename.c_str(),ios::in|ios::binary); + if(!inFile) + { + print_error("read channel data error\n"); + jsonVal["success"] = "false"; + jsonVal["message"] = "error"; + }else{ + float fTemp = 0; + + std::vector envWave; + std::vector hanningWave; + std::vector addhanningWave; + inFile.read((char *)localtimestamp,sizeof(localtimestamp)); + string::size_type comper = param.mChannelId.find("Z"); + if (comper != string::npos && res[17]=="02") { + while(inFile.read((char *)&fTemp,sizeof(fTemp))) + { + vecWave.push_back(fTemp); + } + //添加汉宁窗 + pCalculation->Hanning(vecWave, hanningWave); + for(int i = 0; i < vecWave.size();i++){ + addhanningWave.push_back(vecWave[i]*hanningWave[i]); + } + + //进行傅立叶变换 + if(param.StartFrequency == 0){ + param.StartFrequency = 3000; + param.EndFrequency = 5000; + } + + pCalculation->envSpec(addhanningWave, envWave,param.StartFrequency,param.EndFrequency); + sampleRateReference = 1000; + + }else{ + while(inFile.read((char *)&fTemp,sizeof(fTemp))) + { // 取8K进行计算 + if(i < 8192) + { + vecWave.push_back(fTemp); + }else{ + break; + } + i++; + } + if(vecWave.size() < 8192){ + for(int i = vecWave.size(); i < 8192;i++){ + vecWave.push_back(0); + } + } + + //添加汉宁窗 + pCalculation->Hanning(vecWave, hanningWave); + for(int i = 0; i < vecWave.size();i++){ + addhanningWave.push_back(vecWave[i]*hanningWave[i]); + } + + //进行傅立叶变换 + if(param.StartFrequency == 0){ + param.StartFrequency = 3000; + param.EndFrequency = 5000; + } + + pCalculation->envSpec(addhanningWave, envWave,param.StartFrequency,param.EndFrequency); + sampleRateReference = 1024; + } + /*for(int i = 0; i < envWave.size();i++){ + envWave[i] = envWave[i]*2; + }*/ + + printf("2---------------------------------------------->%d\n",envWave.size()); + printf("2---------------------------------------------->%f\n",envWave[10]); + + print_info("after fft--------------------------------------------------->fftWave.size()=%d\n", envWave.size()); + + int flag = param.mPackageFlag; + flag = (flag + 1) * sampleRateReference; + int number = envWave.size(); + int start = param.mPackageFlag * sampleRateReference; + printf("param.mPackageFlag = %d\n",param.mPackageFlag); + printf("param.start = %d\n",start); + printf("param.flag = %d\n",flag); + if (number < sampleRateReference) { + flag = number; + start = 0; + } + char buf[32]; + for (int i = start; i < flag; i++) { + if ( i == start ) { + memset(buf, 0, 32); + sprintf(buf, "%.6f", envWave[i]); + std::string waveTemp(buf); + strWaveData = waveTemp; + + } else { + memset(buf, 0, 32); + sprintf(buf, "%.6f", envWave[i]); + std::string waveTemp(buf); + strWaveData = strWaveData + "," + waveTemp; + } + } + + int max = number / sampleRateReference; + if (max == 0 && number > 0) { + max = 1; + } + jsBody["packageMax"] = max; + + } + } else { + jsonVal["success"] = false; + jsonVal["message"] = "没有数据文件"; + } + + + jsBody["channelId"] = param.mChannelId; + jsBody["package"] = param.mPackageFlag; + jsBody["timestamp"] = string(localtimestamp); + jsBody["Data"] = strWaveData; + + double resolution = 0.0; + int SampleRate =0; + print_info("sensor type %s\n",res[17].c_str()); + if(res[17]=="01"){ + SampleRate = atoi(res[23].c_str()); + printf("@@@@@@@@@@@@@@@@@@@@sample_rate=%d\n",SampleRate); + resolution = (((double)SampleRate/1000)*1024)/ 8192; + }else if(res[17]=="02"){ + string::size_type comper = param.mChannelId.find("Z"); + if (comper != string::npos) { + SampleRate = atoi(res[23].c_str()); + + resolution = (double)SampleRate/vecWave.size(); + printf("@@@@@@@@@@@@@@@@@@@@sample_rate=%d,resolution = %f\n",SampleRate,resolution); + }else{ + SampleRate = 8000; + printf("@@@@@@@@@@@@@@@@@@@@sample_rate=%d\n",SampleRate); + resolution = (((double)SampleRate/1000)*1024)/ 8192; + } + } + + printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@the sample rate is %d,the resolution %f\n",SampleRate,resolution); + char buf[32]; + memset(buf, 0, 32); + sprintf(buf, "%f", resolution); + jsBody["resolution"] = std::string(buf); + + jsonVal["content"] = jsBody; + return showValue.write(jsonVal); +} +std::string JsonData::JsonCmd_Cgi_41(std::vector ¶m) +{ + Json::Value jsonVal; + jsonVal.clear(); + + jsonVal["cmd"] = "41"; + jsonVal["dataNodeGatewayNo"] = GlobalConfig::MacAddr_G; + jsonVal["success"] = true; + jsonVal["message"] = " "; + + char whereCon[1024] = {0}; + char updateSql[1024] = { 0 }; + //int WaveInteerVal = param.mwaveInterVal/param.mfeatureInterVal; + for(int i = 0; i < param.size();i++){ + sprintf(updateSql, "featureInterVal='%d',waveInterVal='%d',range='%d',samplingRate='%d',AccSampleTime = '%d',\ + startBrands = '%s',stopBrands = '%s',envelopeBandPass = '%s',viff = '%d',faultFrequency = '%s' ,UpdateFlag = 0", + param[i].mfeatureInterVal, param[i].mwaveInterVal,param[i].mrange,\ + param[i].msamplingRate,param[i].mAccSampleTime, param[i].mstartBrands.c_str(),\ + param[i].mstopBrands.c_str(),param[i].menvelopeBandPass.c_str(),param[i].mviff,param[i].mfaultFrequency.c_str()); + sprintf(whereCon, "dataNodeNo='%s'", param[i].mdataNodeNo.c_str()); + + int iRet = sql_ctl->UpdateTableData(T_SENSOR_INFO(TNAME), updateSql, whereCon); + memset(whereCon,0x00,sizeof(whereCon)); + memset(updateSql,0x00,sizeof(updateSql)); + if(iRet != 0) + jsonVal["success"] = false; + } + return showValue.write(jsonVal); +} +std::string JsonData::JsonCmd_Cgi_42(Param_42 ¶m) +{ + Json::Value jsonVal; + jsonVal.clear(); + jsonVal["cmd"] = "42"; + jsonVal["dataNodeGatewayNo"] = GlobalConfig::MacAddr_G; + jsonVal["success"] = true; + jsonVal["message"] = "上传成功!"; + char cmd[100]={0x00}; + strcpy(cmd,"rm -rf /tmp/cgic*"); + system(cmd); + if(param.fileName == "DataNode.tar"){ + string strcmd = "tar xvf /opt/"; + strcmd = strcmd + param.fileName; + strcmd = strcmd + " -C /opt/"; + print_info("strcmd = %s\n",strcmd.c_str()); + system(strcmd.c_str()); + }else if(param.fileName == "rfsbu.tar"){ + sleep(3); + print_info("strcmd = %s\n",param.fileName.c_str()); + system("/opt/opt.sh"); + }else if(param.fileName == "update.json"){ + print_info("strcmd = %s\n",param.fileName.c_str()); + + ReadStrConfig("/opt/update.json"); + }else if(param.fileName == "DataNode.csv"){ + print_info("strcmd = %s\n",param.fileName.c_str()); + + int iRet = UpdataDataNodeConfig("/opt/DataNode.csv"); + string str = to_string(iRet) + "个传感器更新成功"; + if(iRet < 0){ + jsonVal["success"] = false; + jsonVal["message"] = "更新失败!"; + }else{ + jsonVal["success"] = true; + jsonVal["message"] = str; + } + + }else { + jsonVal["success"] = false; + jsonVal["message"] = "文件名错误!"; + } + return showValue.write(jsonVal); +} std::string JsonData::JsonCmd_Cgi_31(Param_31 ¶m) { @@ -1202,6 +1947,8 @@ std::string JsonData::JsonCmd_Cgi_31(Param_31 ¶m) jsonVal["success"] = true; jsBody["channel"] = ReadStrByOpt(ZIGBEECONFIG, "Zigbee", "channel"); jsBody["panID"] = GlobalConfig::ZigbeeInfo_G.PanID; + jsBody["RetryNum"] = GlobalConfig::ZigbeeInfo_G.RetryNum; + jsBody["TranTimeout"] = GlobalConfig::ZigbeeInfo_G.TranTimeout; jsBody["status"] = "1"; jsonVal["content"] = jsBody; @@ -1368,5 +2115,167 @@ std::string JsonData::JsonCmd_Cgi_47(Param_47 ¶m) return showValue.write(jsonVal); } +std::string JsonData::JsonCmd_Cgi_50() +{ + Json::Value jsonVal; + jsonVal.clear(); + + jsonVal[JSON_FIELD_CMD] = "50"; + jsonVal["success"] = true; + jsonVal["message"] = ""; + + std::string strFileName = "",strSoftVersion = ""; + Json::Value root; + Json::Value jsBody; + Json::Reader reader; + std::vector value; + std::vector vecDataNodeUpdate; + DataNodeUpdate datanodeUpdate; + std::fstream is; + is.open("/opt/DataNode/config.json", std::ios::in); + if (reader.parse(is, root)) { + jsBody["sensor"] = root; + } + jsBody["GateWayVersion"] = ReadStrByOpt(SYSTEMINFOFILE, "Version", "GateWayVersion"); + jsBody["SystemVersion"] = ReadStrByOpt(SYSTEMINFOFILE, "Version", "SystemVersion"); + jsBody["WebVersion"] = ReadStrByOpt(SYSTEMINFOFILE, "Version", "WebVersion"); + jsonVal["content"] = jsBody; + return showValue.write(jsonVal); +} +std::string JsonData::JsonCmd_Cgi_51(Param_51 ¶m) +{ + Json::Value jsonVal; + jsonVal.clear(); + Json::Value jsBody; + jsonVal[JSON_FIELD_CMD] = "51"; + jsonVal["success"] = true; + jsonVal["message"] = ""; + + char whereCon[1024] = {0}; + char updateSql[1024] = { 0 }; + string gatewayLocation = ""; + + sprintf(updateSql, "gatewayLocation='%s'", + param.strGateWayLocation.c_str()); + sprintf(whereCon, "gatewayMAC='%s'", param.strGateWayMAC.c_str()); + if(param.mMode == 0){ + int iRet = sql_ctl->UpdateTableData(T_GATEWAY_INFO(TNAME), updateSql, whereCon); + if(iRet != 0) + jsonVal["success"] = false; + }else{ + gatewayLocation = sql_ctl->GetData(T_GATEWAY_INFO(TNAME) ,"gatewayLocation", NULL); + jsBody["gateWayLocation"] = gatewayLocation; + } + + + + jsonVal["content"] = jsBody; + + return showValue.write(jsonVal); +} +std::string JsonData::JsonCmd_Cgi_52(Param_52 ¶m) +{ + Json::Value jsonVal; + Json::Value jsBody; + + jsonVal.clear(); + jsonVal["cmd"] = "52"; + jsonVal["dataWatchNo"] = GlobalConfig::MacAddr_G; + jsonVal["cmdSerial"] = param.mCmdSerial; + jsonVal["success"] = true; + jsonVal["message"] = " "; + + if (0 == param.mMode) { // 扫描 + wifi::WPAClient wpa; + std::string netssid = wpa.GetNetSsid(); + std::vector vecSsid; + boost::split(vecSsid, netssid, boost::is_any_of("\n"), boost::token_compress_off); + jsBody["type"] = "SCAN"; + print_info("netssid : %s %d\n", netssid.c_str(), vecSsid.size()); + for (unsigned int i = 1; i < vecSsid.size() - 1; i++) { + std::vector data; + boost::split(data, vecSsid[i], boost::is_any_of("\t"), boost::token_compress_off); + Json::Value wifiInfo; + wifiInfo["bssid"] = data[0]; + wifiInfo["frequency"] = data[1]; + wifiInfo["signallevel"] = data[2]; + wifiInfo["secure"] = data[3]; + wifiInfo["ssid"] = data[4]; + jsBody["wifilist"].append(wifiInfo); + + } + } else if ( 1 == param.mMode) { // 设置 + print_info("set WiFi\n"); + wifi::WPAClient wpa; + jsBody["ssid"] = param.mSsid; + if (param.mPassWord.length() > 0) { + if (wpa.ConnectWiFi(param.mSsid.c_str(), param.mPassWord.c_str())) { + jsBody["status"] = true; + } else { + jsBody["status"] = false; + } + } else { + if (wpa.ConnectWiFiWithNoPassword(param.mSsid.c_str())) { + jsBody["status"] = true; + } else { + jsBody["status"] = false; + } + } + } else if ( 2 == param.mMode ) { // 获取 + wifi::WPAClient wpa; + std::string ssid = " "; + int rssi = 0; + ssid = wpa.GetCurrentSSID(); + rssi = wpa.GetWiFiRssi() ; + jsBody["ssid"] = ssid; + jsBody["rssi"] = rssi; + } else if ( 3 == param.mMode ) { + wifi::WPAClient wpa; + if (wpa.CleanWifi()) { + jsonVal["message"] = "wifi断开成功"; + } else { + jsonVal["message"] = "wifi断开失败"; + } + } + + jsonVal["content"] = jsBody; + return showValue.write(jsonVal); +} + +std::string JsonData::JsonCmd_Cgi_53(std::vector ¶m) +{ + Json::Value jsonVal; + jsonVal.clear(); + + jsonVal["cmd"] = "53"; + jsonVal["dataNodeGatewayNo"] = GlobalConfig::MacAddr_G; + jsonVal["success"] = true; + jsonVal["message"] = " "; + + char whereCon[1024] = {0}; + char updateSql[1024] = { 0 }; + for(int i = 0; i < param.size();i++){ + if(param[i].mUpdateKey2 == ""){ + sprintf(updateSql, "%s='%s',UpdateFlag = 0", + param[i].mUpdateKey.c_str(), param[i].mUpdateValue.c_str()); + }else if(param[i].mUpdateKey3 == "" && param[i].mUpdateKey2 != ""){ + sprintf(updateSql, "%s='%s',%s='%s',UpdateFlag = 0", + param[i].mUpdateKey.c_str(), param[i].mUpdateValue.c_str(),param[i].mUpdateKey2.c_str(), param[i].mUpdateValue2.c_str()); + }else if(param[i].mUpdateKey3 != "" && param[i].mUpdateKey2 != ""){ + sprintf(updateSql, "%s='%s',%s='%s',%s='%s',UpdateFlag = 0", + param[i].mUpdateKey.c_str(), param[i].mUpdateValue.c_str(),param[i].mUpdateKey2.c_str(), param[i].mUpdateValue2.c_str(),\ + param[i].mUpdateKey3.c_str(), param[i].mUpdateValue3.c_str()); + } + sprintf(whereCon, "dataNodeNo='%s'", param[i].mdataNodeNo.c_str()); + + int iRet = sql_ctl->UpdateTableData(T_SENSOR_INFO(TNAME), updateSql, whereCon); + memset(whereCon,0x00,sizeof(whereCon)); + memset(updateSql,0x00,sizeof(updateSql)); + if(iRet != 0) + jsonVal["success"] = false; + } + return showValue.write(jsonVal); +} + diff --git a/jsonparse/SH_JsonCmd.hpp b/jsonparse/SH_JsonCmd.hpp index 50b0013..bf0f541 100644 --- a/jsonparse/SH_JsonCmd.hpp +++ b/jsonparse/SH_JsonCmd.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -13,6 +14,7 @@ #include "../calculation/Calculation.hpp" #include "../uart/SH_Uart.hpp" #include "../datatransfer/SH_Datatrans.hpp" +#include "../wifi/wpa_client.h" class JsonData { @@ -26,8 +28,10 @@ public : std::string JsonCmd_26(Param_26 ¶m); std::string JsonCmd_27(Json::Value & recvBody); std::string JsonCmd_29(Param_29 ¶m); //系统配置信息 - std::string JsonCmd_50(Json::Value & recvBody); + std::string JsonCmd_50(Json::Value & recvBody); //download update file std::string JsonCmd_51(Json::Value & recvBody); + std::string JsonCmd_52();//upload static data + std::string JsonCmd_53(Json::Value & recvBody); void JsonCmd_38(Json::Value &recvBody); //获取原始数据 void JsonCmd_39(Json::Value &recvBody); //更新传感器程序 @@ -37,24 +41,34 @@ public : std::string JsonCmd_Cgi_07(); //获取系统内存温度硬盘等信息 std::string JsonCmd_07(); //获取系统内存温度硬盘等信息 std::string JsonCmd_Cgi_08(); //重启 - std::string JsonCmd_Cgi_09(); //实时数据获取 + std::string JsonCmd_Cgi_09(Param_09 ¶m); //实时数据获取 + std::string JsonCmd_Cgi_10(Param_10 ¶m); // + std::string JsonCmd_Cgi_11(Param_11 ¶m); // std::string JsonCmd_Cgi_20(Param_20 ¶m); //终端信息获取 std::string JsonCmd_Cgi_22(Param_22 ¶m); //时区配置 std::string JsonCmd_Cgi_23(Param_23 ¶m); //服务器配置 std::string JsonCmd_Cgi_25(Param_25 ¶m); //网口配置 - std::string JsonCmd_Cgi_26(); + std::string JsonCmd_Cgi_26(Param_26 ¶m); std::string JsonCmd_Cgi_27(Param_27 ¶m); std::string JsonCmd_Cgi_28(Param_28 ¶m); std::string JsonCmd_Cgi_29(Param_29 ¶m); //获取原始数据 std::string JsonCmd_Cgi_30(Param_30 ¶m); //获取频域数据 std::string JsonCmd_Cgi_31(Param_31 ¶m);//配置通信通道 std::string JsonCmd_Cgi_32(Param_32 ¶m); // + + std::string JsonCmd_Cgi_40(Param_40 ¶m); // + std::string JsonCmd_Cgi_41(std::vector ¶m); // + std::string JsonCmd_Cgi_42(Param_42 ¶m); //从web端更新程序 std::string JsonCmd_Cgi_43(); //检测网口状态 std::string JsonCmd_Cgi_45(Param_45 ¶m); //国家区域配置 std::string JsonCmd_Cgi_46(Param_46 ¶m); //升级固件 std::string JsonCmd_Cgi_47(Param_47 ¶m); //替换Logo + std::string JsonCmd_Cgi_50(); // + std::string JsonCmd_Cgi_51(Param_51 ¶m); // + std::string JsonCmd_Cgi_52(Param_52 ¶m); + std::string JsonCmd_Cgi_53(std::vector ¶m); std::string JsonCmd_Cgi_default(); private : diff --git a/localserver/SH_LocalServer.cpp b/localserver/SH_LocalServer.cpp index 23c608e..0c19294 100644 --- a/localserver/SH_LocalServer.cpp +++ b/localserver/SH_LocalServer.cpp @@ -21,26 +21,30 @@ void LocalServer::HandleFromServer(const char *pData_r, int pLen, const char *to } std::string data_r = (std::string)(pData_r); + LOG_INFO("MQTT recv base64 %s\n",data_r.c_str()); print_brown("pData base : %s \n", data_r.c_str()); char *base64_data = new char[data_r.length()]; memset(base64_data, 0, data_r.length()); Secure::instance()->Base64Decode(data_r.c_str(), (unsigned char*)base64_data); std::string pData = std::string(base64_data); delete[] base64_data; - + LOG_INFO("MQTT recv %s\n",pData.c_str()); print_brown("pData : %s \n", pData.c_str()); Json::Reader recvReader; Json::Value recvValue; Json::Value recvBody; if (recvReader.parse(pData, recvValue)) { - std::string cmdBody = recvValue["cmdBody"].asString(); - if (!recvReader.parse(cmdBody, recvBody)) { - print_error("recv body error"); - return; - } - // recvBody = recvValue["cmdBody"]; - std::string str = recvBody["timestamp"].asString(); - int cmdType = atoi(recvValue["cmd"].asString().c_str()); + int cmdType = atoi(recvValue["cmd"].asString().c_str()); + if(cmdType == 41){ + recvBody = recvValue["cmdBody"]; + }else{ + std::string cmdBody = recvValue["cmdBody"].asString(); + if (!recvReader.parse(cmdBody, recvBody)) { + print_error("recv body error"); + return; + } + } + switch (cmdType) { case 7:{ JsonData jd; @@ -53,8 +57,8 @@ void LocalServer::HandleFromServer(const char *pData_r, int pLen, const char *to Json::FastWriter fw; std::string strjson = fw.write(recvValue); data_publish(strjson.c_str(), GlobalConfig::Topic_G.mPubCmd.c_str()); - system("echo 1 > /CIDW/start"); - boost::this_thread::sleep(boost::posix_time::seconds(1)); + //system("echo 1 > /CIDW/start"); + sleep(1); system("reboot"); } break; @@ -65,9 +69,9 @@ void LocalServer::HandleFromServer(const char *pData_r, int pLen, const char *to return; }*/ std::string timestamp = recvBody["timestamp"].asString(); - unsigned long itimestamp = boost::lexical_cast(timestamp); + unsigned long itimestamp = atol(timestamp.c_str()); SetTime(itimestamp); - boost::this_thread::sleep(boost::posix_time::milliseconds(200)); + usleep(200); system("hwclock -w"); if (!recvValue["ZoneId"].isNull() && recvValue["ZoneId"].asString().length() > 0) { std::string zoneid = recvValue["ZoneId"].asString(); @@ -134,8 +138,8 @@ void LocalServer::HandleFromServer(const char *pData_r, int pLen, const char *to if (0 == type.compare("SET")) { param.mMode = 0; param.mServerIp = recvBody["localServerIpAddress"].asString(); - param.mPort = boost::lexical_cast(recvBody["localServerPort"].asInt()); - param.mCommMode = boost::lexical_cast(recvBody["CommMode"].asInt()); + param.mPort = to_string(recvBody["localServerPort"].asInt()); + param.mCommMode = to_string(recvBody["CommMode"].asInt()); } else { param.mMode = 1; } @@ -194,11 +198,49 @@ void LocalServer::HandleFromServer(const char *pData_r, int pLen, const char *to std::string data = jd.JsonCmd_50(recvBody); data_publish(data.c_str(), GlobalConfig::Topic_G.mPubCmd.c_str()); }break; + case 41:{ + + JsonData jd; + Param_41 param; + std::vector param41; + for(int i = 0; i < recvBody.size();i++){ + param.mdataNodeNo = recvBody[i]["dataNodeNo"].asString(); + param.mfeatureInterVal = recvBody[i]["featureInterVal"].asInt(); + param.mwaveInterVal = recvBody[i]["waveInterVal"].asInt(); + param.msamplingRate = recvBody[i]["samplingRate"].asInt(); + param.mrange = recvBody[i]["range"].asInt(); + param.mAccSampleTime = recvBody[i]["ACCSampleTime"].asInt(); + param.mstartBrands = recvBody[i]["startBrands"].asString(); + param.mstopBrands = recvBody[i]["stopBrands"].asString(); + param.menvelopeBandPass = recvBody[i]["envelopeBandPass"].asString(); + param.mviff = recvBody[i]["viff"].asInt(); + param.mfaultFrequency = recvBody[i]["faultFrequency"].asString(); + param41.push_back(param); + } + std::string data = jd.JsonCmd_Cgi_41(param41); + char whereCon[64] = { 0 }; + sprintf(whereCon, "dataNodeNo='%s'", param.mdataNodeNo.c_str()); + string strData = sql_ctl->GetNodeConfigureInfor(whereCon); + data_publish(strData.c_str(), GlobalConfig::Topic_G.mPubConfig.c_str()); + + } + break; case 51:{ JsonData jd; std::string data = jd.JsonCmd_51(recvBody); data_publish(data.c_str(), GlobalConfig::Topic_G.mPubCmd.c_str()); }break; + case 52:{ +// JsonData jd; +// std::string data = jd.JsonCmd_52(recvBody); +// data_publish(data.c_str(), GlobalConfig::Topic_G.mPubCmd.c_str()); + }break; + case 53:{ + JsonData jd; + std::string data = jd.JsonCmd_53(recvBody); + data_publish(data.c_str(), GlobalConfig::Topic_G.mPubCmd.c_str()); + } + break; default: // data_publish_local(pData.c_str(), GlobalConfig::Topic_G.mPubLocalCmd.c_str()); break; @@ -274,10 +316,33 @@ try{ break; case 9:{ JsonData jd; - std::string data = jd.JsonCmd_Cgi_09(); + Param_09 param; + param.mPackageFlag = recvBody["package"].asInt(); + std::string data = jd.JsonCmd_Cgi_09(param); return data; } break; + case 10:{ + JsonData jd; + Param_10 param; + param.strDataNode = recvBody["DataNode"].asString(); + param.strStatic = recvBody["Static"].asString(); + param.straxis = recvBody["Raxis"].asString(); + param.mPackageFlag = recvBody["package"].asInt(); + param.timeStart = recvBody["timeStart"].asString(); + param.timeEnd = recvBody["timeEnd"].asString(); + std::string data = jd.JsonCmd_Cgi_10(param); + return data; + } + break; + case 11:{ + JsonData jd; + Param_11 param; + param.DataNodeNo = recvBody["DataNode"].asString(); + std::string data = jd.JsonCmd_Cgi_11(param); + return data; + } + break; case 20:{ Param_20 param; std::string type = recvBody["type"].asString(); @@ -319,7 +384,10 @@ try{ param.mMode = 0; param.mServerIp = recvBody["SystemSettings"]["ServerIpAddress"].asString(); param.mPort = boost::lexical_cast(recvBody["SystemSettings"]["ServerPort"].asInt()); - param.mCommMode = boost::lexical_cast(recvBody["SystemSettings"]["CommMode"].asInt()); + param.mCommMode = recvBody["SystemSettings"]["CommMode"].asString(); + param.mUserName = recvBody["SystemSettings"]["UserName"].asString(); + param.mPassword = recvBody["SystemSettings"]["Password"].asString(); + param.mAPN = recvBody["SystemSettings"]["APN"].asString(); } else { param.mMode = 1; } @@ -332,11 +400,12 @@ try{ case 25:{ Param_25 param; std::string type = recvBody["type"].asString(); - if (0 == type.compare("SET")) { + if (0 == type.compare("SET")) { + param.mNet = recvBody["net"].asString(); param.mDnsName = recvBody["dnsName"].asString(); param.mGateway = recvBody["gateway"].asString(); param.mHostName = recvBody["hostName"].asString(); - param.mIp = recvBody["dataNodeGatewayIpAddress"].asString(); + param.mIp = recvBody["dataWatchIpAddress"].asString(); param.mSubnetMask = recvBody["subnetMask"].asString(); param.mNetworkPortStatus = recvBody["networkPortStatus"].asString(); param.mMode = 0; @@ -351,8 +420,10 @@ try{ break; case 26:{ JsonData jd; - std::string data = jd.JsonCmd_Cgi_26(); - printf("data = %s\n",data.c_str()); + Param_26 param; + param.mPackageFlag = recvBody["package"].asInt(); + std::string data = jd.JsonCmd_Cgi_26(param); + // print_info("data = %s\n",data.c_str()); return data; } break; @@ -415,6 +486,119 @@ try{ return data; } break; + case 40:{ + JsonData jd; + Param_40 param; + param.mChannelId = recvBody["channelId"].asString(); + param.mPackageFlag = recvBody["package"].asInt(); + param.mDataNodeNo = recvBody["dataNodeNo"].asString(); + param.StartFrequency = recvBody["StartFrequency"].asInt(); + param.EndFrequency = recvBody["EndFrequency"].asInt(); + std::string data = jd.JsonCmd_Cgi_40(param); + return data; + } + break; + case 41:{ + JsonData jd; + Param_41 param; + std::vector param41; + for(int i = 0; i < recvBody.size();i++){ + param.mdataNodeNo = recvBody[i]["dataNodeNo"].asString(); + param.mfeatureInterVal = recvBody[i]["featureInterVal"].asInt(); + param.mwaveInterVal = recvBody[i]["waveInterVal"].asInt(); + param.msamplingRate = recvBody[i]["samplingRate"].asInt(); + param.mrange = recvBody[i]["range"].asInt(); + param.mAccSampleTime = recvBody[i]["ACCSampleTime"].asInt(); + param.mstartBrands = recvBody[i]["startBrands"].asString(); + param.mstopBrands = recvBody[i]["stopBrands"].asString(); + param.menvelopeBandPass = recvBody[i]["envelopeBandPass"].asString(); + param.mviff = recvBody[i]["viff"].asInt(); + param.mfaultFrequency = recvBody[i]["faultFrequency"].asString(); + param41.push_back(param); + } + std::string data = jd.JsonCmd_Cgi_41(param41); + char whereCon[64] = { 0 }; + sprintf(whereCon, "dataNodeNo='%s'", param.mdataNodeNo.c_str()); + string strData = sql_ctl->GetNodeConfigureInfor(whereCon); + data_publish(strData.c_str(), GlobalConfig::Topic_G.mPubConfig.c_str()); + return data; + } + break; + case 42:{ + JsonData jd; + Param_42 param; + param.fileName = recvBody["fileName"].asString(); + std::string data = jd.JsonCmd_Cgi_42(param); + return data; + } + break; + case 50:{ + JsonData jd; + std::string data = jd.JsonCmd_Cgi_50(); + return data; + } + + break; + case 51:{ + JsonData jd; + Param_51 param; + std::string type = recvBody["type"].asString(); + if(0 == type.compare("SET")){ + param.mMode = 0; + param.strGateWayMAC = recvBody["gateWayNo"].asString(); + param.strGateWayLocation = recvBody["gateWayLocation"].asString(); + + }else{ + param.mMode = 1; + } + std::string data = jd.JsonCmd_Cgi_51(param); + return data; + } + break; + case 52:{ + Param_52 param; + param.mCmdSerial = recvValue["cmdSerial"].asString(); + std::string type = recvBody["type"].asString(); + if (0 == type.compare("SCAN")) { + param.mMode = 0; + } + if (0 == type.compare("SET")) { + param.mMode = 1; + param.mSsid = recvBody["ssid"].asString(); + param.mPassWord = recvBody["password"].asString(); + } + if (0 == type.compare("GET")) { + param.mMode = 2; + } + if (0 == type.compare("CLEAN")) { + param.mMode = 3; + } + JsonData jd; + std::string data = jd.JsonCmd_Cgi_52(param); + return data; + } + break; + case 53:{ + JsonData jd; + Param_53 param; + std::vector param53; + for(int i = 0; i < recvBody.size();i++){ + param.mdataNodeNo = recvBody[i]["dataNodeNo"].asString(); + param.mUpdateKey = recvBody[i]["updateKey"].asString(); + param.mUpdateValue = recvBody[i]["updateValue"].asString(); + param.mUpdateKey2 = recvBody[i]["updateKey2"].asString(); + param.mUpdateValue2 = recvBody[i]["updateValue2"].asString(); + param.mUpdateKey3 = recvBody[i]["updateKey3"].asString(); + param.mUpdateValue3 = recvBody[i]["updateValue3"].asString(); + param53.push_back(param); + } + std::string data = jd.JsonCmd_Cgi_53(param53); + char whereCon[64] = { 0 }; + sprintf(whereCon, "dataNodeNo='%s'", param.mdataNodeNo.c_str()); + string strData = sql_ctl->GetNodeConfigureInfor(whereCon); + data_publish(strData.c_str(), GlobalConfig::Topic_G.mPubConfig.c_str()); + return data; + }break; default: JsonData jd; std::string data = jd.JsonCmd_Cgi_default(); @@ -428,6 +612,6 @@ try{ jsVal["message"] = "未知错误"; Json::FastWriter fw; return fw.write(jsVal); -} +} } diff --git a/main.cpp b/main.cpp index 3a78adb..869ead7 100644 --- a/main.cpp +++ b/main.cpp @@ -42,29 +42,69 @@ int main(int argc, char *argv[]) // 初始化平台配置文件 platform->PlatFormInit(); + //启动 mqtt客户端 + boost::thread startMqtt(StartMqttClient); + startMqtt.detach(); + + + sql_ctl->InintGateway(); + sql_ctl->CalculateDip(); + sql_ctl->CalculateBattery(); + pUart->InitZigbee(); // UDP,接收客户端发来的组播消息,用于外接 QT 专家系统,屏蔽之 - boost::thread searchT(attrs,SearchThread); + boost::thread searchT(SearchThread); searchT.detach(); // 串口处理线程,用于与 ZigBee 模块通信,通过ZigBee无线通信技术与无线传感器通信 boost::thread uartReadTh(UartStart); uartReadTh.detach(); + boost::thread uartTestReadTh(TestUart); + uartReadTh.detach(); + + boost::thread InitModuleReadTh(InitModule); + InitModuleReadTh.detach(); + //boost::thread uartWatchDogReadTh(WatchDog); + //uartWatchDogReadTh.detach(); + // 休眠2秒,等待串口线程初始化完毕 - boost::this_thread::sleep(boost::posix_time::seconds(2)); + sleep(2); // 串口数据处理,读取传感器原始波形数据 boost::thread uartWaveReadTh(UartStartWave); uartWaveReadTh.detach(); - //启动 mqtt客户端 - boost::thread startMqtt(StartMqttClient); - startMqtt.detach(); + //启动 mqtt 心跳 boost::thread startHeart(HeartRep); startHeart.detach(); + //启动 mqtt 心跳 + boost::thread startRunLED(RunLED); + startRunLED.detach(); + +#ifdef NR5G_MODULE + print_info("NR5G_MODULE \n"); + //5G + boost::thread startCSQ(GetCSQ); + startCSQ.detach(); +#ifndef NR5G_MEIGE + boost::thread startDial(Dial5G); + startDial.detach(); +#endif +#endif + +#ifdef Q4G_MODULE + boost::thread startCSQ(GetCSQ); + startCSQ.detach(); + print_info("4G_MODULE \n"); + +#endif +#ifdef WIFI_MODULE + print_info("WiFi_MODULE \n"); +#endif + // 通过UDP接收数据 boost::thread StartConnectSys(attrs, StartUdpSys); StartConnectSys.detach(); @@ -81,13 +121,30 @@ int main(int argc, char *argv[]) boost::thread startTcpCgi(attrs,StartCgiServer); startTcpCgi.detach(); - //pUart->UpdateZigbeeInfoCtrl(); + + sleep(5); pUart->ZigbeeInit(); + sleep(1); pUart->UpdateZigbeeInfoCtrl(); - boost::this_thread::sleep(boost::posix_time::seconds(5)); + + bool status = Ping( GlobalConfig::ServerIP.c_str(), 10000); + print_info("===========status ======== %d\n",status); + + /* char * szRes = sql_ctl->GetDataChar(T_SENSOR_INFO(TNAME), "dataNodeName", "dataNodeNo = '074cfd0000158d00'"); + printf("szRes = %s\n",szRes); + for(int i = 0; i < 64;i++){ + printf("temp = %02x ",szRes[i]); + }*/ + + int fd = OpenWatchDog(); while (GlobalConfig::QuitFlag_G) { - boost::this_thread::sleep(boost::posix_time::seconds(20)); + + gpio_set(GlobalConfig::GPIO_G.hardWatchDog,1); + usleep(20000); + gpio_set(GlobalConfig::GPIO_G.hardWatchDog,0); + WriteWatchDog(fd); + sleep(20); // data_publish(senddata.c_str(), GlobalConfig::Topic_G.mPubData.c_str()); } diff --git a/mqttclient/SH_MqttClient.cpp b/mqttclient/SH_MqttClient.cpp index 98e6606..3737870 100644 --- a/mqttclient/SH_MqttClient.cpp +++ b/mqttclient/SH_MqttClient.cpp @@ -48,21 +48,31 @@ int data_publish(const char *str, const char *topic) { int iRet = -1; if(mosq != NULL){ - print_blue("data_publish: %s %s\n", str, topic); + //print_blue("data_publish: %s %s\n", str, topic); std::string strTopic = std::string(topic); - if (strTopic.find("cmd") != std::string::npos) { + if (strTopic.find("cmd") != std::string::npos || \ + strTopic.find("configureInfo") != std::string::npos ) { std::string pData = (std::string)str; char *base64_aes = new char[pData.length() * 2]; memset(base64_aes, 0, pData.length() * 2); Secure::instance()->Base64Encode((unsigned char*)pData.c_str(), base64_aes, pData.length()); iRet = mosquitto_publish(mosq, &mid_sent, topic, strlen(base64_aes), base64_aes, ud.topic_qos, false); - print_blue("data_publish: %s \n",base64_aes); + //char *base64_data = new char[pData.length() * 2]; + //memset(base64_data, 0, pData.length() *2); + //Secure::instance()->Base64Decode(base64_aes, (unsigned char*)base64_data); + //std::string pData = std::string(base64_data); + if(base64_aes != NULL) + delete[] base64_aes; // free(out); } else { iRet = mosquitto_publish(mosq, &mid_sent, topic, strlen(str), str, ud.topic_qos, false); } } + if(iRet != 0) + { + reconnect(); + } return iRet; } @@ -93,6 +103,10 @@ int disconnect() return mosquitto_disconnect(mosq); } +int reconnect() +{ + return mosquitto_reconnect(mosq); +} int start_client(const char *boardname, const char *gwid, const char* gwip, const char *gwver, const char *gwcode, std::string &salt) { char *id = NULL; @@ -123,11 +137,11 @@ int start_client(const char *boardname, const char *gwid, const char* gwip, cons signal(SIGPIPE, SIG_IGN); int reconnect = 0; if (my_connect_callback == NULL || my_message_callback == NULL || my_subscribe_callback == NULL || my_log_callback == NULL) { - printf("please call the register_collback function first.\n"); + print_info("please call the register_collback function first.\n"); return -1; } - + int qos = readIntValue( "config", "qos",(char*)GlobalConfig::Config_G.c_str()); mosquitto_lib_init();//使用mosquitto库函数前需进行初始化 memset(&mqttsdata, 0, sizeof(mqttsdata_t)); memcpy(mqttsdata.gwid, gwid, strlen(gwid)); @@ -142,19 +156,28 @@ int start_client(const char *boardname, const char *gwid, const char* gwip, cons host = localip; mqttsdata.port = GlobalConfig::ServerPort; port = GlobalConfig::ServerPort; - +#ifdef WIFI_MODULE + mqttsdata.qos = 0; +#else + mqttsdata.qos = qos; +#endif + print_info("mqttsdata.qos = %d\n",mqttsdata.qos); // std::string username = "root"; // std::string password = "xom!*283#@XHG"; - std::string username = "chaos"; - std::string password = "HSD272*#xkd"; + std::string username = ReadStrByOpt(SERVERCONFIG, "Server", "UserName"); + std::string password = ReadStrByOpt(SERVERCONFIG, "Server", "Password"); + if(username == "" || password == ""){ + username = "chaos"; + password = "HSD272*#xkd"; + } char userName[100]; sprintf(userName, "%s", username.c_str()); char passWord[100]; sprintf(passWord, "%s", password.c_str()); - + print_info("userName = %s , passWord = %s\n",userName,passWord); ud.username = userName; ud.password = passWord; @@ -162,6 +185,7 @@ int start_client(const char *boardname, const char *gwid, const char* gwip, cons ud.dataUrl = mqttsdata.dataUrl; ud.fsUrl = mqttsdata.fsUrl; will_qos = mqttsdata.qos; + ud.topic_qos = will_qos; ud.topic_count++; ud.topics = (char**)realloc(ud.topics, ud.topic_count*sizeof(char *)); if (ud.topics == NULL) { @@ -172,15 +196,15 @@ int start_client(const char *boardname, const char *gwid, const char* gwip, cons sprintf(req_topic, "dev/cidwcc"); ud.topics[ud.topic_count - 1] = req_topic; ud.verbose = 1; - fprintf(stderr, "topic = %s!!!!!!!!!!!\n", ud.topics[ud.topic_count - 1]); + //fprintf(stderr, "topic = %s!!!!!!!!!!!\n", ud.topics[ud.topic_count - 1]); memset(res_topic, 0, 100); sprintf(res_topic, "gw/will"); - printf("res_topic:%s\n", res_topic); + print_info("res_topic:%s\n", res_topic); will_topic = res_topic; ud.resp_topic = res_topic; sprintf(will_payload, "{\"cmd\":\"15\",\"gwID\":\"%s\"}", mqttsdata.gwid); will_payloadlen = strlen(will_payload); - printf("will_payload:%s,will_payloadlen:%ld\n", will_payload, will_payloadlen); + print_info("will_payload:%s,will_payloadlen:%ld\n", will_payload, will_payloadlen); if (clean_session == false && (id_prefix || !id)){ if (!ud.quiet) fprintf(stderr, "Error: You must provide a client id if you are using the -c option.\n"); return 1; @@ -230,7 +254,7 @@ int start_client(const char *boardname, const char *gwid, const char* gwip, cons id[MOSQ_MQTT_ID_MAX_LENGTH] = '\0'; } } - printf("id:%s\n", id); + print_info("id:%s\n", id); mosq = mosquitto_new(id, clean_session, &ud); if (!mosq){ switch (errno){ @@ -316,15 +340,17 @@ int start_client(const char *boardname, const char *gwid, const char* gwip, cons else{ rc = mosquitto_connect_bind(mosq, host, port, keepalive, bind_address); } - printf("host = %s port = %d rc = %d\n",host,port,rc); + print_info("host = %s port = %d rc = %d\n",host,port,rc); if (rc){ if (!ud.quiet){ if (rc == MOSQ_ERR_ERRNO){ - strerror_r(errno, err, 1024); - fprintf(stderr, "Error_: %s\n", err); + //strerror_r(errno, err, 1024); + //fprintf(stderr, "Error_: %s\n", err); + //print_info("%s",stderr); } else{ fprintf(stderr, "Unable to connect (%d).\n", rc); + print_info("%s",stderr); } } goto mosq_free; @@ -332,7 +358,8 @@ int start_client(const char *boardname, const char *gwid, const char* gwip, cons rc = mosquitto_loop_forever(mosq, -1, 1); if (rc) { - fprintf(stderr, "Error: %s\n", mosquitto_strerror(rc)); + //fprintf(stderr, "Error: %s\n", mosquitto_strerror(rc)); + //print_info("%s",stderr); } mosq_free: mosquitto_destroy(mosq); diff --git a/mqttclient/SH_MqttClient.h b/mqttclient/SH_MqttClient.h index 89cb9aa..d080fc9 100644 --- a/mqttclient/SH_MqttClient.h +++ b/mqttclient/SH_MqttClient.h @@ -61,6 +61,7 @@ extern void register_collback(connect_callback connect_c, extern int data_publish(const char *str, const char* topic); extern int data_publish_wave(WAVE_CONTAIN *str, const char *topic); extern int disconnect(); +extern int reconnect(); extern int subscribe(const char* topic, int qos); extern int unsubscribe(const char* topic); extern int start_client(const char *boardname, const char *gwid, const char* gwip, const char *gwver, const char *gwcode, std::string &salt); diff --git a/platform/SH_PlatformInit.cpp b/platform/SH_PlatformInit.cpp index 41be7df..f8a207f 100644 --- a/platform/SH_PlatformInit.cpp +++ b/platform/SH_PlatformInit.cpp @@ -9,20 +9,28 @@ int GlobalConfig::RUN_MODE = 0; int GlobalConfig::QuitFlag_G = 1; int GlobalConfig::LinkStatus_G = 0; int GlobalConfig::LinkCount = 0; +int GlobalConfig::net0Status = 1; - -std::string GlobalConfig::Version = "2.0.11"; +std::string GlobalConfig::Version = "3.0"; std::string GlobalConfig::MacAddr_G = ""; +std::string GlobalConfig::MacAddr_G2 = ""; std::string GlobalConfig::IpAddr_G = ""; std::string GlobalConfig::ServerIP = ""; +std::string GlobalConfig::NetStatus = ""; +std::string GlobalConfig::NetType = ""; +std::string GlobalConfig::NR5GTemp = ""; +int GlobalConfig::serverStatus = 0; +int GlobalConfig::NetSignal = 0; int GlobalConfig::ServerPort = 0; TopicList GlobalConfig::Topic_G; ZigbeeInfo GlobalConfig::ZigbeeInfo_G; ZIGBEE GlobalConfig::Zigbee_G; +GPIOInfo GlobalConfig::GPIO_G; std::string GlobalConfig::DbName_G = "/opt/configenv/cidn.db"; //数据库名称 +std::string GlobalConfig::Config_G = "/opt/configenv/config.ini"; std::string GlobalConfig::UartName_G = "/dev/ttymxc4"; // 处理ZigBee网络接收过程的PanID切换 @@ -41,16 +49,57 @@ PlatformInit::~PlatformInit() void PlatformInit::PlatFormInit() { try{ - GlobalConfig::MacAddr_G = GetLocalMac(); + GlobalConfig::MacAddr_G = GetLocalMac("eth0"); + GlobalConfig::MacAddr_G2 = GetLocalMac("eth1"); transform(GlobalConfig::MacAddr_G.begin(), GlobalConfig::MacAddr_G.end(), GlobalConfig::MacAddr_G.begin(), ::toupper); + transform(GlobalConfig::MacAddr_G2.begin(), GlobalConfig::MacAddr_G2.end(), GlobalConfig::MacAddr_G2.begin(), ::toupper); GlobalConfig::IpAddr_G = IpAddrInit(); print_info("GlobalConfig::IpAddr_G : %s\n", GlobalConfig::IpAddr_G.c_str()); this->ConfigFileCheck(); + print_info("ConfigFileCheck\n"); this->TopicInit(); + print_info("TopicInit\n"); this->ServerIpInit(); + print_info("TopicInit\n"); this->Sqlite3Init(); - + this->GPIOInit(); + print_info("ServerIP : %s \n", GlobalConfig::ServerIP.c_str()); + std::string strMac = sql_ctl->GetData("t_gateway_info","gatewayMAC",NULL); + if(strMac == "60294D208517"){ + char szUpdateSql[100]={0x00}; + sprintf(szUpdateSql,"gatewayMAC = '%s'",GlobalConfig::MacAddr_G.c_str()); + sql_ctl->UpdateTableData("t_gateway_info",szUpdateSql,NULL); + } + else if(strMac != GlobalConfig::MacAddr_G ){ + LOG_ERROR("MAC error strMac1 = %s,MacAddr_G1 = %s\n",strMac.c_str(),GlobalConfig::MacAddr_G.c_str()); + strMac.insert(2,":"); + strMac.insert(5,":"); + strMac.insert(8,":"); + strMac.insert(11,":"); + strMac.insert(14,":"); + ModifyMac((char*)strMac.c_str()); + //system("reboot"); + } +#ifdef G2UL_GATEWAY + std::string strMac2 = sql_ctl->GetData("t_gateway_info","MAC2",NULL); + if(strMac2 == "60294D208518"){ + char szUpdateSql[100]={0x00}; + sprintf(szUpdateSql,"MAC2 = '%s'",GlobalConfig::MacAddr_G2.c_str()); + sql_ctl->UpdateTableData("t_gateway_info",szUpdateSql,NULL); + } + else if(strMac2 != GlobalConfig::MacAddr_G2 ){ + LOG_ERROR("MAC error strMac2 = %s,MacAddr_G2 = %s\n",strMac2.c_str(),GlobalConfig::MacAddr_G2.c_str()); + strMac2.insert(2,":"); + strMac2.insert(5,":"); + strMac2.insert(8,":"); + strMac2.insert(11,":"); + strMac2.insert(14,":"); + ModifyMac((char*)strMac2.c_str()); + //system("reboot"); + } +#endif + // sleep(10); } catch(...){ print_error("PlatFormInit exception happend.\n"); @@ -66,7 +115,7 @@ void PlatformInit::TopicInit() GlobalConfig::Topic_G.mPubHeart = "wireless/heart/" + GlobalConfig::MacAddr_G;// - GlobalConfig::Topic_G.mPubConfig = "wireless/configureInfor/" + GlobalConfig::MacAddr_G; + GlobalConfig::Topic_G.mPubConfig = "wireless/configureInfo/" + GlobalConfig::MacAddr_G; GlobalConfig::Topic_G.mPubWaveData = "wireless/realTimeData/" + GlobalConfig::MacAddr_G; @@ -78,6 +127,8 @@ void PlatformInit::TopicInit() GlobalConfig::Topic_G.mPubRep = "wireless/resp/" + GlobalConfig::MacAddr_G; + GlobalConfig::Topic_G.mPubTiming = "equipment/cmd/" + GlobalConfig::MacAddr_G; + GlobalConfig::Topic_G.mPubLocalWifi = "up/" + GlobalConfig::MacAddr_G + "/recive/wifi"; @@ -128,7 +179,7 @@ int PlatformInit::ServerIpInit() { if (access(SERVERCONFIG, 0) >= 0) { GlobalConfig::ServerIP = ReadStrByOpt(SERVERCONFIG, "Server", "localServerIpAddress"); - GlobalConfig::ServerPort = boost::lexical_cast(ReadStrByOpt(SERVERCONFIG, "Server", "localServerPort")); + GlobalConfig::ServerPort = atoi(ReadStrByOpt(SERVERCONFIG, "Server", "localServerPort").c_str()); } } @@ -136,10 +187,43 @@ int PlatformInit::ServerIpInit() void PlatformInit::Sqlite3Init() { sql_ctl->OpenDB(GlobalConfig::DbName_G.c_str()); + char szValue[10] = {0x00}; + int nType = readIntValue( "Update", "type",(char*)GlobalConfig::Config_G.c_str()); + if(nType== 1){ + sql_ctl->SqliteInitDel(GlobalConfig::DbName_G.c_str()); + writeIntValue("Update", "type",0,(char*)GlobalConfig::Config_G.c_str()); + } + print_info("szValue = %d\n",nType); sql_ctl->SqliteInit(GlobalConfig::DbName_G.c_str()); print_info("Sqlite3Init \n"); } +void PlatformInit::GPIOInit() +{ +#ifdef G2UL_GATEWAY + GlobalConfig::GPIO_G.zigAckrep = 507; + GlobalConfig::GPIO_G.zigAckreset = 499; + GlobalConfig::GPIO_G.zigReset = 496; + GlobalConfig::GPIO_G.commPower = 363; + GlobalConfig::GPIO_G.vol3_8 = 498; + GlobalConfig::GPIO_G.commRest = 466; + GlobalConfig::GPIO_G.wifiPower = 488; + GlobalConfig::GPIO_G.wifiReset = 474; + GlobalConfig::GPIO_G.hardWatchDog = 497; + GlobalConfig::GPIO_G.zigDef = 408; + GlobalConfig::GPIO_G.runLed = 409; + GlobalConfig::GPIO_G.errorLed = 410; + GlobalConfig::GPIO_G.netResetNet0 = 489; +#else if IMX6UL_GATEWAY + GlobalConfig::GPIO_G.zigAckrep = 119; + GlobalConfig::GPIO_G.zigAckreset = 120; + GlobalConfig::GPIO_G.zigReset = 116; + GlobalConfig::GPIO_G.wifiReset = 8; + GlobalConfig::GPIO_G.commRest = 8; + GlobalConfig::GPIO_G.power = 9; + GlobalConfig::GPIO_G.errorLed = 130; +#endif +} void PlatformInit::SystemInfoInit() { std::ifstream ifileOut(SYSTEMINFOFILE); @@ -182,14 +266,14 @@ void PlatformInit::UserInit() } } -void PlatformInit::EquipIpInit() +void PlatformInit::EquipIpInit(std::string eth) { //eth0 初始化 int flag = 0; - std::string networkPortStatus = ReadStrByOpt(NETWORKCONFIG, "Net", "networkPortStatus"); - std::string subnetMask = ReadStrByOpt(NETWORKCONFIG, "Net", "subnetMask"); - std::string gateway = ReadStrByOpt(NETWORKCONFIG, "Net", "gateway"); - std::string dataWatchIpAddress = ReadStrByOpt(NETWORKCONFIG, "Net", "ipAddress"); + std::string networkPortStatus = ReadStrByOpt(NETWORKCONFIG, eth, "networkPortStatus"); + std::string subnetMask = ReadStrByOpt(NETWORKCONFIG, eth, "subnetMask"); + std::string gateway = ReadStrByOpt(NETWORKCONFIG, eth, "gateway"); + std::string dataWatchIpAddress = ReadStrByOpt(NETWORKCONFIG, eth, "ipAddress"); std::string strStatus = GetFileContent(NETWORK, 18); print_red("strStatus:%s\n networkPortStatus:%s dataWatchIpAddress:%s subnetMask:%s gateway:%s\n",strStatus.c_str(),networkPortStatus.c_str(),dataWatchIpAddress.c_str(),subnetMask.c_str(),gateway.c_str()); @@ -197,18 +281,31 @@ void PlatformInit::EquipIpInit() { print_white("dhcp config\n"); std::string cmd = ""; +#ifdef IMX6UL_GATEWAY system("sed -i '17c auto eth0' /etc/network/interfaces"); system("sed -i '18c iface eth0 inet dhcp' /etc/network/interfaces"); system("sed -i '20c ' /etc/network/interfaces"); system("sed -i '21c ' /etc/network/interfaces"); system("sed -i '22c ' /etc/network/interfaces"); +#endif +#ifdef G2UL_GATEWAY + if(eth == "eth0"){ + system("sed -i '5c DHCP=ipv4' /etc/systemd/network/static/10-eth0-static.network"); + system("sed -i '6c ' /etc/systemd/network/static/10-eth0-static.network"); + system("sed -i '7c ' /etc/systemd/network/static/10-eth0-static.network"); + }else if(eth == "eth1"){ + system("sed -i '5c DHCP=ipv4' /etc/systemd/network/dynamic/20-eth1-dynamic.network"); + system("sed -i '6c ' /etc/systemd/network/dynamic/20-eth1-dynamic.network"); + system("sed -i '7c ' /etc/systemd/network/dynamic/20-eth1-dynamic.network"); + } +#endif flag = 0; } if(0 == networkPortStatus.compare("STATIC")) { std::string cmd = ""; print_red("static config\n"); - +#ifdef IMX6UL_GATEWAY system("sed -i '18c iface eth0 inet static' /etc/network/interfaces"); if(dataWatchIpAddress.length() > 0) { @@ -236,15 +333,34 @@ void PlatformInit::EquipIpInit() } system(cmd.c_str()); cmd.clear(); +#endif +#ifdef G2UL_GATEWAY + if(eth == "eth0"){ + cmd = "sed -i '5c Address=" + dataWatchIpAddress + "' /etc/systemd/network/static/10-eth0-static.network"; + system(cmd.c_str()); + cmd = "sed -i '6c Netmask=" + subnetMask + "' /etc/systemd/network/static/10-eth0-static.network"; + system(cmd.c_str()); + cmd = "sed -i '7c Gateway=" + gateway + "' /etc/systemd/network/static/10-eth0-static.network"; + system(cmd.c_str()); + }else if(eth == "eth1"){ + cmd = "sed -i '5c Address=" + dataWatchIpAddress + "' /etc/systemd/network/dynamic/20-eth1-dynamic.network"; + system(cmd.c_str()); + cmd = "sed -i '6c Netmask=" + subnetMask + "' /etc/systemd/network/dynamic/20-eth1-dynamic.network"; + system(cmd.c_str()); + cmd = "sed -i '7c Gateway=" + gateway + "' /etc/systemd/network/dynamic/20-eth1-dynamic.network"; + system(cmd.c_str()); + } +#endif flag = 1; } - - if(1 == flag){ //静态直接更新 - system("source /etc/config.sh"); - } - if(0 == flag) //动态重新启动获取 - { - system("reboot"); - } +#ifdef IMX6UL_GATEWAY + + + system("reboot"); + +#endif +#ifdef G2UL_GATEWAY + system("systemctl restart systemd-networkd.service"); +#endif } diff --git a/platform/SH_PlatformInit.hpp b/platform/SH_PlatformInit.hpp index 3d2c04d..0734532 100644 --- a/platform/SH_PlatformInit.hpp +++ b/platform/SH_PlatformInit.hpp @@ -52,7 +52,9 @@ public : /** *@eth0 初始化 */ - void EquipIpInit(); + void EquipIpInit(std::string eth); + + void GPIOInit(); private: /** diff --git a/searchdev/SH_SearchDev.cpp b/searchdev/SH_SearchDev.cpp index c6a92d9..ea4e66d 100644 --- a/searchdev/SH_SearchDev.cpp +++ b/searchdev/SH_SearchDev.cpp @@ -107,7 +107,7 @@ void SearchDev::HandleRecv_1(const boost::system::error_code &pEc,size_t pBytesR std::string status = jsData["status"].asString(); if(status.compare("REQ") == 0) { jsData["dataWatchNo"] = GlobalConfig::MacAddr_G.c_str(); - jsData["localServerIpAddress"] = GlobalConfig::ServerIP; + jsData["localServerIpAddress"] = GlobalConfig::IpAddr_G; jsData["status"] = "ACK"; jsData["DeviceType"] = "WirelessGateWay"; std::string strData = fw.write(jsData); @@ -122,6 +122,8 @@ void SearchDev::HandleRecv_1(const boost::system::error_code &pEc,size_t pBytesR default: break; } + }else{ + print_error("parse error\n"); } MultiCastRecv_1(); } else { diff --git a/serial/serial.c b/serial/serial.c new file mode 100644 index 0000000..3f9102c --- /dev/null +++ b/serial/serial.c @@ -0,0 +1,503 @@ +/* + * A library for Linux serial communication + * + * Author: JoStudio, 2016 + * + * Version: 0.5 + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "serial.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef CMSPAR +#define CMSPAR 010000000000 +#endif + + + +/* + * convert baud_rate to speed_t + */ +static speed_t get_speed(unsigned int baud_rate) +{ + switch (baud_rate) { + case 0: + return B0; + case 50: + return B50; + case 75: + return B75; + case 110: + return B110; + case 150: + return B150; + case 200: + return B200; + case 300: + return B300; + case 600: + return B600; + case 1200: + return B1200; + case 1800: + return B1800; + case 2400: + return B2400; + case 4800: + return B4800; + case 9600: + return B9600; + case 19200: + return B19200; + case 38400: + return B38400; + case 57600: + return B57600; + case 115200: + return B115200; + case 230400: + return B230400; + case 460800: + return B460800; + case 500000: + return B500000; + case 576000: + return B576000; + case 921600: + return B921600; + case 1000000: + return B1000000; + case 1152000: + return B1152000; + case 1500000: + return B1500000; + case 2000000: + return B2000000; + case 2500000: + return B2500000; + case 3000000: + return B3000000; + case 3500000: + return B3500000; + case 4000000: + return B4000000; + default: + //unsupported baud rate + return 0; + } +} + + +/** + * set baud rate of serial port + * + * @param file_descriptor file descriptor of serial device + * @param baud_rate baud rate + * + * @return 1 if success + * return negative error code if fail + */ +int serial_set_baud_rate(int file_descriptor, int baud_rate) { +/* struct termios termio; + speed_t speed; + int fd = file_descriptor; + + if ( fd < 0 ) { + return SERIAL_INVALID_FILE; + } + + memset(&termio, 0, sizeof(termio)); + + //get old attribute + if (tcgetattr(fd, &termio)) { + return SERIAL_INVALID_RESOURCE; + } + + //calculate baud rate + speed = get_speed(baud_rate); + if (speed == 0) { + return SERIAL_ERROR_BAUDRATE; + } + cfsetispeed(&termio, speed); + cfsetospeed(&termio, speed); + + // set baud rate + if (tcsetattr(fd, TCSAFLUSH, &termio) < 0) { + return SERIAL_ERROR_BAUDRATE; + }*/ + int iFd = file_descriptor; + int len,ret; + struct termios opt; + tcgetattr(iFd, &opt); + cfsetispeed(&opt, B115200); + cfsetospeed(&opt, B115200); + if (tcgetattr(iFd, &opt)<0) { + return -1; + } + opt.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG); + opt.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON); + opt.c_oflag &= ~(OPOST); + opt.c_cflag &= ~(CSIZE | PARENB | CBAUD); + opt.c_cflag |= (CS8 | B115200); + opt.c_cc[VMIN] = 255; + opt.c_cc[VTIME] = 5; + if (tcsetattr(iFd, TCSANOW, &opt)<0) { + return -1; + } + tcflush(iFd,TCIOFLUSH); + + return 1; +} + + +/** + * set serial attributes + * + * @param file_descriptor file descriptor of serial device + * @param flow_ctrl + * @param data_bits how many bits per data, could be 7, 8, 5 + * @param parity which parity method, could be PARITY_NONE, PARITY_ODD, PARITY_EVEN + * @param stop_bits how many stop bits + * + * @return 1 if success. + * return negative error code if fail. + */ +int serial_set_attr(int file_descriptor, int data_bits, char parity, int stop_bits, int flow_ctrl) +{ + struct termios termio; + int fd = file_descriptor; + + if ( fd < 0 ) { + return SERIAL_INVALID_FILE; + } + + memset(&termio, 0, sizeof(termio)); + + if (tcgetattr(fd, &termio)) { + return SERIAL_INVALID_RESOURCE; + } + + //set flow control + switch(flow_ctrl) { + case FLOW_CONTROL_NONE : + termio.c_cflag &= ~CRTSCTS; + break; + case FLOW_CONTROL_HARDWARE : + termio.c_cflag |= CRTSCTS; + break; + case FLOW_CONTROL_SOFTWARE : + termio.c_cflag |= IXON | IXOFF | IXANY; + break; + } + + //set data bit + termio.c_cflag &= ~CSIZE; + switch (data_bits) { + case 8: + termio.c_cflag |= CS8; + break; + case 7: + termio.c_cflag |= CS7; + break; + case 6: + termio.c_cflag |= CS6; + break; + case 5: + termio.c_cflag |= CS5; + break; + default: + termio.c_cflag |= CS8; + break; + } + + //set stop bits + switch (stop_bits) { + case 1: + termio.c_cflag &= ~CSTOPB; + break; + case 2: + termio.c_cflag |= CSTOPB; + break; + default: + break; + } + + //set parity bit + switch (parity) { + case PARITY_NONE: + termio.c_cflag &= ~(PARENB | PARODD); + break; + case PARITY_EVEN: + termio.c_cflag |= PARENB; + termio.c_cflag &= ~PARODD; + break; + case PARITY_ODD: + termio.c_cflag |= PARENB | PARODD; + break; + case PARITY_MARK: + termio.c_cflag |= PARENB | CMSPAR | PARODD; + break; + case PARITY_SPACE: + termio.c_cflag |= PARENB | CMSPAR; + termio.c_cflag &= ~PARODD; + break; + } + + if (tcsetattr(fd, TCSAFLUSH, &termio) < 0) { + return SERIAL_ERROR_SETTING; + } + + return 1; +} + + +/** + * open serial port + * + * @param device_filename device file name, such as "/dev/ttyS0" + * @param baund_rate could be 57600, 38400, 19200, 9600, 4800, 2400, 1200, 300 + * + * @return file descriptor which could be used in read() or write() + * return -1 if failed, and errno is set + */ +int serial_open_file(char *device_filename, int baud_rate) { + int fd; + struct termios termio; + + if ((fd = open(device_filename, O_RDWR | O_NOCTTY )) == -1) { + return -1; + } + + memset(&termio, 0, sizeof(termio)); + + // setup the tty and the selected baud rate + // get current modes + if (tcgetattr(fd, &termio)) { + close(fd); + return -1; + } + + // setup initial mode: 8 bit data, No parity, 1 stop bit, no echo, no flow control + cfmakeraw(&termio); + if (tcsetattr(fd, TCSAFLUSH, &termio) < 0) { + close(fd); + return -1; + } + + if (serial_set_baud_rate(fd, baud_rate) != 1) { + close(fd); + return -1; + } + + return fd; +} + +/** + * open serial port + * + * @param file_descriptor file descriptor of serial device + * @param timeout timeout in second + * + * @return 1 if success + * return negative error code if fail + */ +int serial_set_timeout(int file_descriptor, int timeout) +{ + int fd = file_descriptor; + struct termios termio; + + if (fd < 0) { + return SERIAL_INVALID_FILE; + } + + + // get current attributes + if (tcgetattr(fd, &termio)) { + return SERIAL_INVALID_RESOURCE; + } + + //set read timeout + if (timeout > 0) { + timeout = timeout / 100; + if (timeout == 0) + timeout = 1; + } + termio.c_lflag &= ~ICANON; /* Set non-canonical mode */ + termio.c_cc[VTIME] = timeout; /* Set timeout in tenth seconds */ + if (tcsetattr(fd, TCSANOW, &termio) < 0) { + return SERIAL_ERROR_SETTING; + } + + return 1; +} + + +/** + * open serial port + * + * @param port number of port, could be 0, 1 ... , the device file is /dev/ttyS0, /dev/ttyS1 respectively + * @param baund_rate could be 57600, 38400, 19200, 9600, 4800, 2400, 1200, 300 + * + * @return file descriptor which could be used in read() or write() + * return -1 if failed, and errno is set + */ +int serial_open(char* port, int baud_rate) { + char buf[128]; + + snprintf(buf, sizeof(buf), "/dev/ttyS%d", port); + return serial_open_file(port, baud_rate); +} + + +/** + * close serial port + * + * @param file_descriptor file descriptor of serial port device file + * + * @return 0 if success. + * return -1 if failed, and errno is set. + */ +int serial_close(int file_descriptor) { + return close(file_descriptor); +} + + +/** + * The function waits until all queued output to the terminal filedes has been transmitted. + * + * tcdrain() is called. + + * @param file_descriptor file descriptor of serial port device file + * + * @return 0 if success. + * return -1 if fail, and errno is set. + */ +int serial_flush(int file_descriptor) +{ + return tcdrain(file_descriptor); +} + +/** + * whether data is available + * + * @param file_descriptor file descriptor of serial port device file + * @param timeout_millisec timeout in millisecond + * + * @return 1 if data is available + * return 0 if data is not available + */ +int serial_data_available(int file_descriptor, unsigned int timeout_millisec) +{ + int fd = file_descriptor; + struct timeval timeout; + fd_set readfds; + + if (fd < 0) { + return SERIAL_INVALID_FILE; + } + + if (timeout_millisec == 0) { + // no waiting + timeout.tv_sec = 0; + timeout.tv_usec = 0; + } else { + timeout.tv_sec = timeout_millisec / 1000; + timeout.tv_usec = (timeout_millisec % 1000) * 1000; + } + + FD_ZERO(&readfds); + FD_SET(fd, &readfds); + + if (select(fd + 1, &readfds, NULL, NULL, &timeout) > 0) { + return 1; // data is ready + } else { + return 0; // no data + } +} + + +/** + * send data + * + * @param file_descriptor file descriptor of serial port device file + * @param buffer buffer of data to send + * @param data_len data length + * + * @return positive integer of bytes sent if success. + * return -1 if failed. + */ +int serial_send(int file_descriptor, char *buffer, size_t data_len) +{ + ssize_t len = 0; + len = write(file_descriptor, buffer, data_len); + if ( len == data_len ) { + return len; + } else { + tcflush(file_descriptor, TCOFLUSH); + return -1; + } + +} + +/** + * receive data + * + * @param file_descriptor file descriptor of serial port device file + * @param buffer buffer to receive data + * @param data_len max data length + * + * @return positive integer of bytes received if success. + * return -1 if failed. + */ +int serial_receive(int file_descriptor, char *buffer,size_t data_len) +{ + int len,fs_sel; + fd_set fs_read; + struct timeval time; + int fd = file_descriptor; + + FD_ZERO(&fs_read); + FD_SET(fd, &fs_read); + + time.tv_sec = 10; + time.tv_usec = 0; + + //use select() to achieve multiple channel communication + fs_sel = select(fd + 1, &fs_read, NULL, NULL, &time); + if ( fs_sel ) { + len = read(fd, buffer, data_len); + return len; + } else { + return -1; + } +} + + diff --git a/serial/serial.h b/serial/serial.h new file mode 100644 index 0000000..5e1eb3b --- /dev/null +++ b/serial/serial.h @@ -0,0 +1,193 @@ +/* + * A library for Linux serial communication + * + * Author: JoStudio, 2016 + * + * Version: 0.5 + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef __SERIAL_H__ +#define __SERIAL_H__ + + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* serial error code */ +#define SERIAL_ERROR_OPEN -1 +#define SERIAL_ERROR_READ -2 +#define SERIAL_ERROR_WRITE -3 +#define SERIAL_ERROR_BAUDRATE -4 +#define SERIAL_ERROR_SETTING -5 +#define SERIAL_INVALID_RESOURCE -6 +#define SERIAL_INVALID_FILE -7 + + +/* flow control */ +#define FLOW_CONTROL_NONE 0 +#define FLOW_CONTROL_HARDWARE 1 +#define FLOW_CONTROL_SOFTWARE 2 + +/* parity */ +#define PARITY_NONE 'N' +#define PARITY_EVEN 'E' +#define PARITY_ODD 'O' +#define PARITY_SPACE 'S' +#define PARITY_MARK 'M' + + +/** + * open serial port + * + * @param port number of port, could be 0, 1 ... , the device file is /etc/ttyS0, /etc/ttyS1 respectively + * @param baund_rate could be 57600, 38400, 19200, 9600, 4800, 2400, 1200, 300 + * + * @return file descriptor which could be used in read() or write() + * return -1 if failed, and errno is set + */ +int serial_open(char* port, int baud_rate); + + +/** + * close serial port + * + * @param file_descriptor file descriptor of serial port device file + * + * @return 0 if success. + * return -1 if failed, and errno is set. + */ +int serial_close(int file_descriptor); + +/** + * open serial port + * + * @param device_filename device file name, such as "/etc/ttyS0" + * @param baund_rate could be 57600, 38400, 19200, 9600, 4800, 2400, 1200, 300 + * + * @return file descriptor which could be used in read() or write() + * return -1 if failed, and errno is set + */ +int serial_open_file(char *device_filename, int baud_rate); + + +/** + * set serial attributes + * + * @param file_descriptor file descriptor of serial device + * @param flow_ctrl + * @param data_bits how many bits per data, could be 7, 8, 5 + * @param parity which parity method, could be PARITY_NONE, PARITY_ODD, PARITY_EVEN + * @param stop_bits how many stop bits + * + * @return 1 if success. + * return negative error code if fail. + */ +int serial_set_attr(int file_descriptor, int data_bits, char parity, int stop_bits, int flow_ctrl); + + +/** + * open serial port + * + * @param file_descriptor file descriptor of serial device + * @param timeout timeout in second + * + * @return 1 if success + * return negative error code if fail + */ +int serial_set_timeout(int file_descriptor, int timeout); + + +/** + * set baud rate of serial port + * + * @param file_descriptor file descriptor of serial device + * @param baud_rate baud rate + * + * @return 1 if success + * return negative error code if fail + */ +int serial_set_baud_rate(int file_descriptor, int baud_rate) ; + + + + +/** + * The function waits until all queued output to the terminal filedes has been transmitted. + * + * tcdrain() is called. + + * @param file_descriptor file descriptor of serial port device file + * + * @return 0 if success. + * return -1 if fail, and errno is set. + */ +int serial_flush(int file_descriptor); + +/** + * whether data is available + * + * @param file_descriptor file descriptor of serial port device file + * @param timeout_millisec timeout in millisecond + * + * @return 1 if data is available + * return 0 if data is not available + */ +int serial_data_available(int file_descriptor, unsigned int timeout_millisec); + + +/** + * send data + * + * @param file_descriptor file descriptor of serial port device file + * @param buffer buffer of data to send + * @param data_len data length + * + * @return positive integer of bytes sent if success. + * return -1 if failed. + */ +int serial_send(int file_descriptor, char *buffer, size_t data_len); + + + +/** + * receive data + * + * @param file_descriptor file descriptor of serial port device file + * @param buffer buffer to receive data + * @param data_len max data length + * + * @return positive integer of bytes received if success. + * return -1 if failed. + */ +int serial_receive(int file_descriptor, char *buffer,size_t data_len); + + + +#ifdef __cplusplus +} +#endif + + +#endif /* __SERIAL_H__ */ diff --git a/tcpcgi/TcpCgi.cpp b/tcpcgi/TcpCgi.cpp index 510f1f3..a8aefe2 100644 --- a/tcpcgi/TcpCgi.cpp +++ b/tcpcgi/TcpCgi.cpp @@ -53,7 +53,7 @@ void TcpCgi::startCgiServer() std::string recvData = std::string(buff); std::string reqData = cidwServer->HandleCgi_cmd(recvData); - print_info("send cgi : %s\n", reqData.c_str()); + //print_info("send cgi : %s\n length = %d\n", reqData.c_str(),reqData.length()); if( send(connfd, reqData.c_str(), reqData.length(), 0) < 0){ printf("send msg error: %s(errno: %d)\n", strerror(errno), errno); } diff --git a/threadfunc/SH_ThreadFunc.cpp b/threadfunc/SH_ThreadFunc.cpp index 9aac80b..60787e1 100644 --- a/threadfunc/SH_ThreadFunc.cpp +++ b/threadfunc/SH_ThreadFunc.cpp @@ -9,6 +9,10 @@ #include "SH_ThreadFunc.hpp" #include "../API_log/SH_log.h" #include "../uart/SH_Uart.hpp" +#include "../common/SH_CommonFunc.hpp" +#include "../dial5G/Dial.h" +#include "../wifi/wpa_client.h" +#include namespace{ Uart *pUart = Uart::instance(); @@ -20,6 +24,8 @@ static std::string uptime; static long long connect_lost_time = 0; //ms static long long connect_time = 0; //ms +Dial dial; + void CheckThread() { print_info("ENTER CHECK THREAD \n"); @@ -31,27 +37,123 @@ void CheckThread() int reset_flag = 0; int online_check = 0; int HardStatus = 0; + int logClean = 0; + int Battery = 0; + int UpdateZigbee = 0; + int commSignal = 0; + int loose_check = 0; + int mqttresend = 0; + int rebootsystem = 0; + int ModifyAddr = 0; + int wifi_reconnect_count = 0; + int checkNet0 = 0; + int connectCount = 0; while (GlobalConfig::QuitFlag_G) { if (10 == heart_count) { // StatusPub(); if (GlobalConfig::LinkCount > 30) { - exit(0); + //exit(0); } std::string ipTemp = IpAddrInit(); + GlobalConfig::IpAddr_G = ipTemp; if ( 0 != ipTemp.compare(GlobalConfig::IpAddr_G)) { - exit(0); + //exit(0); } heart_count = 0; } - - if (600 == time_check) { +#ifdef G2UL_GATEWAY + if(checkNet0 == 5){ + checkNet0 = 0; + int iStatus = get_netlink_status("eth0"); + if(iStatus == 1 && GlobalConfig::net0Status == 0){ + system("ifconfig eth0:1 192.168.188.188 netmask 255.255.255.0"); + } + GlobalConfig::net0Status = iStatus; + } +#endif + if (300 == time_check) { char buf[256] = {0}; sprintf(buf, "{\"dataNodeGatewayNo\":\"%s\",\"cmd\":\"12\",\"status\":\"REQ\"}", GlobalConfig::MacAddr_G.c_str()); std::string str = std::string(buf); - data_publish(str.c_str(), GlobalConfig::Topic_G.mPubCmd.c_str()); time_check = 0; + int iRet = data_publish(str.c_str(), GlobalConfig::Topic_G.mPubCmd.c_str()); + if(iRet != 0 ) + { + LOG_ERROR("MQTT connect failed\n"); + //bool status = Ping( GlobalConfig::ServerIP.c_str(), 10000); +#ifdef NR5G_MODULE +#ifdef IMX6UL_GATEWAY + dial.closePort(); + gpio_set(GlobalConfig::GPIO_G.commRest,0); + LOG_DEBUG("GPIO 8 start\n"); + sleep(2); + gpio_set(GlobalConfig::GPIO_G.commRest,1); + LOG_DEBUG("GPIO 8 End\n"); + sleep(20); + dial.openPort("/dev/ttyUSB2"); + dial.setState(); +#endif +#ifdef G2UL_GATEWAY + dial.closePort(); + gpio_set(GlobalConfig::GPIO_G.commPower,0); + LOG_DEBUG("commPower start\n"); + sleep(2); + gpio_set(GlobalConfig::GPIO_G.commPower,1); + LOG_DEBUG("commPower End\n"); + sleep(20); + connectCount ++; + if(connectCount > 10){ + LOG_ERROR("5G reset error ,reboot!\n"); + system("reboot"); + } +#ifndef NR5G_MEIGE + dial.openPort("/dev/ttyUSB2"); + dial.setState(); +#else + char szquectel[100]={0x00}; + std::string strAPN = ReadStrByOpt(SERVERCONFIG, "Server", "APN"); + sprintf(szquectel,"/opt/quectel-CM/Meig-CM -s %s &",strAPN.c_str()); + system(szquectel); +#endif +#endif +#endif +#ifdef WIFI_MODULE + LOG_ERROR("WiFi reset!\n"); +#ifdef IMX6UL_GATEWAY + gpio_set(GlobalConfig::GPIO_G.wifiReset,0); + sleep(5); + gpio_set(GlobalConfig::GPIO_G.wifiReset,1); + sleep(5); + wifi::WPAClient wpa; + wpa.ReconnectWiFi(); + system("/etc/init.d/wpa_restart"); + system("udhcpc -i wlan2 &"); +#endif +#ifdef G2UL_GATEWAY + system("/etc/init.d/wpa_restart"); + sleep(5); + string strip = GetGwIp_("wlan0"); + print_info("strip = %s\n",strip.c_str()); + if (strip.compare("0.0.0.0") != 0) { + + }else{ + gpio_set(GlobalConfig::GPIO_G.wifiReset,1); + sleep(5); + gpio_set(GlobalConfig::GPIO_G.wifiReset,0); + sleep(30); + wifi::WPAClient wpa; + wpa.ReconnectWiFi(); + system("/etc/init.d/wpa_restart"); + sleep(5); + system("udhcpc -b -i wlan0 &"); + } +#endif +#endif + }else{ + connectCount = 0; + } } if(HardStatus == 3600){//one hour 3600 JsonData jd; @@ -59,26 +161,227 @@ void CheckThread() data_publish(data.c_str(), GlobalConfig::Topic_G.mPubStatus.c_str()); HardStatus = 0; } + if(mqttresend == 1800){ + mqttresend = 0; +#ifdef WIFI_MODULE + bool status = Ping( GlobalConfig::ServerIP.c_str(), 10000); + if(status != 0){ + LOG_INFO("===========net status ========failed \n"); + LOG_ERROR("openSwitch\n"); + sleep(20); + gpio_set(GlobalConfig::GPIO_G.power,1); + } +#endif + LOG_INFO("mqttresend check\n"); + Json::Value jsHeart; + Json::FastWriter fw; + jsHeart["dataNodeGatewayNo"] = GlobalConfig::MacAddr_G; + jsHeart["status"] = "online_V" + GlobalConfig::Version; + jsHeart["IP"] = GlobalConfig::IpAddr_G; + std::string strJson = fw.write(jsHeart); + int iRet = data_publish(strJson.c_str(), GlobalConfig::Topic_G.mPubHeart.c_str()); + if(iRet == 0){ + sql_ctl->QueryofflineData(); + } - if (onlineCheck == online_check) { - JsonData jd; - jd.DataNodeStatusCheck(); - LOG_INFO("online_check = %d",online_check); - Param_29 param; - std::string cmd29 = jd.JsonCmd_29(param); - data_publish(cmd29.c_str(), GlobalConfig::Topic_G.mPubCmd.c_str()); - online_check = 0; } + if (600 == online_check) { + online_check = 0; + int Count = sql_ctl->GetTableRows(T_SENSOR_INFO(TNAME), NULL); + if(Count > 0){ + JsonData jd; + jd.DataNodeStatusCheck(); + Param_29 param; + std::string cmd29 = jd.JsonCmd_29(param); + int iRet = data_publish(cmd29.c_str(), GlobalConfig::Topic_G.mPubCmd.c_str()); + char localtimestamp[32] = { 0 }; + GetTimeNet(localtimestamp, 1); + std::string nowTimetamp = std::string(localtimestamp); + char selectCon[128] = { 0 }; + sprintf(selectCon, " sendMsg <> '' ORDER BY timeStamp DESC LIMIT 0,1"); + sleep(1); + std::string strTime = sql_ctl->GetData(T_DATASTATIC_INFO(TNAME), "timeStamp", selectCon); + long lTime = atol(nowTimetamp.c_str())-atol(strTime.c_str()); + LOG_INFO("online check = %d\n",lTime); + if(lTime > 1800){ + LOG_ERROR("nowTimetamp = %s,lastTime = %s,lTime = %d\n",nowTimetamp.c_str(),strTime.c_str(),lTime); + } + } + }if(21000 == Battery){ + Battery = 0; + sql_ctl->CalculateBattery(); + } +// if(10800 == UpdateZigbee){ +// UpdateZigbee = 0; +// pUart->UpdateZigbeeInfoCtrl(); +// } + if(21000 == loose_check){ + loose_check = 0; + sql_ctl->CalculateDip(); + } + if(ModifyAddr == 21000 && pUart->bModifyAddr){ +//#ifdef IMX6UL_GATEWAY + LOG_ERROR("ModifyAddr failed \n"); + exit(0); +//#endif + } + if(ModifyAddr == 21000){ + ModifyAddr = 0; + } + + if(18000 == commSignal){ //5h + Json::Value jsBody,jsonVal; + Json::FastWriter showValue; + if(GlobalConfig::NetStatus == "\"NOCONN\"" || GlobalConfig::NetStatus == "\"CONNECT\""){ + if(GlobalConfig::NetSignal == 0){ + jsBody["communicationSignal"] = "未知"; + } + else if(GlobalConfig::NetSignal > -80){ + jsBody["commSignal"] = "优"; + }else if(GlobalConfig::NetSignal > -90 && GlobalConfig::NetSignal < -80){ + jsBody["commSignal"] = "良"; + }else if(GlobalConfig::NetSignal > -105 && GlobalConfig::NetSignal < -90){ + jsBody["commSignal"] = "一般"; + }else if(GlobalConfig::NetSignal < -105){ + jsBody["commSignal"] = "弱"; + }else if(GlobalConfig::NetSignal < -115){ + jsBody["commSignal"] = "不稳定"; + } + + }else if(GlobalConfig::NetStatus == "\"SEARCH\""){ + jsBody["commSignal"] = "搜索网络"; + }else if(GlobalConfig::NetStatus == "\"LIMSRV\""){ + jsBody["commSignal"] = "未插卡"; + }else{ + jsBody["commSignal"] = "未知"; + } + + jsonVal["cmd"] = "53"; + std::string dataBody = showValue.write(jsBody); + jsonVal["cmdBody"] = dataBody; + data_publish(showValue.write(jsonVal).c_str(), GlobalConfig::Topic_G.mPubConfig.c_str()); + } + if(21000 == logClean){ + logClean = 0; + DIR *dp; //创建一个指向root路径下每个文件的指针 + struct dirent *dirp; + string root="/opt/log/"; + if((dp = opendir(root.c_str()))==NULL) + cout << "can't open"<< root << endl; + while((dirp = readdir(dp)) != NULL){ + + if((!strcmp(dirp->d_name,".")||(!strcmp(dirp->d_name,"..")))) + continue; + struct timeval curTime; + gettimeofday(&curTime, NULL); + char buffer[80] = {0}; + char fileMonth[11] = {0}; + char todayMonth[11]={0}; + char fileDay[11] = {0}; + char todayDay[11]={0}; + struct tm nowTime; + localtime_r(&curTime.tv_sec, &nowTime);//把得到的值存入临时分配的内存中,线程安全 + strftime(buffer, sizeof(buffer), "%Y-%m-%d", &nowTime); + memcpy(fileDay,dirp->d_name+8,2); + memcpy(todayDay,buffer+8,2); + memcpy(fileMonth,dirp->d_name+5,2); + memcpy(todayMonth,buffer+5,2); + string filename = root+ string(dirp->d_name); + if(atoi(fileMonth) == atoi(todayMonth) ? abs(atoi(todayDay) - atoi(fileDay)) > 15: abs(abs(30-(atoi(fileDay)) + atoi(todayDay))) > 15){ + LOG_INFO("filename = %s\n",filename.c_str()); + remove(filename.c_str()); + } + + } + + /*staticData = 0; + Json::Value jsHeart; + Json::FastWriter fw; + jsHeart["dataNodeGatewayNo"] = GlobalConfig::MacAddr_G; + jsHeart["status"] = "online"; + std::string strJson = fw.write(jsHeart); + int iRet = data_publish(strJson.c_str(), GlobalConfig::Topic_G.mPubHeart.c_str()); + if(iRet == 0){ + JsonData jd; + std::string data = jd.JsonCmd_52(); + } + double freeDisk = GetHardDiskFree(); + if(freeDisk < 90){ + char whereCon[512] = {0x00}; + time_t timestamp; + long timeStamp = time(×tamp) ;//秒级时间戳 + memset(whereCon,0x00,sizeof(whereCon)); + sprintf(whereCon,"sendMsg = '0' and timeStamp < '%s'",timeStamp-1); //1 week + sql_ctl->DeleteTableData(T_DATA_INFO(TNAME),whereCon,0); + sql_ctl->DeleteTableData(T_DATASTATIC_INFO(TNAME),whereCon,0); + }*/ + + } +#ifdef WIFI_MODULE + if (wifi_reconnect_count == 600) { // 每 10分钟,重连WiFi网络 + wifi_reconnect_count = 0; + wifi::WPAClient wpa; + std::string netssid = wpa.GetNetSsid(); + std::string currentssid = ""; + if (0 == netssid.compare("")) { + netssid = wpa.GetNetSsid(); + } + + if (netssid.length() > 0) { + currentssid = wpa.GetCurrentSSID(); + if (currentssid.length() > 0) { + char buf[64] = {0}; + std::string rssiSend = ""; +#ifdef G2UL_GATEWAY + rssiSend = "/usr/sbin/wpa_cli signal_poll|grep RSSI | cut -f 2 -d '='"; +#endif + +#ifdef IMX6UL_GATEWAY + rssiSend = "/opt/Cidn/wpa_cli signal_poll|grep RSSI | cut -f 2 -d '='"; +#endif + system_custom(rssiSend.c_str(), buf); + std::string Rssi = std::string(buf); + + memset(buf, 0, 64); + sprintf(buf, "wifi:true Rssi:%s", Rssi.c_str()); + print_info("%s\n", buf); + LOG_INFO("%s\n",buf); + + } else { + std::string runinfo = "wifi:false\n"; + print_info("%s\n", runinfo.c_str()); + } + } + if (wpa.ReconnectWiFi()) { + print_info("wifi reconnect ok\n"); + } + } +#endif + if ( reset_flag > 7200) { reset_flag = 0; //exit(0); } + Battery ++; reset_flag++; time_check++; heart_count++; online_check++; HardStatus ++; + //UpdateZigbee ++; + logClean ++ ; + loose_check ++; + ModifyAddr ++; + mqttresend ++; +#ifdef G2UL_GATEWAY + checkNet0 ++; +#endif +#ifdef WIFI_MODULE + wifi_reconnect_count ++; +#endif + + //rebootsystem ++; if(GlobalConfig::EnterZigBeeWaveTransmittingFlag_G == ENTER_TRANSMITTING_STATUS) { GlobalConfig::EnterZigBeeWaveTransmittingCnt_G ++; if(GlobalConfig::EnterZigBeeWaveTransmittingCnt_G >= 180) { @@ -87,13 +390,17 @@ void CheckThread() LOG_ERROR("[---- ZigBee error--!] ZigBee PanID is 9999 over time for 3 minutes !\n"); // 重新写入 0x8888 unsigned short shortAddr = 0x8888; - pUart->WriteShortAddr2Zigbee(shortAddr); + pUart->modify_LocalAddr(0x8888); + GlobalConfig::Zigbee_G.MyAddr = 0x8888; +// pUart->WriteShortAddr2Zigbee(shortAddr); // 延时1秒 - boost::this_thread::sleep(boost::posix_time::seconds(1)); + sleep(1); // 重新读回 GlobalConfig::ZigbeeInfo_G.PanID pUart->UpdateZigbeeInfoCtrl(); + pUart->bUpdateconfig = false; + pUart->bUpdate = false; // 延时1秒 - boost::this_thread::sleep(boost::posix_time::seconds(1)); + sleep(1); std::string str("8888"); if( GlobalConfig::ZigbeeInfo_G.MyAddr.compare(str) == 0 ){ LOG_INFO("[---- ZigBee INFO ----!] ZigBee PanID come back to be 8888 !\n"); @@ -103,8 +410,7 @@ void CheckThread() } } } - - boost::this_thread::sleep(boost::posix_time::milliseconds(1000)); + sleep(1);; } } @@ -114,40 +420,277 @@ void StartCgiServer() TcpCgi *tcpCgi = TcpCgi::instance(); while (1) { tcpCgi->startCgiServer(); - boost::this_thread::sleep(boost::posix_time::seconds(10)); + sleep(10); } } - +void RunLED() +{ + while(1){ + gpio_set(GlobalConfig::GPIO_G.runLed,1); + sleep(1); + gpio_set(GlobalConfig::GPIO_G.runLed,0); + sleep(1); + } +} void HeartRep() { + int count = 0; while(1) { Json::Value jsHeart; Json::FastWriter fw; jsHeart["dataNodeGatewayNo"] = GlobalConfig::MacAddr_G; - jsHeart["status"] = "online"; + jsHeart["status"] = "online_V" + GlobalConfig::Version; + jsHeart["IP"] = GlobalConfig::IpAddr_G; std::string strJson = fw.write(jsHeart); - data_publish(strJson.c_str(), GlobalConfig::Topic_G.mPubHeart.c_str()); - boost::this_thread::sleep(boost::posix_time::seconds(10)); + int iRet = data_publish(strJson.c_str(), GlobalConfig::Topic_G.mPubHeart.c_str()); + print_info("heart = %s,iRet = %d\n",strJson.c_str(),iRet); + if(iRet != 0){ + count ++; + gpio_set(GlobalConfig::GPIO_G.errorLed,1); + sleep(1); + gpio_set(GlobalConfig::GPIO_G.errorLed,0); + sleep(1); + gpio_set(GlobalConfig::GPIO_G.errorLed,1); + sleep(1); + gpio_set(GlobalConfig::GPIO_G.errorLed,0); + sleep(1); + gpio_set(GlobalConfig::GPIO_G.errorLed,1); + sleep(1); + GlobalConfig::serverStatus = 1; + }else{ + GlobalConfig::serverStatus = 0; + count = 0; + gpio_set(GlobalConfig::GPIO_G.errorLed,0); + } + gpio_set(GlobalConfig::GPIO_G.errorLed,0); +// if(count > 0){ +// bool status = Ping( GlobalConfig::ServerIP.c_str(), 10000); +// if(status != 0) +// //LOG_INFO("===========net status ========failed heart count %d\n",count); +// if(status != 0 && count > 30){ +// LOG_ERROR("heart send failed,heart count %d\n",count); +// count = 0; +// sleep(20); +// gpio_set(GlobalConfig::GPIO_G.power,1); +// } +// } +// if(count > 1000){ +// gpio_set(GlobalConfig::GPIO_G.power,1); +// count = 0; +// } +// write_data(fd,"AT+QENG=\"servingcell\"\r\n",27); +// //sleep(1); +// char buff[1024]={0x00}; +// int ret = read_data(fd, buff, 1024, 10); +// print_info("ret = %d,buff = %s\n",ret,buff); +// const char *str2 = "+QENG: "; +// char csq[128] = {0}; +// char *pdata = strstr((char*)buff, str2); +// if(pdata){ +// strncpy(csq, pdata+7, sizeof(csq)); +// } +// else { +// } +// +// //printf("SIM-CSQ: %s\n", csq); +// GlobalConfig::NetStatus = GetOneContent(csq,1,","); +// string signal = GetOneContent(csq,13,","); +// GlobalConfig::NetSignal = atoi(signal.c_str()); +// print_info("NetStatus = %s,NetSignal = %d\n",GlobalConfig::NetStatus.c_str(),GlobalConfig::NetSignal); + + //GlobalConfig::NetSignal = getcsq(); + /*if(GlobalConfig::NetSignal <= -105 ){ + gpio_set(130,1); + }else if(GlobalConfig::NetSignal > -105 ){ + gpio_set(130,0); + }else{ + gpio_set(130,1); + }*/ + sleep(10); + //socketHeart(strJson.c_str()); } } +void GetCSQ() +{ +#ifdef NR5G_MODULE + //5G + int iRet = -1; +open5G: + iRet = dial.openPort("/dev/ttyUSB2"); + if (iRet < 0){ + sleep(5); + goto open5G; + } +#ifdef NR5G_MEIGE + dial.closePort(); + char szquectel[100]={0x00}; + std::string strAPN = ReadStrByOpt(SERVERCONFIG, "Server", "APN"); + sprintf(szquectel,"/opt/quectel-CM/Meig-CM -s %s &",strAPN.c_str()); + system(szquectel); +#else + dial.recvData(); +#endif +#endif +#ifdef Q4G_MODULE + //4G + int fd = -1; +open4G: + fd = config_uart("/dev/ttyUSB2",115200); + if (fd < 0){ + sleep(5); + goto open4G; + } + char szbuffer[200]={0x00}; + int offSize = 0; + int timeoutflag = 0; + write_data(fd,"AT+QENG=\"servingcell\"\r\n",27); + while(1){ + char buff[1024]={0x00}; + int ret = read_data(fd, buff, 1024, 10); + if(ret <= 0){ + timeoutflag ++; + if(timeoutflag > 5){ + print_info("timeoutflag = %d\n",timeoutflag); + timeoutflag = 0; + const char *str2 = "+QENG: "; + char csq[128] = {0}; + char *pdata = strstr((char*)szbuffer, str2); + if(pdata){ + strncpy(csq, pdata+7, sizeof(csq)); + + //printf("SIM-CSQ: %s\n", csq); + GlobalConfig::NetStatus = GetOneContent(csq,1,","); + string signal = GetOneContent(csq,13,","); + GlobalConfig::NetSignal = atoi(signal.c_str()); + GlobalConfig::NetType = GetOneContent(csq,2,","); + print_info("NetStatus = %s,NetSignal = %d\n",GlobalConfig::NetStatus.c_str(),GlobalConfig::NetSignal); + + } + memset(szbuffer,0x00,sizeof(szbuffer)); + offSize = 0; + write_data(fd,"AT+QENG=\"servingcell\"\r\n",27); + } + usleep(10000); + }else if(ret > 0){ + print_info("ret = %d,buff = %s\n",ret,buff); + memcpy(szbuffer + offSize,buff,ret); + offSize = offSize + ret; + print_info("szbuffer = %s\n",szbuffer); + continue; + } + sleep(10); + } +#endif +} +void Dial5G() +{ + sleep(2); +dial5G: + if(dial.m_fd > 0){ + dial.dial5G(); + }else{ + sleep(5); + goto dial5G; + } +} void UartStart() { // onReceiveUart cb = (onReceiveUart)&ProtoConvert::HandleFromUart; // pUart->setCallBack(cb); - pUart->InitUart(); + InitGpio(GlobalConfig::GPIO_G.zigAckrep,0);//ACK + InitGpio(GlobalConfig::GPIO_G.zigAckreset,1);//ACK reset + InitGpio(GlobalConfig::GPIO_G.zigReset,1);//Zigbee reset + gpio_set(GlobalConfig::GPIO_G.zigAckreset,1); + gpio_set(GlobalConfig::GPIO_G.zigReset,1); - while (GlobalConfig::QuitFlag_G) { +#ifdef IMX6UL_GATEWAY + InitGpio(GlobalConfig::GPIO_G.errorLed,1);//指示灯 + gpio_set(GlobalConfig::GPIO_G.errorLed,0); + InitGpio(GlobalConfig::GPIO_G.power,1);//power reset + gpio_set(GlobalConfig::GPIO_G.power,0); +#endif +#ifdef G2UL_GATEWAY + InitGpio(GlobalConfig::GPIO_G.runLed,1); + InitGpio(GlobalConfig::GPIO_G.errorLed,1); + gpio_set(GlobalConfig::GPIO_G.runLed,1); + gpio_set(GlobalConfig::GPIO_G.errorLed,0); + InitGpio(GlobalConfig::GPIO_G.netResetNet0,1); + gpio_set(GlobalConfig::GPIO_G.netResetNet0,0); +#endif + GlobalConfig::Zigbee_G.Serial_Rate = 0x07; + GlobalConfig::Zigbee_G.Serial_DataB = 0x08; + GlobalConfig::Zigbee_G.Serial_StopB = 0x01; + pUart->InitUart(B115200); + char buffer[1100]={0x00}; + + sleep(1); + pUart->UartRecv(pUart->fd,1,buffer); + sleep(1); - pUart->UpdateZigbeeInfoCtrl(); - pUart->ReadFromUart(); - pUart->Run(); -// pUart->Stop(); - boost::this_thread::sleep(boost::posix_time::milliseconds(10)); - } } +void InitModule() +{ +#ifdef NR5G_MODULE +#ifdef G2UL_GATEWAY + InitGpio(GlobalConfig::GPIO_G.commPower,1);//4G,5G模组供电, + gpio_set(GlobalConfig::GPIO_G.commPower,1); + InitGpio(GlobalConfig::GPIO_G.vol3_8,1);//5G 高电平3.8V,低电平3.3V + gpio_set(GlobalConfig::GPIO_G.vol3_8,1); + + InitGpio(GlobalConfig::GPIO_G.commRest,1); + gpio_set(GlobalConfig::GPIO_G.commRest,0);//高电平复位 +#endif +#ifdef IMX6UL_GATEWAY + InitGpio(GlobalConfig::GPIO_G.commRest,1); + gpio_set(GlobalConfig::GPIO_G.commRest,1);// +#endif +#endif +#ifdef Q4G_MODULE +#ifdef G2UL_GATEWAY + InitGpio(GlobalConfig::GPIO_G.commPower,1);//4G,5G模组供电, + gpio_set(GlobalConfig::GPIO_G.commPower,1); + InitGpio(GlobalConfig::GPIO_G.commRest,1); + gpio_set(GlobalConfig::GPIO_G.commRest,0);//高电平复位 + sleep(10); + char szquectel[100]={0x00}; + std::string strAPN = ReadStrByOpt(SERVERCONFIG, "Server", "APN"); + sprintf(szquectel,"/opt/quectel-CM/quectel-CM -s %s &",strAPN.c_str()); + system(szquectel); +#endif +#endif +#ifdef WIFI_MODULE + print_info("Init WiFi!\n"); + +#ifdef IMX6UL_GATEWAY + InitGpio(GlobalConfig::GPIO_G.wifiReset,1);//WiFi模组复位,0复位,1取消复位 + gpio_set(GlobalConfig::GPIO_G.wifiReset,1); + sleep(10); + wifi::WPAClient wpa; + wpa.ReconnectWiFi(); + system("/etc/init.d/wpa_restart"); + system("udhcpc -i wlan2 &"); +#endif +#ifdef G2UL_GATEWAY + InitGpio(GlobalConfig::GPIO_G.wifiReset,1);//WiFi模组复位,1复位,0取消复位 + gpio_set(GlobalConfig::GPIO_G.wifiReset,0); + InitGpio(GlobalConfig::GPIO_G.wifiPower,1);//WiFi模组上电 + gpio_set(GlobalConfig::GPIO_G.wifiPower,1); + sleep(10); + wifi::WPAClient wpa; + wpa.ReconnectWiFi(); + system("/usr/sbin/wpa_supplicant -Dnl80211 -iwlan0 -c/etc/wpa_supplicant.conf &"); + system("udhcpc -b -i wlan0 &"); +#endif +#endif +} +void TestUart() +{ + pUart->InitTestUart(B115200); + pUart->ReadTestUart(); +} void UartStartWave() { pUart->DealWaveThread(); @@ -158,7 +701,15 @@ void StartUdpSys() UdpSys *udpsys = UdpSys::instance(); udpsys->StartConnectSysUdp(); } - +void WatchDog() +{ + int fd = OpenWatchDog(); + while(1){ + WriteWatchDog(fd); + sleep(50); + } + close(fd); +} static const char* LOCAL_WILL_TOPIC = "up/uart/will"; void my_publish_callback(struct mosquitto *mosq, void *obj, int mid) { @@ -185,7 +736,7 @@ void my_connect_callback(struct mosquitto *mosq, void *obj, int result) connect_time = strtoll(gwTime, NULL, 10); print_debug("connect_time:%lld\n", connect_time); long long difftime_ms = connect_time - connect_lost_time; - //if (difftime_ms > 20*1000) { // 超过20秒,判定为连接断开 + if (difftime_ms > 20*1000) { // 超过20秒,判定为连接断开 char reply_string[256] = {0}; std::string startStatus = "0"; if (access(SYSTEMSTART, 0) >= 0) { @@ -199,20 +750,17 @@ void my_connect_callback(struct mosquitto *mosq, void *obj, int result) Json::FastWriter fw; jsData["cmd"] = "15"; jsData["dataNodeGatewayNo"] = GlobalConfig::MacAddr_G; - // jsData["cmdBody"] = ""; std::string strCmd15 = fw.write(jsData); - // data_publish(strCmd15.c_str(), GlobalConfig::Topic_G.mPubCmd.c_str()); std::string instr = std::string(reply_string); std::string topic = "equipment/state/" + GlobalConfig::MacAddr_G; int ret = data_publish(instr.c_str(), topic.c_str()); - system("echo 0 > /CIDW/start"); if (ret != MOSQ_ERR_SUCCESS) { print_debug("Publish failed:%d, %s\n", ret, instr.c_str()); disconnect(); } - //} + } GlobalConfig::LinkStatus_G = 1; print_debug("Connect to server success.\n"); @@ -250,8 +798,8 @@ void my_disconnect_callback(struct mosquitto *mosq, void *obj, int result) { int ret = 0; ret = disconnect(); - // LOG_ERROR("The uart connection lost:%d\n", ret); - print_debug("The uart connection lost\n"); + //LOG_ERROR("The MQTT connection lost:%d\n", ret); + print_debug("The MQTT connection lost\n"); char gwTime[32] = { 0 }; GetTimeNet(gwTime, 0); uptime = std::string(gwTime); @@ -259,6 +807,41 @@ void my_disconnect_callback(struct mosquitto *mosq, void *obj, int result) print_debug("connect_lost_time:%lld\n", connect_lost_time); GlobalConfig::LinkStatus_G = 0; GlobalConfig::LinkCount = GlobalConfig::LinkCount + 1; + +#ifdef WIFI_MODULE + char buf[128] = {0}; + std::string wpa_state = ""; +#ifdef G2UL_GATEWAY + wpa_state = "/usr/sbin/wpa_cli status|grep wpa_state | cut -f 2 -d '='"; +#endif + +#ifdef IMX6UL_GATEWAY + wpa_state = "/opt/Cidn/wpa_cli status|grep wpa_state | cut -f 2 -d '='"; +#endif + system_custom(wpa_state.c_str(), buf); + std::string state = std::string(buf); + std::string RSSI_cmd = ""; +#ifdef G2UL_GATEWAY + RSSI_cmd = "/usr/sbin/wpa_cli signal_poll|grep RSSI | cut -f 2 -d '='"; +#endif +#ifdef IMX6UL_GATEWAY + RSSI_cmd = "/opt/Cidn/wpa_cli signal_poll|grep RSSI | cut -f 2 -d '='"; +#endif + system_custom(RSSI_cmd.c_str(), buf); + std::string RSSI = std::string(buf); + + int iRet = reconnect(); + memset(buf, 0, sizeof(buf)); + sprintf(buf, "wifi RSSI:%s,state:%s,MQTT reconnect :%d\n", RSSI.c_str(),state.c_str(),iRet); + //LOG_WARN(" %s\n",buf); + int status = Ping( GlobalConfig::ServerIP.c_str(), 10000);; + //LOG_WARN(" netStatus %d\n",status); + print_info("%s\n", buf); + +#else + int iRet = reconnect(); +#endif + } void my_message_callback(struct mosquitto *mosq, void *obj, const struct mosquitto_message *message) @@ -337,7 +920,7 @@ void StartMqttClient() register_collback(my_connect_callback, my_message_callback, my_subscribe_callback, my_log_callback, my_disconnect_callback, my_publish_callback); start_client(strEqupNo.c_str(), GlobalConfig::MacAddr_G.c_str(), GlobalConfig::ServerIP.c_str(), strVersion.c_str(), "11111111", salt); } - boost::this_thread::sleep(boost::posix_time::seconds(3)); + sleep(3); } } @@ -348,13 +931,14 @@ void SearchThread() while (GlobalConfig::QuitFlag_G) { if (GlobalConfig::IpAddr_G.length() > 0 && 0 != GlobalConfig::IpAddr_G.compare("0.0.0.0")) { + print_info("%s\n",runinfo.c_str()); boost::asio::io_service io_service; SearchDev *searchDevObj = new SearchDev(io_service); searchDevObj->MultiCastRecv(); io_service.run(); delete searchDevObj; } - boost::this_thread::sleep(boost::posix_time::seconds(5)); + sleep(5); print_error("SearchThred restart.\n"); } } diff --git a/threadfunc/SH_ThreadFunc.hpp b/threadfunc/SH_ThreadFunc.hpp index 38a4e4b..8f35074 100644 --- a/threadfunc/SH_ThreadFunc.hpp +++ b/threadfunc/SH_ThreadFunc.hpp @@ -27,5 +27,11 @@ extern void RecvUpdateFile(); //更新升级包 extern void StartCgiServer(); //启动cgi处理服务端 extern void HeartRep(); extern void UartStart(); // +extern void TestUart(); +extern void WatchDog(); extern void UartStartWave(); extern void StartUdpSys(); //组播通信 +extern void GetCSQ(); +extern void Dial5G(); +extern void InitModule(); +extern void RunLED(); diff --git a/uart/SH_Uart.cpp b/uart/SH_Uart.cpp index 77a95ac..c4adf45 100644 --- a/uart/SH_Uart.cpp +++ b/uart/SH_Uart.cpp @@ -1,4 +1,10 @@ #include +#include +#include +#include +#include +#include +#include #include #include #include @@ -6,12 +12,16 @@ #include #include #include "../uart/SH_Uart.hpp" +#include "../serial/serial.h" + namespace{ Uart *pUart = Uart::instance(); + Calculation *pCalculation = Calculation::instance(); } char g_UartRecvBuf[GENERAL_BUF_SIZE]; int offSize = 0; +pTestRecvCallBack pTestRecv ; // namespace{ // PlatformInit *platform = PlatformInit::instance(); // LocalServer *wlServer = LocalServer::instance(); @@ -21,73 +31,346 @@ using namespace boost::asio; const UINT CharSize = 8; const UINT UartBaud = 115200; +int Uart::UartRecv(int fd, char srcshow,char* buffer) +{ + char buff[BUF_LENGTH]; + int ret = 0; + int maxSize = 0; + int offSize = 0; + int timeoutflag = 0; + char head[] = {0xAA,0x55,0xAA}; + char szbuffer[BUF_LENGTH]={0x00} ; + while(1) + { + + if((unsigned short)GlobalConfig::Zigbee_G.MyAddr == 0x9999){ + memset(buff, 0, sizeof(buff)); + ret = read_data(fd, buff, BUF_LENGTH, 10); + if (ret <= 0 ){ + if(!bUpdate && !bUpdateconfig && GlobalConfig::EnterZigBeeWaveTransmittingCnt_G > 15){ + timeoutflag ++; + if(timeoutflag > 300){ + LOG_DEBUG("===============0x9999 timeout= %d offSize = %d===============\n",timeoutflag,offSize); + print_info("0x9999 timeout %d===============Size = %d\n",timeoutflag,offSize); + FindRecvPackage(offSize, mUartRecvTmpBuf,head); + GlobalConfig::Zigbee_G.MyAddr = 0x8888; + timeoutflag = 0; + offSize = 0; + maxSize = 0; + tcflush(fd,TCIFLUSH); + bModifyAddr = true; + modify_LocalAddr(0x8888); + bSendTimeStamp = false; + usleep(10000); + + GlobalConfig::EnterZigBeeWaveTransmittingFlag_G = NO_ENTER_TRANSMITTING_STATUS; + GlobalConfig::EnterZigBeeWaveTransmittingCnt_G = 0; + DealWave(); + LOG_DEBUG("wave end\n"); + } + usleep(10000); + }else if(bUpdatePre || (bUpdateconfig && GlobalConfig::EnterZigBeeWaveTransmittingCnt_G > 15)){ + timeoutflag ++; + if(timeoutflag > 300){ + print_info("bUpdateconfig %d===============\n",timeoutflag); + GlobalConfig::EnterZigBeeWaveTransmittingFlag_G = NO_ENTER_TRANSMITTING_STATUS; + GlobalConfig::EnterZigBeeWaveTransmittingCnt_G = 0; + timeoutflag = 0; + offSize = 0; + maxSize = 0; + bUpdate = false; + bUpdatePre = false; + bUpdateconfig = false; + bModifyAddr = true; + bSendTimeStamp = false; + modify_LocalAddr(0x8888); + usleep(100000); + GlobalConfig::Zigbee_G.MyAddr = 0x8888; + } + usleep(100000); + } + } + else if(ret > 0){ + maxSize += ret; + //print_debug("0x9999===str_recv===,ret = %d offSize = %d,bUpdatePre = %d,bUpdateconfig = %d\n",ret,maxSize,bUpdatePre,bUpdateconfig); +// for(int i = 0; i < ret;i++){ +// printf("[%02x]", buff[i]&0xff); +// } + //print_debug("maxSize = %d\n",maxSize); + //print_debug("\n"); + timeoutflag = 0; + + if((bUpdatePre || bUpdateconfig)) + { + for(int i = 0; i < ret;i++){ + printf("%02x ", buff[i]&0xff); + } + //print_debug("maxSize111 = %d\n",maxSize); + // string strTime = GetLocalTimeWithMs(); + // LOG_INFO("str_recv strTime1 = %s\n",strTime.c_str()); + FindRecvPackage(ret,buff,head); + // ReadHandle(buff,ret); + // strTime = GetLocalTimeWithMs(); + // LOG_INFO("str_recv strTime2 = %s\n",strTime.c_str()); + }else{ + m_TimeStamp = 0; + memcpy(mUartRecvTmpBuf + offSize,buff,ret); + offSize = offSize + ret; + if(offSize > BUF_LENGTH * 15){ + LOG_INFO("maxSize = %d\n",offSize); + memset(mUartRecvTmpBuf,0,BUF_LENGTH); + timeoutflag = 0; + offSize = 0; + maxSize = 0; + tcflush(fd,TCIOFLUSH); + bModifyAddr = true; + modify_LocalAddr(0x8888); + GlobalConfig::Zigbee_G.MyAddr = 0x8888; + GlobalConfig::EnterZigBeeWaveTransmittingFlag_G = NO_ENTER_TRANSMITTING_STATUS; + GlobalConfig::EnterZigBeeWaveTransmittingCnt_G = 0; + } + print_debug("offSize = %d\n",offSize); + } + } + + }else if((unsigned short)GlobalConfig::Zigbee_G.MyAddr == 0x8888){ +#ifdef IMX6UL_GATEWAY + memset(buff, 0, sizeof(buff)); + ret = read_data(fd, buff, BUF_LENGTH, 50); + if (ret <= 0){ + continue; + } + if (srcshow) { + print_info("0x8888 ===str_recv===,ret = %d\n",ret); + for(int i = 0; i < ret;i++){ + print_debug("[%02x]", buff[i]&0xff); + } + printf("\n"); + FindRecvPackage(ret, buff,head); + + } +#else if G2UL_GATEWAY + memset(buff, 0x00, sizeof(buff)); + ret = read_data(fd, buff, BUF_LENGTH, 50); + if (ret <= 0 ){ + timeoutflag ++; + if(timeoutflag > 5){ + + FindRecvPackage(offSize, szbuffer,(char*)head); + memset(szbuffer,0x00,sizeof(szbuffer)); + timeoutflag = 0; + offSize = 0; + maxSize = 0; + usleep(10000); + } + }else if(ret > 0){ + maxSize += ret; + print_debug("0x8888==str_recv===,ret = %d offSize = %d\n",ret,maxSize); + for(int i = 0; i < ret;i++){ + print_debug("%02x ", buff[i]&0xff); + } + print_debug("\n"); + timeoutflag = 0; + m_TimeStamp = 0; + memcpy(szbuffer + offSize,buff,ret); + offSize = offSize + ret; + } +#endif + } + usleep(50); + } +} + Uart::Uart():mUart(mIoSev),mStrand(mIoSev) { - mRdLength = 0; - memset(mUartRecvBuf,0,BUF_LENGTH); + mRdLength = 0; + m_TimeStamp = 0; + mlastSize = 0; + fd = 0; + waittime = 0; + mPackgeIndex = -1; + bUpdate = false; + m_strDestShortAddr = ""; + memset(mUartRecvBuf,0,BUF_LENGTH); + memset(mUartRecvTmpBuf,0,BUF_LENGTH); + bTest = false; + TestFd = 0; + DataNodeUpdateFile = ""; + strTimetamp = ""; + bZigbeeSinal = false; + bModifyAddr = false; + bUpdatePre = false; + bSendTimeStamp = false; } - -void Uart::InitUart() -{ - //*.reset()作用重置对象,为run()的调用做准备 - mUart.get_io_service().reset(); - mStrand.get_io_service().reset(); - // ThreadInit(); - mRdLength = 0; - //errcode用来接收错误类型 - boost::system::error_code errcode; - //打开/dev/ttymxc4串口文件 - mUart.open(GlobalConfig::UartName_G,errcode); - if ( errcode) { - print_error("Fail To Open Uart!\n"); - // LOG_ERROR("Fail To Open Uart!\n"); - return ; - } else { - if (mUart.is_open()) { - print_info("Success To Open Uart!\n"); - } - } - //设置串口的波特率 数据位 流控 奇偶校验位 停止位 - mUart.set_option( serial_port::baud_rate(UartBaud), errcode); - mUart.set_option( serial_port::flow_control(serial_port::flow_control::none),errcode ); - mUart.set_option( serial_port::parity(serial_port::parity::none),errcode ); - mUart.set_option( serial_port::stop_bits(serial_port::stop_bits::one),errcode ); - mUart.set_option( serial_port::character_size(CharSize),errcode ); - - - // WriteToUart(); - // mUart.set_option( serial_port::baud_rate(UartBaud), errcode); - -} - Uart::~Uart() { + close(fd); + close(TestFd); if (mUart.is_open()) mUart.close(); } +void Uart::openSwitch() +{ + char buffer[100]={0x00}; + int len; + int fdSwitch = config_uart("/dev/ttymxc1",B38400); + char strSend[8]={0x01,0x06,0x00,0x00,0x00,0x00,0x89,0xCA}; + len = write_data(fdSwitch,(char*)strSend,8); + sleep(1); + len = read_data(fdSwitch,(char*)buffer,100,10); + for ( int i = 0; i < len; i++) + print_debug("%02X ",buffer[i]&0xFF); + char strSend2[8]={0x01,0x06,0x00,0x00,0x00,0x01,0x48,0x0A}; + len = write_data(fdSwitch,(char*)strSend2,8); + sleep(1); + len = read_data(fdSwitch,(char*)buffer,100,10); + for ( int i = 0; i < len; i++) + print_debug("%02X ",buffer[i]&0xFF); + close(fdSwitch); +} +void Uart::InitUart(speed_t speed) +{ + +#ifdef G2UL_GATEWAY + fd = config_uart("/dev/ttySC2",speed); +#endif +#ifdef IMX6UL_GATEWAY + fd = config_uart("/dev/ttymxc4",speed); +#endif + print_info("InitUart fd = %d\n",fd); + if(fd < 0){ + printf("config_uart error\n"); + } + +} +void Uart::Close() +{ + close(fd); + fd = 0; +} +void Uart::InitZigbee() +{ + + InitUart(B115200); + UpdateZigbeeInfoCtrl(); + sleep(2); + int iRet = ReadFromUart(); + if(iRet <= 0) + { + Close(); + sleep(2); + print_info("Speed error\n"); + InitUart(B57600); + UpdateZigbeeInfoCtrl(); + sleep(2); + ReadFromUart(); + print_info("modify speed\n"); + WriteSpeed2Zigbee(); + ReadFromUart(); + } + Close(); + sleep(1); +} +void TestRecv(int status) +{ + char szStatus[10]={0x00}; + sprintf(szStatus,"%d",status); + write_data(pUart->TestFd,(char*)szStatus,strlen(szStatus)); +} +void Regist(pTestRecvCallBack pTestRecv1){ + pTestRecv = pTestRecv1; +} +void Uart::InitTestUart(speed_t speed) +{ + print_info("InitTestUart\n"); + TestFd = config_uart("/dev/ttymxc2",speed);//Test + if(TestFd < 0){ + printf("Test config_uart error\n"); + } + Regist(TestRecv); +} + +void Uart::ReadTestUart() +{ + char buff[BUF_LENGTH] = {0x00}; + print_info("ReadTestUart\n"); + while(1){ + int ret = read_data(TestFd, buff, BUF_LENGTH, 10); + if(ret > 0){ + print_info("buff = %s\n",buff); + if(!strcmp(buff,"0")){ + + char buf[256] = {0}; + sprintf(buf, "{\"dataNodeGatewayNo\":\"%s\",\"cmd\":\"12\",\"status\":\"REQ\"}", + GlobalConfig::MacAddr_G.c_str()); + std::string str = std::string(buf); + int iRet = data_publish(str.c_str(), GlobalConfig::Topic_G.mPubCmd.c_str()); + if(iRet < 0){ + pTestRecv(1); + }else{ + pTestRecv(0); + } + iRet = ZigbeeTest(); + }else if(!strcmp(buff,"1")){ + string IP = GetGwIp_("eth0"); + write_data(TestFd,(char*)IP.c_str(),IP.size()); + IP = GetGwIp_("eth1"); + write_data(TestFd,(char*)"|",1); + write_data(TestFd,(char*)IP.c_str(),IP.size()); + write_data(TestFd,(char*)"|",1); + }else{ + ModifyMac(buff); + pTestRecv(0); + } + } + usleep(20000); + } +} + +int Uart::ZigbeeTest() +{ + char buff[BUF_LENGTH] = {0x00}; + modify_Localchannel(22); + usleep(100000); + + modify_LocalPanID(2222); + + usleep(100000); + modify_LocalAddr(6666); + + usleep(100000); + return 0; +} + void Uart::WriteToUart(const char *strSend,int pLen) { //#ifdef ZIGBEE_TEST - print_debug("Write To Uart Start:\n"); - for(int i=0; i 0){ + ReadHandle(buffer,len); + }*/ } void Uart::Run() @@ -110,21 +407,336 @@ void Uart::Stop() mUart.close(); mIoSev.stop(); } - -void Uart::ReadHandle(const boost::system::error_code &ec,size_t bytesRead) +int Uart::FindRecvPackage(int bytesRead, char* mUartRecvBuf,char* head) { -try{ + string strTime = GetLocalTimeWithMs(); + char head1[] = {0xAB,0xBC,0xCD}; + char head2[] = {0xDE,0xDF,0xEF}; + + //LOG_INFO("m_VecWaveData= %d\n",m_VecWaveData.size()); + int lastSize = 0; + char UartRecvBuf[BUF_LENGTH*15]={0x00}; + char RecvBuf[200] = {0x00}; + if(mlastSize > 0){ + print_info("mlastSize = %d\n",mlastSize); + memcpy(UartRecvBuf,mUartRecvTmpBuf,mlastSize); + for(int i = 0; i < mlastSize;i++){ + print_info("%02x ",UartRecvBuf[i]); + } + print_info("\n "); + memset(mUartRecvTmpBuf,0x00,sizeof(mUartRecvTmpBuf)); + } + memcpy(UartRecvBuf + mlastSize,mUartRecvBuf,bytesRead); + // for(int i = 0 ; i < bytesRead;i++){ + // if(!(i % 100)) + // printf("\n"); + // printf("%02x ",mUartRecvBuf[i]); + // } + bytesRead = bytesRead + mlastSize; + for(int i = 0; i < bytesRead;i++){ + if(UartRecvBuf[i] == head[0]){ + char buf[6]={0x00}; + char ShortAddr[8]={0x00}; + sprintf(&buf[0], "%02X", UartRecvBuf[i]&0xFF); + sprintf(&buf[2], "%02X", UartRecvBuf[i+1]&0xFF); + sprintf(&buf[4], "%02X", UartRecvBuf[i+2]&0xFF); + sprintf(ShortAddr, "%02x%02x", UartRecvBuf[i+3]&0xFF, UartRecvBuf[i+4]&0xFF); + std::string strShortAddr(ShortAddr); + std::string strHeadFlag(buf); + if ( 0 == strHeadFlag.compare("AA55AA")) { + char buf[8]={0x00}; + sprintf(buf, "%02d", UartRecvBuf[i+5]&0xFF); + int command = atoi(buf); + //print_info("command = %d\n",command); + //print_info("index = %d\n",UartRecvBuf[i+6]&0xFF); + //print_info("mPackgeIndex1 = %d\n",mPackgeIndex); + if((mPackgeIndex == -1 || (unsigned int)UartRecvBuf[i+6] == 0) && (!bUpdatePre && !bUpdateconfig)){ + //print_info("mPackgeIndex2 = %d\n",mPackgeIndex); + mPackgeIndex = UartRecvBuf[i+6]&0xFF; + }else if((unsigned int)mPackgeIndex == (unsigned int)UartRecvBuf[i+6] && + mPackgeIndex != -1 && (!bUpdatePre && !bUpdateconfig) && command != 2){ + LOG_ERROR("mPackgeIndex same index1:%d,index2:%02d ShortAddr :%s \n",\ + mPackgeIndex,UartRecvBuf[i+6]&0xff,strShortAddr.c_str()); + continue; + + }else if((unsigned int)mPackgeIndex + 1 != (unsigned int)UartRecvBuf[i+6] && + mPackgeIndex != -1 && (!bUpdatePre && !bUpdateconfig) && command != 2){ + m_TimeStamp = 0; + //print_info("mPackgeIndex3 = %d\n",mPackgeIndex); + LOG_ERROR("mPackgeIndex error index1:%d,index2:%02d ShortAddr :%s \n",\ + mPackgeIndex,UartRecvBuf[i+6]&0xff,strShortAddr.c_str()); + mPackgeIndex = -1; + print_error("mPackgeIndex error ShortAddr :%s \n",strShortAddr.c_str()); + + char tmp[10]={0x00}; + char tmp2[10]={0x00}; + for(int j = 0; j < 100;j++){ + sprintf(tmp,"%02x ",UartRecvBuf[i + j] & 0xff); + strcat(tmp2,tmp); + } + LOG_ERROR("error str = %s\n",tmp2); + + tcflush(fd,TCIOFLUSH); + sleep(1); + modify_LocalAddr(0x8888); + sleep(1); + tcflush(fd,TCIOFLUSH); + bModifyAddr = true; + GlobalConfig::Zigbee_G.MyAddr = 0x8888; + GlobalConfig::EnterZigBeeWaveTransmittingFlag_G = NO_ENTER_TRANSMITTING_STATUS; + GlobalConfig::EnterZigBeeWaveTransmittingCnt_G = 0; + std::vector().swap(m_VecWaveData); + break; + } + + if(command == 32){ + LOG_INFO("bUpdateconfig command = %d ShortAddr :%s\n",command,strShortAddr.c_str()); + memcpy(RecvBuf,(char*)&UartRecvBuf[i],12); + //for(int j = i; j < i+12;j++){ + // print_info("%02X ",UartRecvBuf[j]&0xFF); + //} + + if(!CheckCrc(RecvBuf,11)){ + LOG_INFO("CheckCrc error command 20 \n"); + mPackgeIndex = -1; + tcflush(fd,TCIOFLUSH); + sleep(1); + modify_LocalAddr(0x8888); + sleep(1); + tcflush(fd,TCIOFLUSH); + bModifyAddr = true; + GlobalConfig::Zigbee_G.MyAddr = 0x8888; + GlobalConfig::EnterZigBeeWaveTransmittingFlag_G = NO_ENTER_TRANSMITTING_STATUS; + GlobalConfig::EnterZigBeeWaveTransmittingCnt_G = 0; + break; + } + bUpdate = true; + m_TimeStamp = 0; + DealRecvData(RecvBuf); + break; + }else if(!bUpdatePre && !bUpdateconfig && (command == 3 || command == 4 || command == 5)){ + if(!CheckCrc(&UartRecvBuf[i],99)){ + m_TimeStamp = 0; + mPackgeIndex = -1; + LOG_INFO("CheckCrc error ShortAddr :%s command = %d\n",strShortAddr.c_str(),command); + print_error("CheckCrc error ShortAddr :%s \n",strShortAddr.c_str()); + char tmp[10]={0x00}; + char tmp2[10]={0x00}; + for(int j = 0; j < 100;j++){ + sprintf(tmp,"%02x ",UartRecvBuf[i + j] & 0xff); + strcat(tmp2,tmp); + } + LOG_ERROR("error str = %s\n",tmp2); + print_info("\n"); + tcflush(fd,TCIOFLUSH); + sleep(1); + modify_LocalAddr(0x8888); + bModifyAddr = true; + sleep(1); + tcflush(fd,TCIOFLUSH); + GlobalConfig::Zigbee_G.MyAddr = 0x8888; + GlobalConfig::EnterZigBeeWaveTransmittingFlag_G = NO_ENTER_TRANSMITTING_STATUS; + GlobalConfig::EnterZigBeeWaveTransmittingCnt_G = 0; + std::vector().swap(m_VecWaveData); + break; + } + mlastSize = 0; + lastSize = bytesRead - i; + //print_info("laseSize = %d , i = %d\n",lastSize,i); + if(lastSize < 100 && lastSize > 0){ + memcpy(mUartRecvTmpBuf,(char*)&UartRecvBuf[bytesRead-lastSize],lastSize); + mlastSize = lastSize; + break; + } + memcpy(RecvBuf,(char*)&UartRecvBuf[i],100); + DealDataNodeWave(RecvBuf); + }else if(!bUpdate && !bUpdateconfig && (command == 1 || command == 2 || command == 6 || command == 7)){ + char RecvBuf[100] = {0x00}; + memcpy(RecvBuf,&UartRecvBuf[i],100); + if(!CheckCrc(RecvBuf,99)){ + LOG_INFO("CheckCrc error ShortAddr :%s command = %d \n",strShortAddr.c_str(),command); + break; + } + DealRecvData(RecvBuf); + + }else if(bUpdate && !bUpdateconfig && (command == 1 || command == 2 || command == 6 || command == 7)){ + + print_info("m_strDestShortAddr = %s,strShortAddr = %s,waittime = %d\n",\ + m_strDestShortAddr.c_str(),strShortAddr.c_str(),waittime); + //if(waittime >= 2 || m_strDestShortAddr == strShortAddr) + { + char RecvBuf[100] = {0x00}; + memcpy(RecvBuf,&UartRecvBuf[i],100); + DealRecvData(RecvBuf); + LOG_INFO("Online = %s,command = %d\n",strShortAddr.c_str(),command); + waittime = 0; + bUpdate = false; + bUpdatePre = false; + m_strDestShortAddr = ""; + GlobalConfig::Zigbee_G.MyAddr = 0x8888; + GlobalConfig::EnterZigBeeWaveTransmittingFlag_G = NO_ENTER_TRANSMITTING_STATUS; + GlobalConfig::EnterZigBeeWaveTransmittingCnt_G = 0; + //break; + }/*else if(m_strDestShortAddr != strShortAddr){ + usleep(100000); + waittime ++; + }*/ + + }else if(command == 34 && bUpdateconfig){ + LOG_INFO("bUpdateconfig command = %d ShortAddr :%s\n",command,strShortAddr.c_str()); + memset(RecvBuf,0x00,sizeof(RecvBuf)); + print_info("bUpdateconfig ShortAddr :%s\n",strShortAddr.c_str()); + //memcpy(RecvBuf,(char*)&UartRecvBuf[i],100); + /*for(int j = i; j < i+100;j++){ + print_info("%02X ",UartRecvBuf[j]&0xFF); + }*/ + m_TimeStamp = 0; + //if(!CheckCrc((char*)&UartRecvBuf[i],99)) + { + char whereCon[1024] = {0}; + char updateSql[1024] = { 0 }; + char buf[20]={0x00}; + sprintf(buf, "%02x%02x", UartRecvBuf[i+3]&0xFF, UartRecvBuf[i+4]&0xFF);//Zigbee 本地地址 2 byte + sprintf(updateSql, "UpdateFlag = 1"); + sprintf(whereCon, "zigbeeShortAddr='%s'", buf); + sql_ctl->UpdateTableData(T_SENSOR_INFO(TNAME), updateSql, whereCon); + //string strData = sql_ctl->GetNodeConfigureInfor(whereCon); + //data_publish(strData.c_str(), GlobalConfig::Topic_G.mPubConfig.c_str()); + bUpdateconfig = false; + mPackgeIndex = -1; + tcflush(fd,TCIOFLUSH); + sleep(1); + modify_LocalAddr(0x8888); + bModifyAddr = true; + sleep(1); + tcflush(fd,TCIFLUSH); + GlobalConfig::Zigbee_G.MyAddr = 0x8888; + GlobalConfig::EnterZigBeeWaveTransmittingFlag_G = NO_ENTER_TRANSMITTING_STATUS; + GlobalConfig::EnterZigBeeWaveTransmittingCnt_G = 0; + break; + } + break; + }else if(command == 35){ + LOG_INFO("command = %d ShortAddr :%s\n",command,strShortAddr.c_str()); + for(int j = i; j < i+100;j++){ + printf("%02X ",UartRecvBuf[j]&0xFF); + } + char whereCon[1024] = {0}; + char updateSql[1024] = { 0 }; + char tableName[100]={0x00}; + sprintf(whereCon, "zigbeeShortAddr='%s'", strShortAddr.c_str()); + vec_t vecDataNodeNo = sql_ctl->GetDataSingleLine(T_SENSOR_INFO(TNAME), " dataNodeNo,LooseValue ", whereCon); + memset(whereCon,0x00,sizeof(whereCon)); + sprintf(updateSql, "zigbeeSignal = '%02d' ",UartRecvBuf[i+14]&0xFF);//zigbeeRSSIType = 0 传感器获取网关信号强度 + sprintf(whereCon, "dataNodeNo='%s' and timeStamp = '%s'", (char*)vecDataNodeNo[0].c_str(),strTimetamp.c_str()); + sprintf(tableName,"t_dataStatic_%s",(char*)vecDataNodeNo[0].c_str()); + sql_ctl->UpdateTableData(tableName, updateSql, whereCon); + } + mPackgeIndex = (unsigned int)UartRecvBuf[i+6]; + + } + else{ + continue; + } + }else if(UartRecvBuf[i] == head1[0]){ + char buf[6]={0x00}; + sprintf(&buf[0], "%02X", UartRecvBuf[i]&0xFF); + sprintf(&buf[2], "%02X", UartRecvBuf[i+1]&0xFF); + sprintf(&buf[4], "%02X", UartRecvBuf[i+2]&0xFF); + std::string strHeadFlag(buf); + if ( 0 == strHeadFlag.compare("ABBCCD")) { + char buf[8]={0x00}; + sprintf(buf, "%02d", UartRecvBuf[i+3]&0xFF); + int command = atoi(buf); + print_info("command = %d\n",command); + if(command == 209){ + UpdateZigbeeInfo(&UartRecvBuf[i]); + }else if(command == 220){//DC + bModifyAddr = false; + LOG_INFO("zigbeeShortAddr = %s , ret = %02d\n",m_strDestShortAddr.c_str(),UartRecvBuf[i+6]&0xFF); + if(UartRecvBuf[i+6]&0xFF != 00){ + modify_LocalAddr(0x8888); + } + } + } + }else if(UartRecvBuf[i] == head2[0]){ + char buf[6]={0x00}; + sprintf(&buf[0], "%02X", UartRecvBuf[i]&0xFF); + sprintf(&buf[2], "%02X", UartRecvBuf[i+1]&0xFF); + sprintf(&buf[4], "%02X", UartRecvBuf[i+2]&0xFF); + std::string strHeadFlag(buf); + if ( 0 == strHeadFlag.compare("DEDFEF")) { + char buf[8]={0x00}; + sprintf(buf, "%02d", UartRecvBuf[i+3]&0xFF); + int command = atoi(buf); + print_info("command = %d\n",command); + char tmp[16] = {0x00}; + if(command == 209){//D1 + pTestRecv(command); + }else if(command == 219){//DB + pTestRecv(command); + }else if(command == 220){//DC + bModifyAddr = false; + print_info("%02x,%02x,%02x,%02x,%02x \n",UartRecvBuf[i],UartRecvBuf[i+1],UartRecvBuf[i+2],UartRecvBuf[i+3],UartRecvBuf[i+4]); + LOG_INFO("zigbeeShortAddr = %s , ret = %02d\n",m_strDestShortAddr.c_str(),UartRecvBuf[i+4]&0xFF); + + //pTestRecv(command); + }else if(command == 218){//DA + LOG_INFO("zigbeeShortAddr = %s , signal = %02d\n",m_strDestShortAddr.c_str(),UartRecvBuf[i+6]&0xFF); + char whereCon[1024] = {0}; + char updateSql[1024] = { 0 }; + char tableName[100]={0x00}; + bZigbeeSinal = false; + sprintf(whereCon, "zigbeeShortAddr='%s'", m_strDestShortAddr.c_str()); + vec_t vecDataNodeNo = sql_ctl->GetDataSingleLine(T_SENSOR_INFO(TNAME), " dataNodeNo,LooseValue ", whereCon); + memset(whereCon,0x00,sizeof(whereCon)); + sprintf(updateSql, "zigbeeSignal = '%02d' ",UartRecvBuf[i+6]&0xFF);//zigbeeRSSIType = 1 网关获取传感器信号强度 + sprintf(whereCon, "dataNodeNo='%s' and timeStamp = '%s'", (char*)vecDataNodeNo[0].c_str(),strTimetamp.c_str()); + sprintf(tableName,"t_dataStatic_%s",(char*)vecDataNodeNo[0].c_str()); + sql_ctl->UpdateTableData(tableName, updateSql, whereCon); + Json::Value jsBody,jsonVal; + Json::FastWriter showValue; + char looseValue[10]={0x00}; + readStringValue("config", "loose",looseValue,(char*)GlobalConfig::Config_G.c_str()); + if(atof(looseValue) < atof(vecDataNodeNo[1].c_str())){ + jsBody["looseStatus"] = "1"; + }else{ + jsBody["looseStatus"] = "0"; + } + + jsonVal["cmd"] = "52"; + jsBody["timeStamp"] = strTimetamp; + jsBody["dataNodeNo"] = vecDataNodeNo[0]; + jsBody["zigbeeSignal"] = UartRecvBuf[i+6]&0xFF; + std::string dataBody = showValue.write(jsBody); + jsonVal["cmdBody"] = dataBody; + data_publish(showValue.write(jsonVal).c_str(), GlobalConfig::Topic_G.mPubConfig.c_str()); + + //pTestRecv(command); + } + } + } + + } + strTime = GetLocalTimeWithMs(); +// LOG_INFO("findRecvPackage strTime2 = %s\n",strTime.c_str()); +} +void Uart::ReadHandle(char* pUartRecvBuf,size_t bytesRead) +{ +/*try{ if (ec) { mRdLength = 0; -// ReadFromUart(); + ReadFromUart(); return ; } - else + else*/ { //长度检测 - printf("recv uart len in ZigBee short address %4x : %d\n recv uart data:", + char UartRecvBuf[BUF_LENGTH]={0x00}; + memcpy(UartRecvBuf,pUartRecvBuf,bytesRead); + print_info("recv uart len in ZigBee short address %4x : %d\n recv uart data:", (unsigned short)GlobalConfig::Zigbee_G.MyAddr, bytesRead); - for ( int i = 0; i < bytesRead; i++) - print_debug("%02X ",mUartRecvBuf[i]&0xFF); + // for ( int i = 0; i < bytesRead; i++) +// print_debug("%02X ",mUartRecvBuf[i]&0xFF); int iPackageSize = bytesRead / 100; if (0 == iPackageSize) { @@ -139,42 +751,39 @@ try{ if((unsigned short)GlobalConfig::Zigbee_G.MyAddr == (unsigned short)0x9999){ - for (int j = 0; j < iPackageSize; j++) { - char buf[6]; - char mUartRecvPackage[100] = {0}; - - memcpy(mUartRecvPackage, mUartRecvBuf+7-offSize, 100); - Count = Count - 100; - sprintf(&buf[0], "%02X", mUartRecvPackage[0]&0xFF); - sprintf(&buf[2], "%02X", mUartRecvPackage[1]&0xFF); - sprintf(&buf[4], "%02X", mUartRecvPackage[2]&0xFF); - std::string strHeadFlag(buf); - print_info("data package head command type:%s,Size = %d\n", strHeadFlag.c_str(),offSize); - if ( 0 == strHeadFlag.compare("AA55AA") ) { - DealRecvData(mUartRecvPackage); - } - } - offSize = 7; }else{ for (int j = 0; j < iPackageSize; j++) { - char buf[6]; - char mUartRecvPackage[100] = {0}; - // 多包分包,解包, - if (Count < 100) { - memcpy(mUartRecvPackage, &mUartRecvBuf[j * 100], Count); - } else { - memcpy(mUartRecvPackage, &mUartRecvBuf[j * 100], 100); - Count = Count - 100; - } + char buf[6]; + char mUartRecvPackage[100] = {0}; + char ShortAddr[8]; - sprintf(&buf[0], "%02X", mUartRecvPackage[0]&0xFF); - sprintf(&buf[2], "%02X", mUartRecvPackage[1]&0xFF); - sprintf(&buf[4], "%02X", mUartRecvPackage[2]&0xFF); + // 多包分包,解包, + if (Count < 100) { + memcpy(mUartRecvPackage, &UartRecvBuf[j * 100], Count); + } else { + memcpy(mUartRecvPackage, &UartRecvBuf[j * 100], 100); + Count = Count - 100; + } - //sprintf(&buf1[0], "%02X", mUartRecvPackage[3]&0xFF); + sprintf(&buf[0], "%02X", mUartRecvPackage[0]&0xFF); + sprintf(&buf[2], "%02X", mUartRecvPackage[1]&0xFF); + sprintf(&buf[4], "%02X", mUartRecvPackage[2]&0xFF); + sprintf(ShortAddr, "%02x%02x", mUartRecvPackage[3]&0xFF, mUartRecvPackage[4]&0xFF); + if(bUpdate){//waitting for the upated node 4s + std::string strShortAddr(ShortAddr); + print_info("m_strDestShortAddr = %s,strShortAddr = %s,waittime = %d\n",m_strDestShortAddr.c_str(),strShortAddr.c_str(),waittime); + if(waittime >= 40 || m_strDestShortAddr == strShortAddr){ + LOG_INFO("Online = %s\n",strShortAddr.c_str()); + waittime = 0; + bUpdate = false; + m_strDestShortAddr = ""; + }else if(m_strDestShortAddr != strShortAddr){ + usleep(100000); + waittime ++; + return ; + } + } std::string strHeadFlag(buf); - //std::string strType(buf1); - print_info("data package head command type:%s\n", strHeadFlag.c_str()); if ( 0 == strHeadFlag.compare("ABBCCD") && (0xD1 == (mUartRecvPackage[3]&0xFF))) { @@ -191,12 +800,12 @@ try{ }} } - //读串口循环 +/* //读串口循环 ReadFromUart(); } catch(...) { print_error("PlatFormInit exception happend.\n"); // LOG_ERROR("%s,%d\n", __FUNCTION__, __LINE__); -} +}*/ } void Uart::setCallBack(onReceiveUart _callback) @@ -236,9 +845,36 @@ void Uart::DataAnalysis_W(DevData &pData,bool pFlag) void Uart::UpdateZigbeeInfoCtrl() { - char buf[5] = {0xAB, 0xBC, 0xCD, 0xD1, 0x05}; + /* char buf[5] = {0xAB, 0xBC, 0xCD, 0xD1, 0x05}; WriteToUart(buf, 5); - boost::this_thread::sleep(boost::posix_time::seconds(1)); + sleep(1);*/ +// ReadFromUart(); + char command[5]={0x00}; + unsigned char command1[100]={0x00}; + command[0] = 0xab; + command[1] = 0xbc; + command[2] = 0xcd; + command[3] = 0xd1; + command[4] = 0xaa; + WriteToUart(command,5); + LOG_INFO("UpdateZigbeeInfoCtrl \n"); + /*for ( int i = 0; i < 20; i++) + print_info("%02X ",command[i]); + print_info("\n");*/ + /*int ret = write_data(fd, (char*)command, 5); + if (ret < 0) { + perror("write"); + return ; + } + // sleep(1); + + /*ret = read_data(fd, (char *)command1, 100, 10); + printf("ret = %d\n",ret); + if (ret <= 4) { + printf("info get error!\n"); + return ; + } + UpdateZigbeeInfo((char*)command1);*/ } void Uart::UpdateZigbeeInfo(const char *pData) @@ -248,11 +884,11 @@ void Uart::UpdateZigbeeInfo(const char *pData) GlobalConfig::Zigbee_G = *((ZIGBEE *)pData); char buff[8]; sprintf(buff, "%02d", pData[36]&0xFF); - GlobalConfig::ZigbeeInfo_G.DevMode = boost::lexical_cast(buff); + GlobalConfig::ZigbeeInfo_G.DevMode = atoi(buff); memset(buff, 0, 8); sprintf(buff, "%02d", pData[37]&0xFF); - GlobalConfig::ZigbeeInfo_G.Channel = boost::lexical_cast(buff); + GlobalConfig::ZigbeeInfo_G.Channel = atoi(buff); memset(buff, 0, 8); sprintf(buff, "%02x%02x", pData[38]&0xFF, pData[39]&0xFF); @@ -265,10 +901,59 @@ void Uart::UpdateZigbeeInfo(const char *pData) memset(buff, 0, 8); sprintf(buff, "%02x%02x", pData[50]&0xFF, pData[51]&0xFF); - GlobalConfig::ZigbeeInfo_G.DstAddr = std::string(buff); + GlobalConfig::ZigbeeInfo_G.DstAddr = std::string(buff); - print_info("local zigbee module info Mode : %d Chan : %d PanID : %s MyAddr : %s DstAddr : %s\n", GlobalConfig::ZigbeeInfo_G.DevMode, GlobalConfig::ZigbeeInfo_G.Channel, - GlobalConfig::ZigbeeInfo_G.PanID.c_str(),GlobalConfig::ZigbeeInfo_G.MyAddr.c_str(), GlobalConfig::ZigbeeInfo_G.DstAddr.c_str()); + memset(buff, 0, 8); + sprintf(buff, "%d", pData[62]); + GlobalConfig::ZigbeeInfo_G.RetryNum = std::string(buff); + + memset(buff, 0, 8); + sprintf(buff, "%d", pData[63]); + GlobalConfig::ZigbeeInfo_G.TranTimeout = std::string(buff); + + LOG_INFO("local zigbee module info Mode : %d Chan : %d PanID : %s MyAddr : %s DstAddr : %s,RetryNum:%s,TranTimeout:%s\n", GlobalConfig::ZigbeeInfo_G.DevMode, GlobalConfig::ZigbeeInfo_G.Channel, + GlobalConfig::ZigbeeInfo_G.PanID.c_str(),GlobalConfig::ZigbeeInfo_G.MyAddr.c_str(), GlobalConfig::ZigbeeInfo_G.DstAddr.c_str(),GlobalConfig::ZigbeeInfo_G.RetryNum.c_str(),GlobalConfig::ZigbeeInfo_G.TranTimeout.c_str()); +// if(GlobalConfig::ZigbeeInfo_G.MyAddr != "8888"){ +// modify_LocalAddr(0x8888); +// +// LOG_INFO("zigbee Update \n"); +// GlobalConfig::ZigbeeInfo_G.MyAddr = "8888"; +// } + LOG_INFO("PanID = %s,MacAddr_G= %s\n",GlobalConfig::ZigbeeInfo_G.PanID.c_str(),GlobalConfig::MacAddr_G.c_str()); +// if(GlobalConfig::ZigbeeInfo_G.PanID != GlobalConfig::MacAddr_G.substr(8)){ +// string strPanId = GlobalConfig::MacAddr_G.substr(8); +// long lShortAddr = strtol(strPanId.c_str(), NULL, 16); +// unsigned short panid = lShortAddr & 0xffff; +// //modify_LocalPanID(panid); +// WritePanId2Zigbee(panid); +// usleep(100000); +// LOG_ERROR("PanID error"); +// } + + + std::string strchan = ReadStrByOpt(ZIGBEECONFIG, "Zigbee", "channel"); + LOG_INFO("Channel = %d,strchan = %s\n",GlobalConfig::ZigbeeInfo_G.Channel,strchan.c_str()); +// if(GlobalConfig::ZigbeeInfo_G.Channel != atoi(strchan.c_str())){ +// unsigned short Chan = (unsigned short)strtol(strchan.c_str(), NULL, 10); +// if(Chan > 10 && Chan < 27) +// { +// //modify_Localchannel(Chan); +// WriteChanl2Zigbee(Chan); +// usleep(100000); +// } +// LOG_ERROR("channel error"); +// } + + std::string strType = ReadStrByOpt(SYSTEMINFOFILE, "ZigbeeType", "type"); + print_info("TranTimeout = %02x,strType = %s \n",GlobalConfig::Zigbee_G.TranTimeout,strType.c_str()); + if(strType == "aw21"){ + unsigned short TranTimeout = 0x0A; + WriteTranTimeout2Zigbee(TranTimeout); + } + if( strType == "zm5161"){ + unsigned short TranTimeout = 0x03; + WriteTranTimeout2Zigbee(TranTimeout); + } // LOG_INFO("[UpdateZigbeeInfo---] ZigBee PanID: %s ; Channel: %d ; MyAddr : %s ",GlobalConfig::ZigbeeInfo_G.PanID.c_str(),GlobalConfig::ZigbeeInfo_G.Channel,GlobalConfig::ZigbeeInfo_G.MyAddr.c_str()); } @@ -284,26 +969,53 @@ bool Uart::ReadUpdatePackge(unsigned char* pDestShortAddr) { //compare hardversion in update list std::vector strHWversion; - std::string strFileName = ""; - strHWversion = ReadStrByOpt("/opt/update/DataNode/config.json",strFileName); + std::string strFileName = "",strSoftVersion = ""; + std::vector vecDataNodeUpdate; + vecDataNodeUpdate = ReadStrUpdate("/opt/DataNode/config.json"); char gethardVersion_sql[32] = { 0 }; + char selectsql[1024]={ 0 }; sprintf(gethardVersion_sql, "zigbeeShortAddr='%02x%02x'", pDestShortAddr[0],pDestShortAddr[1]); - std::string hardVersion = sql_ctl->GetData(T_SENSOR_INFO(TNAME), T_SENSOR_INFO(HARDVERSION), gethardVersion_sql); - int thisindex = -1; - for(int i = 0; i < strHWversion.size();i++){ - if(hardVersion == strHWversion[i]){ - thisindex = i; - break; - } + sprintf(selectsql,"%s,%s",T_SENSOR_INFO(HARDVERSION),T_SENSOR_INFO(SOFTVERSION)); + vec_t vecResult = sql_ctl->GetDataSingleLine(T_SENSOR_INFO(TNAME), selectsql, gethardVersion_sql); + if(vecResult.size() < 1){ + return false; } - printf("thisindex = %d\n",thisindex); + print_info("hardversion %s,softversion %s\n",vecResult[0].c_str(),vecResult[1].c_str()); + int thisindex = -1; + int flag = -1; + for(int j = 0; j < vecDataNodeUpdate.size();j++){ + for(int i = 0; i < vecDataNodeUpdate[j].hwVersion.size();i++){ + if(vecResult[0] == vecDataNodeUpdate[j].hwVersion[i]){ + if(vecResult[1] == vecDataNodeUpdate[j].strSoftVersion){ + flag = 0; + break; + }else{ + thisindex = i; + strFileName = vecDataNodeUpdate[j].strUpdataFileName; + break; + } + } + } + if(thisindex >= 0 || flag == 0) + break; + } + if(thisindex < 0) return false; + +// if(!strncmp(vecResult[0].c_str(),"3",1)){ +// WriteTranTimeout2Zigbee(0x03); +// }else if(!strncmp(vecResult[0].c_str(),"4",1)){ +// WriteTranTimeout2Zigbee(0x0A); +// } + + print_info("thisindex = %d\n",thisindex); + FILE * pFile=NULL; int thisSize = 0; - strFileName = "/opt/update/DataNode/" + strFileName; - printf("strFileName = %s\n",strFileName.c_str()); - pFile = fopen (strFileName.c_str(),"rb"); + DataNodeUpdateFile = "/opt/DataNode/" + strFileName; + print_info("strFileName = %s\n",DataNodeUpdateFile.c_str()); + pFile = fopen (DataNodeUpdateFile.c_str(),"rb"); if (pFile==NULL){ return false; } @@ -315,18 +1027,24 @@ bool Uart::ReadUpdatePackge(unsigned char* pDestShortAddr) fclose (pFile); } - unsigned short localAddr = 0x9999; - WriteShortAddr_DistAddr2Zigbee(localAddr,pDestShortAddr); +// WriteShortAddr_DistAddr2Zigbee(localAddr,pDestShortAddr);//永久参数配置 +/* char tmpbuf[8] = {0x00}; + * unsigned short localAddr = 0x9999; + sprintf(tmpbuf,"%02x%02x",pDestShortAddr[0],pDestShortAddr[1]); + m_strDestShortAddr = std::string(tmpbuf); + modify_distaddr_info(localAddr,"",pDestShortAddr);//临时参数配置 + GlobalConfig::Zigbee_G.MyAddr = 0x9999;*/ + unsigned char Data[12]={0x00}; unsigned char size[4]={0x00}; - printf("thisSize = %d\n",thisSize); + print_info("thisSize = %d\n",thisSize); //帧头[3byte] 节点地址[2byte] 数据类型[1byte] 序号[1byte] 升级包大小[4byte] CRC校验[1byte] Data[0]=0xAA; Data[1]=0x55; Data[2]=0xAA; Data[3]=pDestShortAddr[0]; Data[4]=pDestShortAddr[1]; - Data[5]=0x07; + Data[5]=0x20; Data[6]=0x00; int2bytes(thisSize,size,4); Data[7]=size[3]; @@ -338,81 +1056,356 @@ bool Uart::ReadUpdatePackge(unsigned char* pDestShortAddr) tmp +=Data[i]; } Data[11]=tmp; + sleep(1); WriteToUart((const char*)Data,12); - boost::this_thread::sleep(boost::posix_time::milliseconds(1000)); - ReadFromUart(); + string strTime = GetLocalTimeWithMs(); + LOG_INFO("ReadUpdatePackge strTime = %s\n",strTime.c_str()); return true; } void Uart::UpdateWirelessNode(unsigned short shortAdd) { - LOG_INFO("UpdateWirelessNode id = %02x %02x\n",UINT16_HIGH(shortAdd),UINT16_LOW(shortAdd)); + string strTime = GetLocalTimeWithMs(); + LOG_INFO("UpdateWirelessNode start = %s UpdateWirelessNode id = %02x %02x\n",strTime.c_str(),UINT16_HIGH(shortAdd),UINT16_LOW(shortAdd)); + /*std::string strFileName = "",strSoftVersion = ""; + std::vector vecDataNodeUpdate; + vecDataNodeUpdate = ReadStrUpdate("/opt/DataNode/config.json"); - std::string strFileName = ""; - ReadStrByOpt("/opt/update/DataNode/config.json",strFileName); - FILE * pFile=NULL; - int thisSize = 0; - char *buffer=NULL; - strFileName = "/opt/update/DataNode/" + strFileName; - pFile = fopen (strFileName.c_str(),"rb"); - if (pFile==NULL) perror ("Error opening file"); - else - { - while (fgetc(pFile) != EOF) { - ++thisSize; + char gethardVersion_sql[32] = { 0 }; + sprintf(gethardVersion_sql, "zigbeeShortAddr='%02x%02x'", UINT16_HIGH(shortAdd),UINT16_LOW(shortAdd)); + std::string SoftVersion = sql_ctl->GetData(T_SENSOR_INFO(TNAME), "softVersion", gethardVersion_sql); + + print_info("SoftVersion = %s\n",SoftVersion.c_str()); + LOG_INFO(" NOW SoftVersion = %s\n",SoftVersion.c_str());*/ + ////// + ////// + //strFileName = "/opt/DataNode/" + strFileName; + FILE * pFile=NULL; + int thisSize = 0; + char *buffer=NULL; + int resendCount = 0; + pFile = fopen (DataNodeUpdateFile.c_str(),"rb"); + if (pFile==NULL) perror ("Error opening file"); + else + { + while (fgetc(pFile) != EOF) { + ++thisSize; + } + rewind(pFile); + buffer = (char*)malloc(thisSize);// + fread (buffer, sizeof (char), thisSize, pFile); + fclose (pFile); + + int Count = thisSize / 92; + int lastSize = thisSize % 92; + unsigned char UpdateData[100]={0x00}; + //帧头[3byte] 节点地址[2byte] 数据类型[1byte] 序号[1byte] 数据包[92byte] CRC校验[1byte] + print_info("Start Update!!! file Size = %d\n",thisSize); + unsigned char tmp = 0x00; + gpio_set(GlobalConfig::GPIO_G.zigAckreset,0); + //boost::this_thread::sleep(boost::posix_time::milliseconds(1)); + usleep(1000); + gpio_set(GlobalConfig::GPIO_G.zigAckreset,1); + for(int j = 0; j < Count;j++){ + int time ,value; + UpdateData[0]=0xAA; + UpdateData[1]=0x55; + UpdateData[2]=0xAA; + UpdateData[3]=UINT16_HIGH(shortAdd); + UpdateData[4]=UINT16_LOW(shortAdd); + UpdateData[5]=0x21; + UpdateData[6]=0xff & j; + memcpy(&UpdateData[7],buffer+92*j,92); + tmp = 0x00; + for(int k = 0; k < 99;k++){ + tmp +=UpdateData[k]; + } + UpdateData[99] = tmp; +// RESEND: + WriteToUart((const char*)UpdateData,100); + if(gpio_read(GlobalConfig::GPIO_G.zigAckrep) == 48) + gpio_set(GlobalConfig::GPIO_G.zigAckreset,1); + time = 0; + do{ + value = gpio_read(GlobalConfig::GPIO_G.zigAckrep); + if(value == 49) + break; + usleep(10000); + time += 1; + }while(time < 250); + if(time >= 250){ +// resendCount++; +// if(resendCount < 3){ +// LOG_INFO(" RESEND gpio_read failed shortAdd %x %x,error index %d\n",UINT16_HIGH(shortAdd),UINT16_LOW(shortAdd),j); +// goto RESEND; +// } + LOG_INFO("gpio_read failed shortAdd %x %x,error index %d\n",UINT16_HIGH(shortAdd),UINT16_LOW(shortAdd),j); + print_red("gpio_read failed \n"); + GlobalConfig::EnterZigBeeWaveTransmittingFlag_G = NO_ENTER_TRANSMITTING_STATUS; + GlobalConfig::EnterZigBeeWaveTransmittingCnt_G = 0; + bUpdate = false; + goto endUpdate; + } + gpio_set(GlobalConfig::GPIO_G.zigAckreset,0); + usleep(2000); +// if(gpio_read(GlobalConfig::GPIO_G.zigAckrep) == 48) +// gpio_set(GlobalConfig::GPIO_G.zigAckreset,1); + memset(UpdateData,0x00,sizeof(UpdateData)); + //boost::this_thread::sleep(boost::posix_time::milliseconds(5)); + usleep(5000); + } + if(gpio_read(GlobalConfig::GPIO_G.zigAckrep) == 48) + gpio_set(GlobalConfig::GPIO_G.zigAckreset,1); + // printf("Count =%d,lastSize = %d\n",Count,lastSize); + if(lastSize > 0){ + UpdateData[0]=0xAA; + UpdateData[1]=0x55; + UpdateData[2]=0xAA; + UpdateData[3]=UINT16_HIGH(shortAdd); + UpdateData[4]=UINT16_LOW(shortAdd); + UpdateData[5]=0x21; + UpdateData[6]=0xff & Count; + memcpy(&UpdateData[7],buffer+92*Count,lastSize); + tmp = 0x00; + for(int k = 0; k < 99;k++){ + tmp +=UpdateData[k]; + } + UpdateData[99] = tmp; + WriteToUart((const char*)UpdateData,100); + boost::this_thread::sleep(boost::posix_time::milliseconds(10)); +// if(gpio_read(GlobalConfig::GPIO_G.zigAckrep) == 49){ +// gpio_set(GlobalConfig::GPIO_G.zigAckreset,0); +// boost::this_thread::sleep(boost::posix_time::milliseconds(1)); +// if(gpio_read(GlobalConfig::GPIO_G.zigAckrep) == 48)gpio_set(GlobalConfig::GPIO_G.zigAckreset,1); +// } + int time = 0; + do{ + int value = gpio_read(GlobalConfig::GPIO_G.zigAckrep); + if(value == 49){ + gpio_set(GlobalConfig::GPIO_G.zigAckreset,0); + usleep(10000); + if(gpio_read(GlobalConfig::GPIO_G.zigAckrep) == 48) + gpio_set(GlobalConfig::GPIO_G.zigAckreset,1); + break; + } + usleep(100); + time += 1; + }while(time < 2500); + if(time >= 2500){ + LOG_INFO("gpio_read failed shortAdd %x %x\n",UINT16_HIGH(shortAdd),UINT16_LOW(shortAdd)); + print_info("gpio_read failed \n"); + GlobalConfig::EnterZigBeeWaveTransmittingFlag_G = NO_ENTER_TRANSMITTING_STATUS; + GlobalConfig::EnterZigBeeWaveTransmittingCnt_G = 0; + bUpdate = false; + goto endUpdate; + } + memset(UpdateData,0x00,sizeof(UpdateData)); + } + print_info("Update END!!! file Size = %d\n",thisSize); + } + endUpdate: + free(buffer); + tcflush(fd,TCIFLUSH); + boost::this_thread::sleep(boost::posix_time::seconds(1)); + bUpdate = false; + bSendTimeStamp = false; + modify_LocalAddr(0x8888); + bModifyAddr = true; + boost::this_thread::sleep(boost::posix_time::milliseconds(100)); + GlobalConfig::Zigbee_G.MyAddr = 0x8888; + DataNodeUpdateFile = ""; + std::vector().swap(m_VecWaveData); + // WriteShortAddr2Zigbee(shortAddr); + // UpdateZigbeeInfoCtrl(); + GlobalConfig::EnterZigBeeWaveTransmittingFlag_G = NO_ENTER_TRANSMITTING_STATUS; + GlobalConfig::EnterZigBeeWaveTransmittingCnt_G = 0; + LOG_INFO("UpdateWirelessNode end"); +} +int Uart::UpdateConfig(unsigned char* pDestShortAddr) +{ + char whereCon[64] = { 0 }; + char selCon[100]={0x00}; + sprintf(whereCon, "zigbeeShortAddr='%02x%02x'", pDestShortAddr[0],pDestShortAddr[1]); + //std::string strUpdate = sql_ctl->GetData(T_SENSOR_INFO(TNAME), "UpdateFlag", whereCon); + vec_t vecResultNode = sql_ctl->GetDataSingleLine(T_SENSOR_INFO(TNAME), "*", whereCon); + if(vecResultNode.size() <= 0) + return -1; + if(vecResultNode[41] == "0") + { +// if(!strncmp(vecResult[1].c_str(),"3",1)){//zm5161 +// WriteTranTimeout2Zigbee(0x03); +// }else if(!strncmp(vecResult[1].c_str(),"4",1)){//aw21 +// WriteTranTimeout2Zigbee(0x0A); +// } + print_info("UpdateConfig\n"); + bUpdateconfig = true; + unsigned short localAddr = 0x9999; + // WriteShortAddr_DistAddr2Zigbee(localAddr,pDestShortAddr);//永久参数配置 + char tmpbuf[8] = {0x00}; + sprintf(tmpbuf,"%02x%02x",pDestShortAddr[0],pDestShortAddr[1]); + m_strDestShortAddr = std::string(tmpbuf); + modify_distaddr_info(localAddr,"",pDestShortAddr);//临时参数配置 + GlobalConfig::Zigbee_G.MyAddr = 0x9999; + boost::this_thread::sleep(boost::posix_time::milliseconds(500)); + vec_t vecResult; + sprintf(selCon,"featureInterVal,waveInterVal,range,samplingRate,ACCSampleTime,startBrands,stopBrands,\ + envelopeBandPass,faultFrequency,timeStamp,viff"); + vecResult = sql_ctl->GetDataSingleLine(T_SENSOR_INFO(TNAME),selCon,whereCon); + print_info("vecResult size = %d\n",vecResult.size()); + if(vecResult.size() < 1){ + return -1; } - rewind(pFile); - buffer = (char*)malloc(thisSize);// - fread (buffer, sizeof (char), thisSize, pFile); - fclose (pFile); - - int Count = thisSize / 92; - int lastSize = thisSize % 92; unsigned char UpdateData[100]={0x00}; //帧头[3byte] 节点地址[2byte] 数据类型[1byte] 序号[1byte] 数据包[92byte] CRC校验[1byte] - print_info("Start Update!!! file Size = %d\n",thisSize); + UpdateData[0]=0xAA; + UpdateData[1]=0x55; + UpdateData[2]=0xAA; + UpdateData[3]=pDestShortAddr[0]; + UpdateData[4]=pDestShortAddr[1]; + UpdateData[5]=0x22; + UpdateData[6]=0x00; + UpdateData[7]=0xAA; + UpdateData[8]=UINT16_LOW(atoi(vecResult[0].c_str())); + UpdateData[9]=UINT16_HIGH(atoi(vecResult[1].c_str())); + UpdateData[10]=UINT16_LOW(atoi(vecResult[1].c_str())); + int y = 0; + if(vecResultNode[17] == "01"){ + if(vecResult[3]=="3200"){ + y = 0; + }else if(vecResult[3]=="6400"){ + y = 1; + }else if(vecResult[3]=="12800"){ + y = 2; + }else if(vecResult[3]=="25600"){ + y = 3; + } + }else if(vecResultNode[17] == "02"){ + if(vecResult[3]=="8000"){ + y = 0; + }else if(vecResult[3]=="16000"){ + y = 1; + }else if(vecResult[3]=="24000"){ + y = 2; + }else if(vecResult[3]=="32000"){ + y = 3; + }else if(vecResult[3]=="48000"){ + y = 4; + }else if(vecResult[3]=="96000"){ + y = 5; + }else if(vecResult[3]=="192000"){ + y = 6; + } + } + int x = atoi(vecResult[2].c_str()); + UpdateData[21] = BUILD_UINT2(x,y); + UpdateData[22] = atoi(vecResult[4].c_str()) & 0xFF; + print_info("vecResult size = %s==%s==%s==%s\n",vecResult[5].c_str(),vecResult[6].c_str(),vecResult[7].c_str(),vecResult[8].c_str()); + vector vStart,vStop,vEnvelopeBandPass,vfaultFrequency; + boost::split( vStart, vecResult[5], boost::is_any_of( "," ), boost::token_compress_on ); + boost::split( vStop, vecResult[6], boost::is_any_of( "," ), boost::token_compress_on ); + boost::split( vEnvelopeBandPass, vecResult[7], boost::is_any_of( "," ), boost::token_compress_on ); + boost::split( vfaultFrequency, vecResult[8], boost::is_any_of( "," ), boost::token_compress_on ); + + UpdateData[23] = UINT16_HIGH(atoi(vStart[0].c_str())); + UpdateData[24] = UINT16_LOW(atoi(vStart[0].c_str())); + UpdateData[25] = UINT16_HIGH(atoi(vStop[0].c_str())); + UpdateData[26] = UINT16_LOW(atoi(vStop[0].c_str())); + + UpdateData[27] = UINT16_HIGH(atoi(vStart[1].c_str())); + UpdateData[28] = UINT16_LOW(atoi(vStart[1].c_str())); + UpdateData[29] = UINT16_HIGH(atoi(vStop[1].c_str())); + UpdateData[30] = UINT16_LOW(atoi(vStop[1].c_str())); + + UpdateData[31] = UINT16_HIGH(atoi(vStart[2].c_str())); + UpdateData[32] = UINT16_LOW(atoi(vStart[2].c_str())); + UpdateData[33] = UINT16_HIGH(atoi(vStop[2].c_str())); + UpdateData[34] = UINT16_LOW(atoi(vStop[2].c_str())); + + UpdateData[35] = UINT16_HIGH(atoi(vStart[3].c_str())); + UpdateData[36] = UINT16_LOW(atoi(vStart[3].c_str())); + UpdateData[37] = UINT16_HIGH(atoi(vStop[3].c_str())); + UpdateData[38] = UINT16_LOW(atoi(vStop[3].c_str())); + + UpdateData[39] = UINT16_HIGH(atoi(vStart[4].c_str())); + UpdateData[40] = UINT16_LOW(atoi(vStart[4].c_str())); + UpdateData[41] = UINT16_HIGH(atoi(vStop[4].c_str())); + UpdateData[42] = UINT16_LOW(atoi(vStop[4].c_str())); + + UpdateData[43] = UINT16_HIGH(atoi(vEnvelopeBandPass[0].c_str())); + UpdateData[44] = UINT16_LOW(atoi(vEnvelopeBandPass[0].c_str())); + UpdateData[45] = UINT16_HIGH(atoi(vEnvelopeBandPass[1].c_str())); + UpdateData[46] = UINT16_LOW(atoi(vEnvelopeBandPass[1].c_str())); + + UpdateData[47] = UINT16_HIGH(atoi(vfaultFrequency[0].c_str())); + UpdateData[48] = UINT16_LOW(atoi(vfaultFrequency[0].c_str())); + UpdateData[49] = UINT16_HIGH(atoi(vfaultFrequency[1].c_str())); + UpdateData[50] = UINT16_LOW(atoi(vfaultFrequency[1].c_str())); + + UpdateData[51] = UINT16_HIGH(atoi(vfaultFrequency[2].c_str())); + UpdateData[52] = UINT16_LOW(atoi(vfaultFrequency[2].c_str())); + UpdateData[53] = UINT16_HIGH(atoi(vfaultFrequency[3].c_str())); + UpdateData[54] = UINT16_LOW(atoi(vfaultFrequency[3].c_str())); + + UpdateData[55] = UINT32_HIGH_1(atoi(vecResult[9].c_str())); + UpdateData[56] = UINT32_HIGH_2(atoi(vecResult[9].c_str())); + UpdateData[57] = UINT32_LOW_1(atoi(vecResult[9].c_str())); + UpdateData[58] = UINT32_LOW_2(atoi(vecResult[9].c_str())); + + UpdateData[59] = (atoi(vecResult[10].c_str())) & 0xFF; unsigned char tmp = 0x00; - for(int j = 0; j < Count;j++){ - UpdateData[0]=0xAA; - UpdateData[1]=0x55; - UpdateData[2]=0xAA; - UpdateData[3]=UINT16_HIGH(shortAdd); - UpdateData[4]=UINT16_LOW(shortAdd); - UpdateData[5]=0x08; - UpdateData[6]=0xff & j; - memcpy(&UpdateData[7],buffer+92*j,92); - tmp = 0x00; - for(int k = 0; k < 99;k++){ - tmp +=UpdateData[k]; - } - UpdateData[99] = tmp; - WriteToUart((const char*)UpdateData,100); - boost::this_thread::sleep(boost::posix_time::milliseconds(200)); - memset(UpdateData,0x00,sizeof(UpdateData)); + for(int k = 0; k < 99;k++){ + tmp +=UpdateData[k]; } - printf("Count =%d,lastSize = %d\n",Count,lastSize); - if(lastSize > 0){ - UpdateData[0]=0xAA; - UpdateData[1]=0x55; - UpdateData[2]=0xAA; - UpdateData[3]=UINT16_HIGH(shortAdd); - UpdateData[4]=UINT16_LOW(shortAdd); - UpdateData[5]=0x08; - UpdateData[6]=0xff & Count; - memcpy(&UpdateData[7],buffer+92*Count,lastSize); - tmp = 0x00; - for(int k = 0; k < 99;k++){ - tmp +=UpdateData[k]; - } - UpdateData[99] = tmp; - WriteToUart((const char*)UpdateData,100); - memset(UpdateData,0x00,sizeof(UpdateData)); - } - print_info("Update END!!! file Size = %d\n",thisSize); + UpdateData[99] = tmp; + tcflush(fd,TCIFLUSH); + WriteToUart((const char*)UpdateData,100); + return 0; + }else{ + return -1; } - free(buffer); - ZigbeeInit(); - offSize = 0; - LOG_INFO("UpdateWirelessNode success"); + +} +void Uart::UpdateWirelessNodeTime(unsigned char* pDestShortAddr,int modifyaddr/*,int nodewaveindex,int nodetime,int nodeindex*/) +{ + if(modifyaddr) + modify_DistAddr(pDestShortAddr); + usleep(10000); + //print_info("nodewaveindex = %d,nodetime = %d,nodeindex = %d\n",nodewaveindex,nodetime,nodeindex); + char localtimestamp[32]={0x00}; + int millisecond = 0; + + string rtcTime = GetRTC(localtimestamp,millisecond); + LOG_INFO("ShortAddr = %02x%02x,rtcTime = %s,localtimestamp = %s,millisecond = %d,bSendTimeStamp = %d \n",pDestShortAddr[0],pDestShortAddr[1],rtcTime.c_str(),localtimestamp,millisecond,bSendTimeStamp); + // struct timeval tv; + // gettimeofday(&tv, NULL); + // int millisecond = tv.tv_usec / 1000; + + // sprintf(localtimestamp, "%ld", tv.tv_sec); + + unsigned char UpdateData[100]={0x00}; + UpdateData[0]=0xAA; + UpdateData[1]=0x55; + UpdateData[2]=0xAA; + UpdateData[3]=pDestShortAddr[0]; + UpdateData[4]=pDestShortAddr[1]; + UpdateData[5]=0x23; + UpdateData[6]=0x00; + UpdateData[7]=0x00; + UpdateData[8]=UINT32_LOW_2(atol(localtimestamp)); + UpdateData[9]=UINT32_LOW_1(atol(localtimestamp)); + UpdateData[10]=UINT32_HIGH_2(atol(localtimestamp)); + UpdateData[11]=UINT32_HIGH_1(atol(localtimestamp)); + UpdateData[12]=UINT16_LOW(millisecond); + UpdateData[13]=UINT16_HIGH(millisecond); + //UpdateData[13]=UINT16_HIGH(nodetime); + //UpdateData[14]=UINT16_LOW(nodetime); + //UpdateData[15]=UINT16_LOW(nodewaveindex); + //UpdateData[16]=UINT16_LOW(nodeindex); + unsigned char tmp = 0x00; + for(int k = 0; k < 99;k++){ + tmp += UpdateData[k]; + } + UpdateData[99] = tmp; + WriteToUart((const char*)UpdateData,100); } void Uart::DealRecvData(const char *pData) { @@ -421,7 +1414,7 @@ void Uart::DealRecvData(const char *pData) sprintf(buf, "%02d", pData[5]&0xFF); sprintf(shortAdd, "%02x%02x", pData[3]&0xFF,pData[4]&0xFF); unsigned short ushortAdd = BUILD_UINT16(pData[3]&0xFF,pData[4]&0xFF); - int flag = boost::lexical_cast(buf); + int flag = atoi(buf); print_info("the data package type(1,2,3,4,5,6) is %s,%x\n",buf,pData[5]&0xFF); switch (flag) @@ -434,7 +1427,7 @@ void Uart::DealRecvData(const char *pData) DealDataNodeFeature(pData, 0); } break; - case 3:{//0x03:长波形X轴 +/* case 3:{//0x03:长波形X轴 DealDataNodeWave(pData); } break; @@ -445,22 +1438,63 @@ void Uart::DealRecvData(const char *pData) case 5:{//0x05:长波形Z轴 DealDataNodeWave(pData); } - break; + break;*/ case 6:{//0x06:特征值+长波形 + //LOG_INFO("DealDataNodeFeature 06"); DealDataNodeFeature(pData, 1); } break; - case 7:{//0x07:升级 + case 32:{//升级 UpdateWirelessNode(ushortAdd); } break; + case 7:{ + DealDataNodeName(pData); + } + break; default: break; } } +void Uart::DealDataNodeName(const char* pData) +{ + bSendTimeStamp = false; + string strTime = GetLocalTimeWithMs(); + //LOG_INFO("DealDataNodeName Time = %s\n",strTime.c_str()); + unsigned char shortAdd[8]={0x00}; + char NodeName[64]={0x00}; + memcpy(shortAdd,&pData[3],2); + memcpy(NodeName,&pData[7],64); + //DealNodeSendTime((unsigned char*)shortAdd); + UpdateWirelessNodeTime((unsigned char*)shortAdd,1); + + for(int i = 0; i < 64;i++){ + sprintf(&NodeName[i * 2], "%02X", pData[7 + i]&0xFF); + } + + char gbkNodeName[128]={0x00}; + std::string strNodeName(NodeName); + print_info("strNodeName = %s\n",strNodeName.c_str()); + solve(gbkNodeName,NodeName); + print_info("gbkNodeName = %s\n",gbkNodeName); + string utfNodeName = GBKToUTF8(gbkNodeName); + print_info("utfNodeName = %s\n",utfNodeName.c_str()); + //LOG_INFO("gbkNodeName:%s \n",gbkNodeName); + //LOG_INFO("utfNodeName:%s \n",utfNodeName.c_str()); + unsigned short ushortAdd = BUILD_UINT16(pData[3]&0xFF,pData[4]&0xFF); + char whereCon[64] = { 0 }; + char uplCon[200]={0x00}; + sprintf(whereCon, "zigbeeShortAddr='%02x%02x'", shortAdd[0],shortAdd[1]); + print_info("whereCon = %s\n",whereCon); + sprintf(uplCon,"dataNodeName = '%s'",gbkNodeName); + int iRet = sql_ctl->UpdateTableData(T_SENSOR_INFO(TNAME),uplCon,whereCon,0); + string strData = sql_ctl->GetNodeConfigureInfor(whereCon); + iRet = data_publish(strData.c_str(), GlobalConfig::Topic_G.mPubConfig.c_str()); + +} void Uart::DealDataNodeInfo(const char *pData) { print_info("recv remote zigbee module info\n"); @@ -468,12 +1502,12 @@ void Uart::DealDataNodeInfo(const char *pData) char buf[32] = {0}; char chTemp = pRecvData->Data[0];//设备状态标志 1 byte DataNodeInfo dataNodeInfo; - dataNodeInfo.EquipSta = boost::lexical_cast(chTemp >> 2 & 0x1); - dataNodeInfo.TemTopFlag = boost::lexical_cast(chTemp >> 3 & 0x1); - dataNodeInfo.TemBotFlag = boost::lexical_cast(chTemp >> 4 & 0x1); - dataNodeInfo.ZigbeeFlag = boost::lexical_cast(chTemp >> 5 & 0x1); - dataNodeInfo.AccFlag = boost::lexical_cast(chTemp >> 6 & 0x1); - dataNodeInfo.InitFlag = boost::lexical_cast(chTemp >> 7 & 0x1); + dataNodeInfo.EquipSta = GET_BIT(chTemp, 2 ); + dataNodeInfo.TemTopFlag = GET_BIT(chTemp, 3 ); + dataNodeInfo.TemBotFlag = GET_BIT(chTemp , 4); + dataNodeInfo.ZigbeeFlag = GET_BIT(chTemp , 5); + dataNodeInfo.AccFlag = GET_BIT(chTemp ,6); + dataNodeInfo.InitFlag = GET_BIT(chTemp ,7); sprintf(buf, "%02x%02x%02x%02x%02x%02x%02x%02x", pRecvData->Data[1], pRecvData->Data[2], pRecvData->Data[3], pRecvData->Data[4], pRecvData->Data[5], pRecvData->Data[6], pRecvData->Data[7],pRecvData->Data[8]); @@ -481,10 +1515,9 @@ void Uart::DealDataNodeInfo(const char *pData) chTemp = pRecvData->Data[9];//硬件版本 1 byte memset(buf, 0, 32); - sprintf(buf, "%02x", chTemp); + sprintf(buf, "%.1f", 0.1*chTemp); dataNodeInfo.HardVersion = std::string(buf); - chTemp = pRecvData->Data[10];//软件版本 1 byte memset(buf, 0, 32); //sprintf(buf, "%02x", chTemp); @@ -507,17 +1540,17 @@ void Uart::DealDataNodeInfo(const char *pData) memset(buf, 0, 32); sprintf(buf, "%d", BUILD_UINT32(pRecvData->Data[23], pRecvData->Data[24], pRecvData->Data[25], pRecvData->Data[26])); - dataNodeInfo.WakeupTime = boost::lexical_cast(buf);//唤醒次数 4 byte + dataNodeInfo.WakeupTime = atoi(buf);//唤醒次数 4 byte printf("WakeupTime = %d\n",dataNodeInfo.WakeupTime); memset(buf, 0, 32); sprintf(buf, "%d", BUILD_UINT32(pRecvData->Data[27], pRecvData->Data[28], pRecvData->Data[29], pRecvData->Data[30])); - dataNodeInfo.StaticTime = boost::lexical_cast(buf);//特征值发送次数 4 byte + dataNodeInfo.StaticTime = atoi(buf);//特征值发送次数 4 byte printf("StaticTime = %d\n",dataNodeInfo.StaticTime); memset(buf, 0, 32); // sprintf(buf, "%d", BUILD_UINT32(pRecvData->Data[31], pRecvData->Data[32], pRecvData->Data[33], pRecvData->Data[34])); dataNodeInfo.WaveTime = BUILD_UINT32(pRecvData->Data[31], pRecvData->Data[32], pRecvData->Data[33], pRecvData->Data[34]);//原始波形发送次数 4 byte - printf("dataNodeInfo.WaveTime = %d\n",dataNodeInfo.WaveTime); + memset(buf, 0, 32); // sprintf(buf, "%02x%02x", pRecvData->Data[35], pRecvData->Data[36]); dataNodeInfo.BateryV = BUILD_UINT16(pRecvData->Data[35],pRecvData->Data[36]);//电池电压 2 byte @@ -530,23 +1563,21 @@ void Uart::DealDataNodeInfo(const char *pData) chTemp = pRecvData->Data[38]; memset(buf, 0, 32); sprintf(buf, "%d", chTemp); - dataNodeInfo.RSSI = boost::lexical_cast(buf); //无线信号强度 1 byte + dataNodeInfo.RSSI = atoi(buf); //无线信号强度 1 byte chTemp = pRecvData->Data[39]; memset(buf, 0, 32); sprintf(buf, "%02x", chTemp); dataNodeInfo.ConfigFlag = ((0 == std::string(buf).compare("aa")) ? 1 : 0); //配置标志 1 byte - memset(buf, 0, 32); - sprintf(buf, "%u%u", pRecvData->Data[40], pRecvData->Data[41]); - dataNodeInfo.FeatureInterVal = boost::lexical_cast(buf); //唤醒周期 2 byte - - chTemp = pRecvData->Data[42]; + chTemp = pRecvData->Data[40]; memset(buf, 0, 32); - // sprintf(buf, "%02x", chTemp); - sprintf(buf, "%d",(unsigned int)chTemp); // yxq - dataNodeInfo.WaveInterVal = boost::lexical_cast(buf);//原始波形发送周期 2 byte - printf("====WaveInterVal = %s\n",buf); + sprintf(buf, "%d", chTemp); + dataNodeInfo.FeatureInterVal = atoi(buf); //唤醒周期 1 byte + memset(buf, 0, 32); + // yxq + sprintf(buf, "%u%u", pRecvData->Data[41],pRecvData->Data[42]); + dataNodeInfo.WaveInterVal = atoi(buf);//原始波形发送周期 2 byte memset(buf, 0, 32); sprintf(buf, "%02x%02x", pRecvData->Data[43], pRecvData->Data[44]); //Zigbee PID 2 byte dataNodeInfo.ZigbeePanId = std::string(buf); @@ -554,36 +1585,82 @@ void Uart::DealDataNodeInfo(const char *pData) chTemp = pRecvData->Data[45]; memset(buf, 0, 32); sprintf(buf, "%d", chTemp); - dataNodeInfo.ZigbeeChannel = boost::lexical_cast(buf);//Zigbee 信道 1 byte + dataNodeInfo.ZigbeeChannel = atoi(buf);//Zigbee 信道 1 byte memset(buf, 0, 32); sprintf(buf, "%02x%02x", pRecvData->Data[46], pRecvData->Data[47]);//Zigbee 本地地址 2 byte - dataNodeInfo.ZigbeeShortAddr = std::string(buf); + dataNodeInfo.ZigbeeShortAddr = std::string(buf); + unsigned char shortAddr[2] = {0x00}; + memcpy(shortAddr,(unsigned char*)&pRecvData->Data[46],2); + modify_DistAddr(shortAddr);//修改目标地址 + string strTime = GetLocalTimeWithMs(); + //LOG_INFO("DealDataNodeInfo modify_DistAddr Time = %s\n",strTime.c_str()); + + //LOG_INFO("ZigbeeShortAddr = %s,SoftVersion = %s\n",dataNodeInfo.ZigbeeShortAddr.c_str(),dataNodeInfo.SoftVersion.c_str()); memset(buf, 0, 32); sprintf(buf, "%02x%02x", pRecvData->Data[48], pRecvData->Data[49]);//Zigbee 目标地址 2 byte dataNodeInfo.ZigbeeDesAddr = std::string(buf); + //print_info("ZigbeeDesAddr = %s\n",buf); //50 51 52=》序号23 zigbee重试间隔 memset(buf, 0, 32); sprintf(buf, "%02x", pRecvData->Data[50]);//Zigbee 发射功率 1 byte - dataNodeInfo.ZigbeePower = boost::lexical_cast(buf); + dataNodeInfo.ZigbeePower = atoi(buf); + //print_info("ZigbeePower = %s\n",buf); memset(buf, 0, 32); sprintf(buf, "%d", BUILD_UINT16(00,pRecvData->Data[51]));//Zigbee 重试次数 1 byte - dataNodeInfo.ZigbeeRetry = boost::lexical_cast(buf); + dataNodeInfo.ZigbeeRetry = atoi(buf); + //print_info("ZigbeeRetry = %s\n",buf); memset(buf, 0, 32); - sprintf(buf, "%02x", pRecvData->Data[52]);//Zigbee 重试间隔 1 byte - dataNodeInfo.ZigbeeRetryGap = boost::lexical_cast(buf); + sprintf(buf, "%d", BUILD_UINT16(00,pRecvData->Data[52]));//Zigbee 重试间隔 1 byte + dataNodeInfo.ZigbeeRetryGap = atoi(buf); + //print_info("ZigbeeRetryGap = %s\n",buf); - chTemp = pRecvData->Data[53]; - dataNodeInfo.Range = boost::lexical_cast(chTemp >> 2 & 0x3); - dataNodeInfo.SamplingRate = boost::lexical_cast(chTemp & 0x3); + + if(dataNodeInfo.ProductNo == "01"){ + chTemp = pRecvData->Data[53]; + unsigned char range = (chTemp >> 2) & 0x3; + dataNodeInfo.Range = range; + int SamplingRate = (chTemp & 0x3); + print_info("SamplingRate = %d\n",SamplingRate); + if(SamplingRate == 0){ + dataNodeInfo.SamplingRate = 3200; + }else if(SamplingRate == 1){ + dataNodeInfo.SamplingRate = 6400; + }else if(SamplingRate == 2){ + dataNodeInfo.SamplingRate = 12800; + }else if(SamplingRate == 3){ + dataNodeInfo.SamplingRate = 25600; + } + }else if(dataNodeInfo.ProductNo == "02"){ + chTemp = pRecvData->Data[53]; + unsigned char range = (chTemp >> 3) & 0x7; + dataNodeInfo.Range = range; + int SamplingRate = (chTemp & 0x7); + print_info("SamplingRate = %d\n",SamplingRate); + if(SamplingRate == 0){ + dataNodeInfo.SamplingRate = 8000; + }else if(SamplingRate == 1){ + dataNodeInfo.SamplingRate = 16000; + }else if(SamplingRate == 2){ + dataNodeInfo.SamplingRate = 24000; + }else if(SamplingRate == 3){ + dataNodeInfo.SamplingRate = 32000; + }else if(SamplingRate == 4){ + dataNodeInfo.SamplingRate = 48000; + }else if(SamplingRate == 5){ + dataNodeInfo.SamplingRate = 96000; + }else if(SamplingRate == 6){ + dataNodeInfo.SamplingRate = 192000; + } + } // 54=》序号25 ACC采样时间 memset(buf, 0, 32); - sprintf(buf, "%02x", pRecvData->Data[54]);//ACC 采样时间 1 byte - dataNodeInfo.ACCSampleTime = boost::lexical_cast(buf); + sprintf(buf, "%u", pRecvData->Data[54]);//ACC 采样时间 1 byte + dataNodeInfo.ACCSampleTime = atoi(buf); int iTemp = 0; //使用了55 56 59 60 63 64 67 68 71 72 @@ -593,9 +1670,9 @@ void Uart::DealDataNodeInfo(const char *pData) iTemp = (int)strtol(buf, NULL, 16); if (0 == i) { - dataNodeInfo.StartBrands = boost::lexical_cast(iTemp); + dataNodeInfo.StartBrands = to_string(iTemp); } else { - dataNodeInfo.StartBrands += ("," + boost::lexical_cast(iTemp)); + dataNodeInfo.StartBrands += ("," + to_string(iTemp)); } } //使用了57 58 61 62 65 66 69 70 73 74 @@ -604,9 +1681,9 @@ void Uart::DealDataNodeInfo(const char *pData) sprintf(buf, "%02x%02x", pRecvData->Data[57 + j * 4], pRecvData->Data[57 + j * 4 + 1]); iTemp = (int)strtol(buf, NULL, 16); if (0 == j) { - dataNodeInfo.StopBrands = boost::lexical_cast(iTemp); + dataNodeInfo.StopBrands = to_string(iTemp); } else { - dataNodeInfo.StopBrands += ("," + boost::lexical_cast(iTemp)); + dataNodeInfo.StopBrands += ("," + to_string(iTemp)); } } @@ -614,13 +1691,13 @@ void Uart::DealDataNodeInfo(const char *pData) memset(buf, 0, 32); sprintf(buf, "%02x%02x", pRecvData->Data[75], pRecvData->Data[76]); iTemp = (int)strtol(buf, NULL, 16); - dataNodeInfo.EnvelopeBandPass = boost::lexical_cast(iTemp); + dataNodeInfo.EnvelopeBandPass = to_string(iTemp); memset(buf, 0, 32); sprintf(buf, "%02x%02x", pRecvData->Data[77], pRecvData->Data[78]); iTemp = (int)strtol(buf, NULL, 16); - dataNodeInfo.EnvelopeBandPass += ("," + boost::lexical_cast(iTemp)); + dataNodeInfo.EnvelopeBandPass += ("," + to_string(iTemp)); //使用了79 80 81 82 83 84 85 86 for (int j = 0; j < 4; j++) { memset(buf, 0, 32); @@ -628,43 +1705,63 @@ void Uart::DealDataNodeInfo(const char *pData) iTemp = (int)strtol(buf, NULL, 16); if (0 == j) { - dataNodeInfo.FaultFrequency = boost::lexical_cast(iTemp); + dataNodeInfo.FaultFrequency = to_string(iTemp); } else { - dataNodeInfo.FaultFrequency += ("," + boost::lexical_cast(iTemp)); + dataNodeInfo.FaultFrequency += ("," + to_string(iTemp)); } } memset(buf, 0, 32); sprintf(buf, "%02x%02x%02x%02x", pRecvData->Data[87], pRecvData->Data[88], pRecvData->Data[89],pRecvData->Data[90]); long lTimeStamp = strtol(buf, NULL, 16); - dataNodeInfo.ConfigDate = boost::lexical_cast(lTimeStamp); + dataNodeInfo.ConfigDate = to_string(lTimeStamp); chTemp = pRecvData->Data[91]; memset(buf, 0, 32); sprintf(buf, "%d", chTemp); - dataNodeInfo.VIntegralFilterFrequency = boost::lexical_cast(buf); + dataNodeInfo.VIntegralFilterFrequency = atoi(buf); char whereCon[64] = {0}; sprintf(whereCon, "dataNodeNo='%s'", dataNodeInfo.ZigbeeLongAddr.c_str()); if (sql_ctl->GetTableRows(T_SENSOR_INFO(TNAME), whereCon) > 0) { - sql_ctl->DeleteTableData(T_SENSOR_INFO(TNAME), whereCon); - } - char insertSql[1024] = { 0 }; - sprintf(insertSql, "'%s','%s','%d','%d','%d','%d','%d','%d',\ - '%s','%s','%s','%s','%s','%d',\ - '%d','%d','%d','%s','%d','%s',\ - '%s','%u','%d','%d','%s','%d','%s','%s',\ - '%s','%d','%s','%s','%s',\ - '%d','%d','%d','%d','%s','%s','%d','%d'", - dataNodeInfo.ZigbeeLongAddr.c_str(), " ", dataNodeInfo.InitFlag, dataNodeInfo.AccFlag, dataNodeInfo.ZigbeeFlag, dataNodeInfo.TemTopFlag, dataNodeInfo.TemBotFlag,dataNodeInfo.EquipSta,\ - dataNodeInfo.HardVersion.c_str(), dataNodeInfo.SoftVersion.c_str(), dataNodeInfo.BpNo.c_str(), dataNodeInfo.SerialNo.c_str(), dataNodeInfo.FirstPowerTime.c_str(), dataNodeInfo.WakeupTime,\ - dataNodeInfo.StaticTime,dataNodeInfo.WaveTime,dataNodeInfo.BateryV,dataNodeInfo.ProductNo.c_str(),dataNodeInfo.ConfigFlag, dataNodeInfo.StartBrands.c_str(), \ - dataNodeInfo.StopBrands.c_str(), dataNodeInfo.FeatureInterVal, dataNodeInfo.WaveInterVal, dataNodeInfo.SamplingRate,"",dataNodeInfo.Range, dataNodeInfo.EnvelopeBandPass.c_str(), dataNodeInfo.FaultFrequency.c_str(),\ - dataNodeInfo.ZigbeePanId.c_str(), dataNodeInfo.ZigbeeChannel, dataNodeInfo.ZigbeeShortAddr.c_str(), dataNodeInfo.ZigbeeLongAddr.c_str(), dataNodeInfo.ZigbeeDesAddr.c_str(), \ - dataNodeInfo.ZigbeePower,dataNodeInfo.ZigbeeRetry,dataNodeInfo.ZigbeeRetryGap,dataNodeInfo.ACCSampleTime,"1", dataNodeInfo.ConfigDate.c_str(),dataNodeInfo.VIntegralFilterFrequency,dataNodeInfo.RSSI); - sql_ctl->InsertData(T_SENSOR_INFO(TNAME), insertSql); - printf("=======insertSql======== %s\n",insertSql); + char updateSql[1024] = { 0 }; + sprintf(updateSql, " initFlag = '%d',accFlag = '%d',zigbeeFlag = '%d',temTopFlag = '%d',temBotFlag = '%d',equipSta = '%d',\ + hardVersion = '%s',softVersion = '%s',bpNo = '%s',serialNo = '%s',firstPowerTime = '%s',WakeupTime = '%d',\ + StaticTime = '%d',WaveTime = '%d',BateryV = '%d',ProductNo = '%s',configFlag = '%d',startBrands = '%s',\ + stopBrands = '%s',featureInterVal = '%u',waveInterVal = '%d',samplingRate = '%d',scope = '%s',range = '%d',envelopeBandPass = '%s',faultFrequency = '%s',\ + zigbeePanId = '%s',zigbeeChannel = '%d',zigbeeShortAddr = '%s',zigbeeLongAddr = '%s',zigbeeDesAddr = '%s',\ + ZigbeePower = '%d',ZigbeeRetry = '%d',ZigbeeRetryGap = '%d',ACCSampleTime = '%d',status = '%s',timeStamp = '%s',viff = '%d',RSSI = '%d',UpdateFlag = 1", + dataNodeInfo.InitFlag, dataNodeInfo.AccFlag, dataNodeInfo.ZigbeeFlag, dataNodeInfo.TemTopFlag, dataNodeInfo.TemBotFlag,dataNodeInfo.EquipSta,\ + dataNodeInfo.HardVersion.c_str(), dataNodeInfo.SoftVersion.c_str(), dataNodeInfo.BpNo.c_str(), dataNodeInfo.SerialNo.c_str(), dataNodeInfo.FirstPowerTime.c_str(), dataNodeInfo.WakeupTime,\ + dataNodeInfo.StaticTime,dataNodeInfo.WaveTime,dataNodeInfo.BateryV,dataNodeInfo.ProductNo.c_str(),dataNodeInfo.ConfigFlag, dataNodeInfo.StartBrands.c_str(), \ + dataNodeInfo.StopBrands.c_str(), dataNodeInfo.FeatureInterVal, dataNodeInfo.WaveInterVal, dataNodeInfo.SamplingRate,"",dataNodeInfo.Range, dataNodeInfo.EnvelopeBandPass.c_str(), dataNodeInfo.FaultFrequency.c_str(),\ + dataNodeInfo.ZigbeePanId.c_str(), dataNodeInfo.ZigbeeChannel, dataNodeInfo.ZigbeeShortAddr.c_str(), dataNodeInfo.ZigbeeLongAddr.c_str(), dataNodeInfo.ZigbeeDesAddr.c_str(), \ + dataNodeInfo.ZigbeePower,dataNodeInfo.ZigbeeRetry,dataNodeInfo.ZigbeeRetryGap,dataNodeInfo.ACCSampleTime,"1", dataNodeInfo.ConfigDate.c_str(),dataNodeInfo.VIntegralFilterFrequency,dataNodeInfo.RSSI); + sprintf(whereCon,"dataNodeNo = '%s'",dataNodeInfo.ZigbeeLongAddr.c_str()); + sql_ctl->UpdateTableData(T_SENSOR_INFO(TNAME), updateSql, whereCon); + }else{ + char insertSql[1024] = { 0 }; + sprintf(insertSql, " '%s','%s','%d','%d','%d','%d','%d','%d',\ + '%s','%s','%s','%s','%s','%d',\ + '%d','%d','%d','%s','%d','%s',\ + '%s','%u','%d','%d','%s','%d', '%s', '%s',\ + '%s','%d','%s','%s','%s',\ + '%d','%d','%d','%d','%s','%s', '%d', '%d','1','0',''", + dataNodeInfo.ZigbeeLongAddr.c_str(), " ", dataNodeInfo.InitFlag, dataNodeInfo.AccFlag, dataNodeInfo.ZigbeeFlag, dataNodeInfo.TemTopFlag, dataNodeInfo.TemBotFlag,dataNodeInfo.EquipSta,\ + dataNodeInfo.HardVersion.c_str(), dataNodeInfo.SoftVersion.c_str(), dataNodeInfo.BpNo.c_str(), dataNodeInfo.SerialNo.c_str(), dataNodeInfo.FirstPowerTime.c_str(), dataNodeInfo.WakeupTime,\ + dataNodeInfo.StaticTime,dataNodeInfo.WaveTime,dataNodeInfo.BateryV,dataNodeInfo.ProductNo.c_str(),dataNodeInfo.ConfigFlag, dataNodeInfo.StartBrands.c_str(), \ + dataNodeInfo.StopBrands.c_str(), dataNodeInfo.FeatureInterVal, dataNodeInfo.WaveInterVal, dataNodeInfo.SamplingRate,"",dataNodeInfo.Range, dataNodeInfo.EnvelopeBandPass.c_str(), dataNodeInfo.FaultFrequency.c_str(),\ + dataNodeInfo.ZigbeePanId.c_str(), dataNodeInfo.ZigbeeChannel, dataNodeInfo.ZigbeeShortAddr.c_str(), dataNodeInfo.ZigbeeLongAddr.c_str(), dataNodeInfo.ZigbeeDesAddr.c_str(), \ + dataNodeInfo.ZigbeePower,dataNodeInfo.ZigbeeRetry,dataNodeInfo.ZigbeeRetryGap,dataNodeInfo.ACCSampleTime,"1", dataNodeInfo.ConfigDate.c_str(),dataNodeInfo.VIntegralFilterFrequency,dataNodeInfo.RSSI); + sql_ctl->InsertData(T_SENSOR_INFO(TNAME), insertSql); + } + char szTableName[50]={0x00}; + sprintf(szTableName,"t_data_%s",dataNodeInfo.ZigbeeLongAddr.c_str()); + sql_ctl->Createtable(szTableName); + memset(szTableName,0x00,sizeof(szTableName)); + sprintf(szTableName,"t_dataStatic_%s",dataNodeInfo.ZigbeeLongAddr.c_str()); + sql_ctl->CreatedataStatictable(szTableName); Json::Value jsonVal; jsonVal.clear(); jsonVal["cmd"] = "26"; @@ -711,9 +1808,9 @@ void Uart::DealDataNodeInfo(const char *pData) Json::FastWriter showValue; std::string dataBody = showValue.write(jsBody); jsonVal["cmdBody"] = dataBody; - std::string strCmd27 = showValue.write(jsonVal); + std::string strCmd26 = showValue.write(jsonVal); //传感器发来的数据包中的表示设备信息的数据转化为json格式后,通过调用data_publish将数据传给mqttclient : Topic:wireless/cmd/60294D203717 - data_publish(strCmd27.c_str(), GlobalConfig::Topic_G.mPubCmd.c_str()); + data_publish(strCmd26.c_str(), GlobalConfig::Topic_G.mPubCmd.c_str()); print_info("remote wireless sensor device info AccFlag : %d EquipSta : %d BpNo : %s ConfigFlag : %d EnvelopeBandPass : %s FaultFrequency : %s FeatureInterVal : %u FirstPowerTime : %s HardVersion : %s InitFlag : %d SamplingRate : %d range : %d SerialNo : %s\ SoftVersion : %s StartBrands : %s StopBrands : %s TemBotFlag : %d TemTopFlag : %d WaveInterVal : %d ZigbeeChannel : %d ZigbeeDesAddr : %s ZigbeeFlag : %d ZigbeeLongAddr : %s panid : %s ZigbeeShortAddr : %s Configdate : %s vintegralfilterfrequency : %d RSSI : %d \n", \ @@ -722,6 +1819,7 @@ void Uart::DealDataNodeInfo(const char *pData) dataNodeInfo.SoftVersion.c_str(), dataNodeInfo.StartBrands.c_str(), dataNodeInfo.StopBrands.c_str(), dataNodeInfo.TemBotFlag, dataNodeInfo.TemTopFlag, dataNodeInfo.WaveInterVal,\ dataNodeInfo.ZigbeeChannel, dataNodeInfo.ZigbeeDesAddr.c_str(), dataNodeInfo.ZigbeeFlag, dataNodeInfo.ZigbeeLongAddr.c_str(), dataNodeInfo.ZigbeePanId.c_str(), dataNodeInfo.ZigbeeShortAddr.c_str(), dataNodeInfo.ConfigDate.c_str(), dataNodeInfo.VIntegralFilterFrequency, dataNodeInfo.RSSI); + } @@ -729,50 +1827,91 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) { print_info("recv feature\n"); RecvData * pRecvData = (RecvData *)pData; - - char buf[8]; + char whereCon[1024] = {0}; + char updateSql[1024] = { 0 }; + char buf[20] = {0x00}; + int nodeResend = 0; sprintf(buf, "%02x%02x", pRecvData->ShortAddr[0], pRecvData->ShortAddr[1]); - LOG_INFO("DealDataNodeFeature %02x%02x\n",pRecvData->ShortAddr[0], pRecvData->ShortAddr[1]); + //LOG_INFO("DealDataNodeFeature %02x%02x\n",pRecvData->ShortAddr[0], pRecvData->ShortAddr[1]); std::string strShortAddr = std::string(buf); print_info("zigbeeShortAddr='%s'\n", strShortAddr.c_str()); - if (1 == flag) { - print_info("recv wave minute\n"); - unsigned short localAddr = 0x9999; - bool bUpdate = ReadUpdatePackge(pRecvData->ShortAddr); - if(!bUpdate){ - GlobalConfig::ZigbeeInfo_G.MyAddr = "9999"; - WriteShortAddr2Zigbee(localAddr); - } -/* bool bUpdate = ReadUpdatePackge(pRecvData->ShortAddr,buf); - if(bUpdate){ - WriteShortAddr_DistAddr2Zigbee(shortAddr,buf); - }else{ - WriteShortAddr2Zigbee(shortAddr); - }*/ -// LOG_INFO("[DealDataNodeFeature] ZigBee PanID: %s ; Channel: %d ; MyAddr : %4x ",GlobalConfig::ZigbeeInfo_G.PanID.c_str(),GlobalConfig::ZigbeeInfo_G.Channel, -// (unsigned short)GlobalConfig::Zigbee_G.MyAddr); - - // 进入传输原始数据状态,启动计数 60秒 - GlobalConfig::EnterZigBeeWaveTransmittingFlag_G = ENTER_TRANSMITTING_STATUS; - GlobalConfig::EnterZigBeeWaveTransmittingCnt_G = 0; - } - - - char getLongAddr_sql[32] = { 0 }; + char getLongAddr_sql[32] = { 0 }; //根据数据包中的传感器的短地址获取数据库中长地址(MAC),在下面判断该传感器是否存在,如果不存在则把数据包丢弃 - sprintf(getLongAddr_sql, "zigbeeShortAddr='%s'", strShortAddr.c_str()); - std::string strLongAddr = sql_ctl->GetData(T_SENSOR_INFO(TNAME), T_SENSOR_INFO(ZIGBEELONGADDR), getLongAddr_sql); - print_info("--------->the remote sensor short addr:%s strLongAddr=%s\n",buf,strLongAddr.c_str()); + sprintf(getLongAddr_sql, "zigbeeShortAddr='%s'", strShortAddr.c_str()); + //std::string strLongAddr = sql_ctl->GetData(T_SENSOR_INFO(TNAME), T_SENSOR_INFO(ZIGBEELONGADDR), getLongAddr_sql); + vec_t vecResult = sql_ctl->GetDataSingleLine(T_SENSOR_INFO(TNAME)," softVersion,zigbeeLongAddr ",getLongAddr_sql); - if (0 == strLongAddr.length()) { - print_error("device info not found\n"); - return; + if (vecResult.size() < 1) { + LOG_ERROR("device info not found %02x%02x\n",pRecvData->ShortAddr[0], pRecvData->ShortAddr[1]); + print_error("device info not found\n"); + return; + } + print_info("--------->the remote sensor short addr:%s strLongAddr=%s,softVersion = %s\n",buf,vecResult[1].c_str(),vecResult[0].c_str()); + + std::string strLongAddr = vecResult[1]; + if (1 == flag) { + + tcflush(fd,TCIOFLUSH); + + if (!bSendTimeStamp) + { + bSendTimeStamp = true; + modify_distaddr_info(0x9999,"",pRecvData->ShortAddr);//临时参数配置 + usleep(10000); + UpdateWirelessNodeTime((unsigned char*)pRecvData->ShortAddr,0); + }else + { + return; + } + + //modify_distaddr_info(0x9999,"",pRecvData->ShortAddr);//临时参数配置 + + GlobalConfig::ZigbeeInfo_G.MyAddr = "9999"; + GlobalConfig::Zigbee_G.MyAddr = 0x9999; + string strTime = GetLocalTimeWithMs(); + + m_strDestShortAddr = std::string(buf); + + bool isUpdate = ReadUpdatePackge(pRecvData->ShortAddr); + bUpdatePre = isUpdate; + if(!isUpdate){ + int iRet = UpdateConfig(pRecvData->ShortAddr); + } + if(isUpdate || bUpdateconfig){ + + }else{ + LOG_DEBUG("DealDataNodeFeature %02x%02x,localaddr %02x%02x \n",pRecvData->ShortAddr[0], pRecvData->ShortAddr[1],\ + UINT16_HIGH(GlobalConfig::Zigbee_G.MyAddr),UINT16_LOW(GlobalConfig::Zigbee_G.MyAddr)); + // 进入传输原始数据状态,启动计数 60秒 + GlobalConfig::EnterZigBeeWaveTransmittingFlag_G = ENTER_TRANSMITTING_STATUS; + GlobalConfig::EnterZigBeeWaveTransmittingCnt_G = 0; + } + + }else{ + memset(whereCon,0x00,sizeof(whereCon)); + memset(updateSql,0x00,sizeof(updateSql)); + sprintf(whereCon, "zigbeeShortAddr='%s'", strShortAddr.c_str()); + sprintf(updateSql, " StaticTime = StaticTime + 1"); + sql_ctl->UpdateTableData(T_SENSOR_INFO(TNAME), updateSql, whereCon); + //string strData = sql_ctl->GetNodeConfigureInfor(whereCon); + //data_publish(strData.c_str(), GlobalConfig::Topic_G.mPubConfig.c_str()); } - + + if (vecResult[0] == "3.0" || vecResult[0] == "4.0"){ + return; + } + long staticIndex = BUILD_UINT32(pRecvData->Data[29], pRecvData->Data[28],pRecvData->Data[27], pRecvData->Data[26]); + + print_info("staticIndex = %d\n",staticIndex); + + + //LOG_INFO("staticIndex = %d\n",staticIndex); + char localtimestamp[32] = { 0 }; GetTimeNet(localtimestamp, 1); - std::string nowTimetamp = std::string(localtimestamp); + std::string nowTimetamp = std::string(localtimestamp); + strTimetamp = nowTimetamp; int iTemp = 0; unsigned char highbit = 0; @@ -780,49 +1919,165 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) float n = 0; DataRecvStatic dataStatic; - memset(buf, 0, 8); + memset(buf, 0, sizeof(buf)); sprintf(buf, "%02x%02x", pRecvData->Data[5], pRecvData->Data[4]); print_blue("!!!!!!!!!!!!!!!!!!!!!!%s\n",buf); iTemp = (int)strtol(buf, NULL, 16); dataStatic.Dip = iTemp; - memset(buf, 0, 8); + int fTemp = 0; + memset(buf, 0, sizeof(buf)); sprintf(buf, "%02x%02x", pRecvData->Data[1], pRecvData->Data[0]); print_blue("@@@@@@@@@@@@@@@@@%s\n",buf); iTemp = (int)strtol(buf, NULL, 16); - dataStatic.TemBot = iTemp * 0.0625;//设备温度 + if (iTemp < 0x8000) { + fTemp = iTemp ; + } else { + fTemp = (((~iTemp)&0xffff) + 1)* (-1); + } + dataStatic.TemBot = fTemp * 0.0625;//设备温度 - memset(buf, 0, 8); + fTemp = 0; + memset(buf, 0, sizeof(buf)); sprintf(buf, "%02x%02x", pRecvData->Data[3], pRecvData->Data[2]); iTemp = (int)strtol(buf, NULL, 16); - dataStatic.TemTop = iTemp * 0.0625;//环境温度 + if (iTemp < 0x8000) { + fTemp = iTemp ; + } else { + fTemp = (((~iTemp)&0xffff) + 1) * (-1); + } + dataStatic.TemTop = fTemp * 0.0625;//环境温度 - memset(buf, 0, 8); + memset(buf, 0, sizeof(buf)); sprintf(buf, "%02x%02x", pRecvData->Data[7], pRecvData->Data[6]); iTemp = (int)strtol(buf, NULL, 16); dataStatic.Voltage = iTemp; + char szTableName[50]={0x00},szTableNameStatic[50]={0x00},szTableNameData[50]={0x00}; + sprintf(szTableName,"t_dataStatic_%s",strLongAddr.c_str()); + memcpy(szTableNameStatic,szTableName,sizeof(szTableNameStatic)); + memset(whereCon,0x00,sizeof(whereCon)); + + sprintf(whereCon,"StaticIndex = %d",staticIndex); + int count = sql_ctl->GetTableRows(szTableNameStatic, whereCon);//避免重复数据 + + sprintf(szTableNameData,"t_data_%s",strLongAddr.c_str()); + + int count2 = sql_ctl->GetTableRows(szTableNameData, whereCon); + if(count > 0 || count2 > 0){ + char logInfo[20]={0x00}; + sprintf(logInfo,"ShortAddr = %s,staticIndex = %d,staticData = %d, data = %d",strShortAddr.c_str(),staticIndex,count,count2); + LOG_DEBUG(logInfo); + return; + } + memset(whereCon,0x00,sizeof(whereCon)); + + ///////////////////////////////////////////////////////////// for V2.0.3 upgrade to V3.0 + std::string strTmp = ""; + char sztmp[100]={0x00}; + strTmp = "name = '" + string(szTableNameStatic)+ "' and sql LIKE '%nodeResend%' "; + + int row = sql_ctl->GetTableRows(" sqlite_master ",strTmp.c_str()); + print_info("row1 = %d\n",row); + if(row == 0){ + memset(sztmp,0x00,sizeof(sztmp)); + sprintf(sztmp,"ALTER TABLE %s ADD COLUMN 'nodeResend'",szTableNameStatic); + sql_ctl->CreateTable(sztmp); + } + // strTmp = "name = '" + string(szTableNameStatic)+ "' and sql LIKE '%zigbeeRSSIType%' "; + // row = sql_ctl->GetTableRows(" sqlite_master ",strTmp.c_str()); + // print_info("row2 = %d\n",row); + // if(row == 0){ + // memset(sztmp,0x00,sizeof(sztmp)); + // sprintf(sztmp,"ALTER TABLE %s ADD COLUMN 'zigbeeRSSIType'",szTableNameStatic); + // sql_ctl->CreateTable(sztmp); + // } + strTmp = "name = '" + string(szTableNameData)+ "' and sql LIKE '%nodeResend%' "; + row = sql_ctl->GetTableRows(" sqlite_master ",strTmp.c_str()); + print_info("row2 = %d\n",row); + if(row == 0){ + memset(sztmp,0x00,sizeof(sztmp)); + sprintf(sztmp,"ALTER TABLE %s ADD COLUMN 'nodeResend'",szTableNameData); + sql_ctl->CreateTable(sztmp); + } + + //////////////////////////////////////////////////////////// + std::string strStaticIndex = sql_ctl->GetData(szTableNameStatic, "StaticIndex", "StaticIndex > 0 order by StaticIndex desc LIMIT 0 , 1"); + // if(abs(atol(strStaticIndex.c_str()) - staticIndex) > 100){ + // sql_ctl->Deletetable(szTableNameStatic); + // sql_ctl->Deletetable(szTableNameData); + // LOG_INFO("staticIndexNOW = %d,strStaticIndexLast = %s\n",staticIndex,strStaticIndex.c_str()); + // } + + if(staticIndex != atol(strStaticIndex.c_str() + 1) && + strStaticIndex != "" && + staticIndex < atol(strStaticIndex.c_str())) + { + sprintf(whereCon,"StaticIndex = %d order by StaticIndex desc LIMIT 0 , 1",atol(strStaticIndex.c_str())); + vec_t vecResult = sql_ctl->GetDataSingleLine(szTableNameStatic, "timeStamp,StaticIndex", whereCon); + memset(whereCon,0x00,sizeof(whereCon)); + sprintf(whereCon,"dataNodeNo = '%s'",strLongAddr.c_str()); + string staticInterval = sql_ctl->GetData(T_SENSOR_INFO(TNAME), "featureInterval", whereCon); + //LOG_INFO("vecResult0 = %s,vecResult1 = %s\n",vecResult[0].c_str(),vecResult[1].c_str()); + long nNowTimetamp = atol(vecResult[0].c_str()) - (atol(staticInterval.c_str()) * \ + (atol(vecResult[1].c_str()) - staticIndex)) * 60; + char tmp[10]={0x00}; + sprintf(tmp,"%ld",nNowTimetamp); + nowTimetamp = string(tmp); + nodeResend = 1; + //LOG_INFO("nowTimetamp = %s,strOldTime = %s\n",nowTimetamp.c_str(),vecResult[0].c_str()); + } + print_info("nowTimetamp = %s",nowTimetamp.c_str()); + // save dataStatic of 7 days + char selectCon[128] = { 0 }; + sprintf(selectCon, "channelID='%s' and sendMsg = '1' ORDER BY timeStamp ASC LIMIT 0,1",(strLongAddr + "-S").c_str()); + std::string strTime = sql_ctl->GetData(szTableName, "timeStamp", selectCon); + int Count = sql_ctl->GetTableRows(szTableName, NULL); + if(Count == -1){ + sql_ctl->CreatedataStatictable(szTableName); + } + print_info("strLongAddr = %s,strTime = %s\n",strLongAddr.c_str(),strTime.c_str()); + long lTime = atol(nowTimetamp.c_str())-atol(strTime.c_str()); + print_info("lTime = %d,OneWeek = %d\n",lTime,OneWeek); print_info("dataStatic.TemTop : %f dataStatic.TemBot : %f dataStatic.Dip :%d dataStatic.Voltage : %d\n", dataStatic.TemTop\ , dataStatic.TemBot, dataStatic.Dip, dataStatic.Voltage); - char whereCon[64] = {0}; - sprintf(whereCon, "channelID='%s'", (strLongAddr + "-S").c_str()); -// if ( 0 == sql_ctl->GetTableRows(T_DATASTATIC_INFO(TNAME), whereCon) ) { + + sprintf(updateSql, "temTop='%f',temBot='%f',dip='%d',voltage='%d',timeStamp='%s',StaticIndex = %d, nodeResend = %d",\ + dataStatic.TemTop, dataStatic.TemBot, dataStatic.Dip, dataStatic.Voltage, nowTimetamp.c_str(),staticIndex,nodeResend); + sprintf(whereCon, "channelID='%s' and sendMsg = '1'", (strLongAddr + "-S").c_str()); + if ( /*0 == sql_ctl->GetTableRows(T_DATASTATIC_INFO(TNAME), whereCon)*/ (Count * 3 < SAVE_COUNT && lTime < OneWeek ) || strTime.size() == 0 ) { print_info("insert static data to sql\n"); char insertSql[1024] = { 0 }; - sprintf(insertSql, "'%s','%s','%f','%f','%d','%d','%s'", - strLongAddr.c_str(), (strLongAddr + "-S").c_str(), dataStatic.TemTop, dataStatic.TemBot, dataStatic.Dip, dataStatic.Voltage, nowTimetamp.c_str()); - sql_ctl->InsertData(T_DATASTATIC_INFO(TNAME), insertSql); - // } else { -/* print_info("update static data to sql\n"); - char updateSql[1024] = { 0 }; - sprintf(updateSql, "temTop='%f',temBot='%f',dip='%d',voltage='%d',timeStamp='%s'",\ - dataStatic.TemTop, dataStatic.TemBot, dataStatic.Dip, dataStatic.Voltage, nowTimetamp.c_str()); - sql_ctl->UpdateTableData(T_DATASTATIC_INFO(TNAME), updateSql, whereCon); - }*/ + sprintf(insertSql, "'%s','%s','%f','%f','%d','%d','',%d,'%s','1',%d", + strLongAddr.c_str(), (strLongAddr + "-S").c_str(), dataStatic.TemTop, dataStatic.TemBot, dataStatic.Dip, dataStatic.Voltage, staticIndex,nowTimetamp.c_str(),nodeResend); + sql_ctl->InsertData(szTableName, insertSql); + if(0 == sql_ctl->GetTableRows(T_DATASTATIC_INFO(TNAME), whereCon)){ // First Connect + char insertSql[1024] = { 0 }; + sprintf(insertSql, "'%s','%s','%f','%f','%d','%d','',%d,'%s','1',%d", + strLongAddr.c_str(), (strLongAddr + "-S").c_str(), dataStatic.TemTop, dataStatic.TemBot, dataStatic.Dip, dataStatic.Voltage, staticIndex,nowTimetamp.c_str(),nodeResend); + sql_ctl->InsertData(T_DATASTATIC_INFO(TNAME), insertSql); + sql_ctl->CalculateBattery(); + } + else + sql_ctl->UpdateTableData(T_DATASTATIC_INFO(TNAME), updateSql, whereCon); + } else { + memset(whereCon,0x00,sizeof(whereCon)); + sprintf(whereCon, "channelID='%s' and sendMsg = '1' and timeStamp = '%s'", (strLongAddr + "-S").c_str(),strTime.c_str()); + print_info("update static data to sql\n"); + sql_ctl->UpdateTableData(szTableName, updateSql, whereCon); + memset(whereCon,0x00,sizeof(whereCon)); + sprintf(whereCon, "channelID='%s' ", (strLongAddr + "-S").c_str()); + sql_ctl->UpdateTableData(T_DATASTATIC_INFO(TNAME), updateSql, whereCon); + } + memset(szTableName,0x00,sizeof(szTableName)); + sprintf(szTableName,"t_data_%s",strLongAddr.c_str()); + if(Count == -1){ + sql_ctl->Createtable(szTableName); + } DataRecvDym dataDymX; - memset(buf, 0, 8); + memset(buf, 0, sizeof(buf)); sprintf(buf, "%02x%02x", pRecvData->Data[9], pRecvData->Data[8]); iTemp = (unsigned int)strtol(buf, NULL, 16); highbit = iTemp >> 14 & 0x3; @@ -844,7 +2099,7 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) } dataDymX.DiagnosisPk = lowbit * n; - memset(buf, 0, 8); + memset(buf, 0, sizeof(buf)); sprintf(buf, "%02x%02x", pRecvData->Data[11], pRecvData->Data[10]); iTemp = (unsigned int)strtol(buf, NULL, 16); highbit = iTemp >> 14 & 0x3; @@ -866,7 +2121,7 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) } dataDymX.RmsValues = lowbit * n; - memset(buf, 0, 8); + memset(buf, 0, sizeof(buf)); sprintf(buf, "%02x%02x", pRecvData->Data[13], pRecvData->Data[12]); iTemp = (unsigned int)strtol(buf, NULL, 16); highbit = iTemp >> 14 & 0x3; @@ -888,7 +2143,7 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) } dataDymX.IntegratPk = lowbit * n; - memset(buf, 0, 8); + memset(buf, 0, sizeof(buf)); sprintf(buf, "%02x%02x", pRecvData->Data[15], pRecvData->Data[14]); iTemp = (unsigned int)strtol(buf, NULL, 16); highbit = iTemp >> 14 & 0x3; @@ -910,7 +2165,7 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) } dataDymX.IntegratRMS = lowbit * n; - memset(buf, 0, 8); + memset(buf, 0, sizeof(buf)); sprintf(buf, "%02x%02x", pRecvData->Data[17], pRecvData->Data[16]); iTemp = (unsigned int)strtol(buf, NULL, 16); highbit = iTemp >> 14 & 0x3; @@ -932,7 +2187,7 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) } dataDymX.Amp1 = lowbit * n; - memset(buf, 0, 8); + memset(buf, 0, sizeof(buf)); sprintf(buf, "%02x%02x", pRecvData->Data[19], pRecvData->Data[18]); iTemp = (unsigned int)strtol(buf, NULL, 16); highbit = iTemp >> 14 & 0x3; @@ -954,7 +2209,7 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) } dataDymX.Amp2 = lowbit * n; - memset(buf, 0, 8); + memset(buf, 0, sizeof(buf)); sprintf(buf, "%02x%02x", pRecvData->Data[21], pRecvData->Data[20]); iTemp = (unsigned int)strtol(buf, NULL, 16); highbit = iTemp >> 14 & 0x3; @@ -976,7 +2231,7 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) } dataDymX.Amp3 = lowbit * n; - memset(buf, 0, 8); + memset(buf, 0, sizeof(buf)); sprintf(buf, "%02x%02x", pRecvData->Data[23], pRecvData->Data[22]); iTemp = (unsigned int)strtol(buf, NULL, 16); highbit = iTemp >> 14 & 0x3; @@ -998,7 +2253,8 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) } dataDymX.Amp4 = lowbit * n; - memset(buf, 0, 8); + + memset(buf, 0, sizeof(buf)); sprintf(buf, "%02x%02x", pRecvData->Data[25], pRecvData->Data[24]); iTemp = (unsigned int)strtol(buf, NULL, 16); highbit = iTemp >> 14 & 0x3; @@ -1020,133 +2276,150 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) } dataDymX.Amp5 = lowbit * n; - memset(buf, 0, 8); - sprintf(buf, "%02x%02x", pRecvData->Data[27], pRecvData->Data[26]); - iTemp = (unsigned int)strtol(buf, NULL, 16); - highbit = iTemp >> 14 & 0x3; - lowbit = iTemp & 0x3fff; - switch (highbit) - { - case 0: - n = 0.0001; - break; - case 1: - n = 0.01; - break; - case 2: - n = 1; - break; - case 3: - n = 100; - break; - } - dataDymX.EnvelopEnergy = lowbit * n; + memset(buf, 0, sizeof(buf)); +// sprintf(buf, "%02x%02x", pRecvData->Data[27], pRecvData->Data[26]); +// iTemp = (unsigned int)strtol(buf, NULL, 16); +// highbit = iTemp >> 14 & 0x3; +// lowbit = iTemp & 0x3fff; +// switch (highbit) +// { +// case 0: +// n = 0.0001; +// break; +// case 1: +// n = 0.01; +// break; +// case 2: +// n = 1; +// break; +// case 3: +// n = 100; +// break; +// } +// dataDymX.EnvelopEnergy = lowbit * n; + + dataDymX.EnvelopEnergy = 0; + + memset(buf, 0, sizeof(buf)); +// sprintf(buf, "%02x%02x", pRecvData->Data[29], pRecvData->Data[28]); +// iTemp = (unsigned int)strtol(buf, NULL, 16); +// highbit = iTemp >> 14 & 0x3; +// lowbit = iTemp & 0x3fff; +// switch (highbit) +// { +// case 0: +// n = 0.0001; +// break; +// case 1: +// n = 0.01; +// break; +// case 2: +// n = 1; +// break; +// case 3: +// n = 100; +// break; +// } +// dataDymX.Phase1 = lowbit * n; + + dataDymX.Phase1 = 0; + + memset(buf, 0, sizeof(buf)); +// sprintf(buf, "%02x%02x", pRecvData->Data[31], pRecvData->Data[30]); +// iTemp = (unsigned int)strtol(buf, NULL, 16); +// highbit = iTemp >> 14 & 0x3; +// lowbit = iTemp & 0x3fff; +// switch (highbit) +// { +// case 0: +// n = 0.0001; +// break; +// case 1: +// n = 0.01; +// break; +// case 2: +// n = 1; +// break; +// case 3: +// n = 100; +// break; +// } + dataDymX.Phase2 = 0; + + memset(buf, 0, sizeof(buf)); memset(buf, 0, 8); - sprintf(buf, "%02x%02x", pRecvData->Data[29], pRecvData->Data[28]); - iTemp = (unsigned int)strtol(buf, NULL, 16); - highbit = iTemp >> 14 & 0x3; - lowbit = iTemp & 0x3fff; - switch (highbit) - { - case 0: - n = 0.0001; - break; - case 1: - n = 0.01; - break; - case 2: - n = 1; - break; - case 3: - n = 100; - break; - } - dataDymX.Phase1 = lowbit * n; +// sprintf(buf, "%02x%02x", pRecvData->Data[33], pRecvData->Data[32]); +// iTemp = (unsigned int)strtol(buf, NULL, 16); +// highbit = iTemp >> 14 & 0x3; +// lowbit = iTemp & 0x3fff; +// switch (highbit) +// { +// case 0: +// n = 0.0001; +// break; +// case 1: +// n = 0.01; +// break; +// case 2: +// n = 1; +// break; +// case 3: +// n = 100; +// break; +// } + dataDymX.Phase3 = 0; - memset(buf, 0, 8); - sprintf(buf, "%02x%02x", pRecvData->Data[31], pRecvData->Data[30]); - iTemp = (unsigned int)strtol(buf, NULL, 16); - highbit = iTemp >> 14 & 0x3; - lowbit = iTemp & 0x3fff; - switch (highbit) - { - case 0: - n = 0.0001; - break; - case 1: - n = 0.01; - break; - case 2: - n = 1; - break; - case 3: - n = 100; - break; - } - dataDymX.Phase2 = lowbit * n; - - memset(buf, 0, 8); - sprintf(buf, "%02x%02x", pRecvData->Data[33], pRecvData->Data[32]); - iTemp = (unsigned int)strtol(buf, NULL, 16); - highbit = iTemp >> 14 & 0x3; - lowbit = iTemp & 0x3fff; - switch (highbit) - { - case 0: - n = 0.0001; - break; - case 1: - n = 0.01; - break; - case 2: - n = 1; - break; - case 3: - n = 100; - break; - } - dataDymX.Phase3 = lowbit * n; + memset(buf, 0, sizeof(buf)); + sprintf(buf, "%02x%02x", pRecvData->Data[35], pRecvData->Data[34]); +// iTemp = (unsigned int)strtol(buf, NULL, 16); +// highbit = iTemp >> 14 & 0x3; +// lowbit = iTemp & 0x3fff; +// switch (highbit) +// { +// case 0: +// n = 0.0001; +// break; +// case 1: +// n = 0.01; +// break; +// case 2: +// n = 1; +// break; +// case 3: +// n = 100; +// break; +// } + dataDymX.Phase4 = 0; - memset(buf, 0, 8); - sprintf(buf, "%02x%02x", pRecvData->Data[35], pRecvData->Data[34]); - iTemp = (unsigned int)strtol(buf, NULL, 16); - highbit = iTemp >> 14 & 0x3; - lowbit = iTemp & 0x3fff; - switch (highbit) - { - case 0: - n = 0.0001; - break; - case 1: - n = 0.01; - break; - case 2: - n = 1; - break; - case 3: - n = 100; - break; - } - dataDymX.Phase4 = lowbit * n; - - memset(whereCon, 0, 64); - sprintf(whereCon, "channelID='%s'", (strLongAddr + "-X").c_str()); - // if ( 0 == sql_ctl->GetTableRows(T_DATA_INFO(TNAME), whereCon) ) { -// char insertSql[1024] = { 0 }; - memset(insertSql,0x00,sizeof(insertSql)); - sprintf(insertSql, "'%s','%s','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%s'", + memset(whereCon, 0, 1024); + sprintf(whereCon, "channelID='%s' and sendMsg = '1'", (strLongAddr + "-X").c_str()); + memset(updateSql, 0, 1024); + sprintf(updateSql, "diagnosisPk='%f',integratPk='%f',integratRMS='%f',rmsValues='%f',envelopEnergy='%f',\ + Amp1='%f',Amp2='%f',Amp3='%f',Amp4='%f',Amp5='%f',Phase1='%f',Phase2='%f',Phase3='%f',Phase4='%f',timeStamp='%s',StaticIndex = %d,nodeResend = %d ",\ + dataDymX.DiagnosisPk, dataDymX.IntegratPk, dataDymX.IntegratRMS, dataDymX.RmsValues, dataDymX.EnvelopEnergy,\ + dataDymX.Amp1, dataDymX.Amp2, dataDymX.Amp3, dataDymX.Amp4, dataDymX.Amp5,dataDymX.Phase1, dataDymX.Phase2, dataDymX.Phase3, dataDymX.Phase4, nowTimetamp.c_str(),staticIndex,nodeResend); + if ( /*0 == sql_ctl->GetTableRows(T_DATA_INFO(TNAME), whereCon)*/(Count * 3 < SAVE_COUNT && lTime < OneWeek ) || strTime.size() == 0) {//1 week + char insertSql[1024] = { 0 }; + memset(insertSql,0x00,sizeof(insertSql)); + sprintf(insertSql, "'%s','%s','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f',%d,'%s','1',%d", strLongAddr.c_str(), (strLongAddr + "-X").c_str(), dataDymX.DiagnosisPk, dataDymX.IntegratPk, dataDymX.IntegratRMS, dataDymX.RmsValues, dataDymX.EnvelopEnergy,\ - dataDymX.Amp1, dataDymX.Amp2, dataDymX.Amp3, dataDymX.Amp4, dataDymX.Amp5,dataDymX.Phase1, dataDymX.Phase2, dataDymX.Phase3, dataDymX.Phase4, nowTimetamp.c_str()); - sql_ctl->InsertData(T_DATA_INFO(TNAME), insertSql); -// } else { -/* char updateSql[1024] = { 0 }; - sprintf(updateSql, "diagnosisPk='%f',integratPk='%f',integratRMS='%f',rmsValues='%f',envelopEnergy='%f',\ - Amp1='%f',Amp2='%f',Amp3='%f',Amp4='%f',Amp5='%f',Phase1='%f',Phase2='%f',Phase3='%f',Phase4='%f',timeStamp='%s'",\ - dataDymX.DiagnosisPk, dataDymX.IntegratPk, dataDymX.IntegratRMS, dataDymX.RmsValues, dataDymX.EnvelopEnergy,\ - dataDymX.Amp1, dataDymX.Amp2, dataDymX.Amp3, dataDymX.Amp4, dataDymX.Amp5,dataDymX.Phase1, dataDymX.Phase2, dataDymX.Phase3, dataDymX.Phase4, nowTimetamp.c_str()); - sql_ctl->UpdateTableData(T_DATA_INFO(TNAME), updateSql, whereCon); - } */ + dataDymX.Amp1, dataDymX.Amp2, dataDymX.Amp3, dataDymX.Amp4, dataDymX.Amp5,dataDymX.Phase1, dataDymX.Phase2, dataDymX.Phase3, dataDymX.Phase4, staticIndex,nowTimetamp.c_str(),nodeResend); + sql_ctl->InsertData(szTableName, insertSql); + + if(0 == sql_ctl->GetTableRows(T_DATA_INFO(TNAME), whereCon)) + sql_ctl->InsertData(T_DATA_INFO(TNAME), insertSql); + else + sql_ctl->UpdateTableData(T_DATA_INFO(TNAME), updateSql, whereCon); + } else { + memset(whereCon,0x00,sizeof(whereCon)); + sprintf(whereCon, "channelID='%s' and sendMsg = '1' and timeStamp = '%s'", (strLongAddr + "-X").c_str(),strTime.c_str()); +// sprintf(whereCon, "channelID='%s' and sendMsg = '1' ", (strLongAddr + "-X").c_str()); + sql_ctl->UpdateTableData(szTableName, updateSql, whereCon); + memset(whereCon,0x00,sizeof(whereCon)); + sprintf(whereCon, "channelID='%s' ", (strLongAddr + "-X").c_str()); + sql_ctl->UpdateTableData(T_DATA_INFO(TNAME), updateSql, whereCon); + } print_info("x:%s,%s,diagnosisPk=%f,integratPk=%f,integratRMS=%f,rmsValues=%f,envelopEnergy=%f,Amp1=%f,Amp2=%f,Amp3=%f,Amp4=%f,Amp5=%f,Phase1=%f,Phase2=%f,Phase3=%f,Phase4=%f,timeStamp=%s\n",\ strLongAddr.c_str(), (strLongAddr + "-X").c_str(), dataDymX.DiagnosisPk, dataDymX.IntegratPk, dataDymX.IntegratRMS, dataDymX.RmsValues, dataDymX.EnvelopEnergy,\ dataDymX.Amp1, dataDymX.Amp2, dataDymX.Amp3, dataDymX.Amp4, dataDymX.Amp5,dataDymX.Phase1, dataDymX.Phase2, dataDymX.Phase3, dataDymX.Phase4, nowTimetamp.c_str()); @@ -1172,7 +2445,7 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) valNodeFeature["timeStamp"] = nowTimetamp; valNodeData.append(valNodeFeature); DataRecvDym dataDymY; - memset(buf, 0, 8); + memset(buf, 0, sizeof(buf)); sprintf(buf, "%02x%02x", pRecvData->Data[37], pRecvData->Data[36]); iTemp = (unsigned int)strtol(buf, NULL, 16); highbit = iTemp >> 14 & 0x3; @@ -1194,7 +2467,7 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) } dataDymY.DiagnosisPk = lowbit * n; - memset(buf, 0, 8); + memset(buf, 0, sizeof(buf)); sprintf(buf, "%02x%02x", pRecvData->Data[39], pRecvData->Data[38]); iTemp = (unsigned int)strtol(buf, NULL, 16); highbit = iTemp >> 14 & 0x3; @@ -1216,7 +2489,7 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) } dataDymY.RmsValues = lowbit * n; - memset(buf, 0, 8); + memset(buf, 0, sizeof(buf)); sprintf(buf, "%02x%02x", pRecvData->Data[41], pRecvData->Data[40]); iTemp = (unsigned int)strtol(buf, NULL, 16); highbit = iTemp >> 14 & 0x3; @@ -1238,7 +2511,7 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) } dataDymY.IntegratPk = lowbit * n; - memset(buf, 0, 8); + memset(buf, 0, sizeof(buf)); sprintf(buf, "%02x%02x", pRecvData->Data[43], pRecvData->Data[42]); iTemp = (unsigned int)strtol(buf, NULL, 16); highbit = iTemp >> 14 & 0x3; @@ -1260,7 +2533,7 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) } dataDymY.IntegratRMS = lowbit * n; - memset(buf, 0, 8); + memset(buf, 0, sizeof(buf)); sprintf(buf, "%02x%02x", pRecvData->Data[45], pRecvData->Data[44]); iTemp = (unsigned int)strtol(buf, NULL, 16); highbit = iTemp >> 14 & 0x3; @@ -1282,7 +2555,7 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) } dataDymY.Amp1 = lowbit * n; - memset(buf, 0, 8); + memset(buf, 0, sizeof(buf)); sprintf(buf, "%02x%02x", pRecvData->Data[47], pRecvData->Data[46]); iTemp = (unsigned int)strtol(buf, NULL, 16); highbit = iTemp >> 14 & 0x3; @@ -1304,7 +2577,7 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) } dataDymY.Amp2 = lowbit * n; - memset(buf, 0, 8); + memset(buf, 0, sizeof(buf)); sprintf(buf, "%02x%02x", pRecvData->Data[49], pRecvData->Data[48]); iTemp = (unsigned int)strtol(buf, NULL, 16); highbit = iTemp >> 14 & 0x3; @@ -1326,7 +2599,7 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) } dataDymY.Amp3 = lowbit * n; - memset(buf, 0, 8); + memset(buf, 0, sizeof(buf)); sprintf(buf, "%02x%02x", pRecvData->Data[51], pRecvData->Data[50]); iTemp = (unsigned int)strtol(buf, NULL, 16); highbit = iTemp >> 14 & 0x3; @@ -1348,7 +2621,7 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) } dataDymY.Amp4 = lowbit * n; - memset(buf, 0, 8); + memset(buf, 0, sizeof(buf)); sprintf(buf, "%02x%02x", pRecvData->Data[53], pRecvData->Data[52]); iTemp = (unsigned int)strtol(buf, NULL, 16); highbit = iTemp >> 14 & 0x3; @@ -1370,133 +2643,147 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) } dataDymY.Amp5 = lowbit * n; - memset(buf, 0, 8); - sprintf(buf, "%02x%02x", pRecvData->Data[55], pRecvData->Data[54]); - iTemp = (unsigned int)strtol(buf, NULL, 16); - highbit = iTemp >> 14 & 0x3; - lowbit = iTemp & 0x3fff; - switch (highbit) - { - case 0: - n = 0.0001; - break; - case 1: - n = 0.01; - break; - case 2: - n = 1; - break; - case 3: - n = 100; - break; - } - dataDymY.EnvelopEnergy = lowbit * n; + memset(buf, 0, sizeof(buf)); +// sprintf(buf, "%02x%02x", pRecvData->Data[55], pRecvData->Data[54]); +// iTemp = (unsigned int)strtol(buf, NULL, 16); +// highbit = iTemp >> 14 & 0x3; +// lowbit = iTemp & 0x3fff; +// switch (highbit) +// { +// case 0: +// n = 0.0001; +// break; +// case 1: +// n = 0.01; +// break; +// case 2: +// n = 1; +// break; +// case 3: +// n = 100; +// break; +// } +// dataDymY.EnvelopEnergy = lowbit * n; - memset(buf, 0, 8); - sprintf(buf, "%02x%02x", pRecvData->Data[57], pRecvData->Data[56]); - iTemp = (unsigned int)strtol(buf, NULL, 16); - highbit = iTemp >> 14 & 0x3; - lowbit = iTemp & 0x3fff; - switch (highbit) - { - case 0: - n = 0.0001; - break; - case 1: - n = 0.01; - break; - case 2: - n = 1; - break; - case 3: - n = 100; - break; - } - dataDymY.Phase1 = lowbit * n; + dataDymY.EnvelopEnergy = 0; - memset(buf, 0, 8); - sprintf(buf, "%02x%02x", pRecvData->Data[59], pRecvData->Data[58]); - iTemp = (unsigned int)strtol(buf, NULL, 16); - highbit = iTemp >> 14 & 0x3; - lowbit = iTemp & 0x3fff; - switch (highbit) - { - case 0: - n = 0.0001; - break; - case 1: - n = 0.01; - break; - case 2: - n = 1; - break; - case 3: - n = 100; - break; - } - dataDymY.Phase2 = lowbit * n; + memset(buf, 0, sizeof(buf)); +// sprintf(buf, "%02x%02x", pRecvData->Data[57], pRecvData->Data[56]); +// iTemp = (unsigned int)strtol(buf, NULL, 16); +// highbit = iTemp >> 14 & 0x3; +// lowbit = iTemp & 0x3fff; +// switch (highbit) +// { +// case 0: +// n = 0.0001; +// break; +// case 1: +// n = 0.01; +// break; +// case 2: +// n = 1; +// break; +// case 3: +// n = 100; +// break; +// } + dataDymY.Phase1 = 0; - memset(buf, 0, 8); - sprintf(buf, "%02x%02x", pRecvData->Data[61], pRecvData->Data[60]); - iTemp = (unsigned int)strtol(buf, NULL, 16); - highbit = iTemp >> 14 & 0x3; - lowbit = iTemp & 0x3fff; - switch (highbit) - { - case 0: - n = 0.0001; - break; - case 1: - n = 0.01; - break; - case 2: - n = 1; - break; - case 3: - n = 100; - break; - } - dataDymY.Phase3 = lowbit * n; + memset(buf, 0, sizeof(buf)); +// sprintf(buf, "%02x%02x", pRecvData->Data[59], pRecvData->Data[58]); +// iTemp = (unsigned int)strtol(buf, NULL, 16); +// highbit = iTemp >> 14 & 0x3; +// lowbit = iTemp & 0x3fff; +// switch (highbit) +// { +// case 0: +// n = 0.0001; +// break; +// case 1: +// n = 0.01; +// break; +// case 2: +// n = 1; +// break; +// case 3: +// n = 100; +// break; +// } + dataDymY.Phase2 = 0; - memset(buf, 0, 8); - sprintf(buf, "%02x%02x", pRecvData->Data[63], pRecvData->Data[62]); - iTemp = (unsigned int)strtol(buf, NULL, 16); - highbit = iTemp >> 14 & 0x3; - lowbit = iTemp & 0x3fff; - switch (highbit) - { - case 0: - n = 0.0001; - break; - case 1: - n = 0.01; - break; - case 2: - n = 1; - break; - case 3: - n = 100; - break; - } - dataDymY.Phase4 = lowbit * n; + memset(buf, 0, sizeof(buf)); +// sprintf(buf, "%02x%02x", pRecvData->Data[61], pRecvData->Data[60]); +// iTemp = (unsigned int)strtol(buf, NULL, 16); +// highbit = iTemp >> 14 & 0x3; +// lowbit = iTemp & 0x3fff; +// switch (highbit) +// { +// case 0: +// n = 0.0001; +// break; +// case 1: +// n = 0.01; +// break; +// case 2: +// n = 1; +// break; +// case 3: +// n = 100; +// break; +// } + dataDymY.Phase3 = 0; - memset(whereCon, 0, 64); - sprintf(whereCon, "channelID='%s'", (strLongAddr + "-Y").c_str()); -// if ( 0 == sql_ctl->GetTableRows(T_DATA_INFO(TNAME), whereCon) ) { - // char insertSql[1024] = { 0 }; - memset(insertSql,0x00,sizeof(insertSql)); - sprintf(insertSql, "'%s','%s','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%s'", + memset(buf, 0, sizeof(buf)); +// sprintf(buf, "%02x%02x", pRecvData->Data[63], pRecvData->Data[62]); +// iTemp = (unsigned int)strtol(buf, NULL, 16); +// highbit = iTemp >> 14 & 0x3; +// lowbit = iTemp & 0x3fff; +// switch (highbit) +// { +// case 0: +// n = 0.0001; +// break; +// case 1: +// n = 0.01; +// break; +// case 2: +// n = 1; +// break; +// case 3: +// n = 100; +// break; +// } + dataDymY.Phase4 = 0; + + memset(whereCon, 0, 1024); + sprintf(whereCon, "channelID='%s' and sendMsg = '1'", (strLongAddr + "-Y").c_str()); + memset(updateSql, 0, 1024); + sprintf(updateSql, "diagnosisPk='%f',integratPk='%f',integratRMS='%f',rmsValues='%f',envelopEnergy='%f',\ + Amp1='%f',Amp2='%f',Amp3='%f',Amp4='%f',Amp5='%f',Phase1='%f',Phase2='%f',Phase3='%f',Phase4='%f',timeStamp='%s',StaticIndex = %d,nodeResend = %d ",\ + dataDymY.DiagnosisPk, dataDymY.IntegratPk, dataDymY.IntegratRMS, dataDymY.RmsValues, dataDymY.EnvelopEnergy,\ + dataDymY.Amp1, dataDymY.Amp2, dataDymY.Amp3, dataDymY.Amp4, dataDymY.Amp5,dataDymY.Phase1, dataDymY.Phase2, dataDymY.Phase3, dataDymY.Phase4, nowTimetamp.c_str(),staticIndex,nodeResend); + if ( /*0 == sql_ctl->GetTableRows(T_DATA_INFO(TNAME), whereCon)*/ (Count * 3 < SAVE_COUNT && lTime < OneWeek ) || strTime.size() == 0) { + char insertSql[1024] = { 0 }; + memset(insertSql,0x00,sizeof(insertSql)); + sprintf(insertSql, "'%s','%s','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f',%d,'%s','1',%d", strLongAddr.c_str(), (strLongAddr + "-Y").c_str(), dataDymY.DiagnosisPk, dataDymY.IntegratPk, dataDymY.IntegratRMS, dataDymY.RmsValues, dataDymY.EnvelopEnergy,\ - dataDymY.Amp1, dataDymY.Amp2, dataDymY.Amp3, dataDymY.Amp4, dataDymY.Amp5,dataDymY.Phase1, dataDymY.Phase2, dataDymY.Phase3, dataDymY.Phase4, nowTimetamp.c_str()); - sql_ctl->InsertData(T_DATA_INFO(TNAME), insertSql); - // } else { -/* char updateSql[1024] = { 0 }; - sprintf(updateSql, "diagnosisPk='%f',integratPk='%f',integratRMS='%f',rmsValues='%f',envelopEnergy='%f',\ - Amp1='%f',Amp2='%f',Amp3='%f',Amp4='%f',Amp5='%f',Phase1='%f',Phase2='%f',Phase3='%f',Phase4='%f',timeStamp='%s'",\ - dataDymY.DiagnosisPk, dataDymY.IntegratPk, dataDymY.IntegratRMS, dataDymY.RmsValues, dataDymY.EnvelopEnergy,\ - dataDymY.Amp1, dataDymY.Amp2, dataDymY.Amp3, dataDymY.Amp4, dataDymY.Amp5,dataDymY.Phase1, dataDymY.Phase2, dataDymY.Phase3, dataDymY.Phase4, nowTimetamp.c_str()); + dataDymY.Amp1, dataDymY.Amp2, dataDymY.Amp3, dataDymY.Amp4, dataDymY.Amp5,dataDymY.Phase1, dataDymY.Phase2, dataDymY.Phase3, dataDymY.Phase4,staticIndex, nowTimetamp.c_str(),nodeResend); + sql_ctl->InsertData(szTableName, insertSql); + + if(0 == sql_ctl->GetTableRows(T_DATA_INFO(TNAME), whereCon)) + sql_ctl->InsertData(T_DATA_INFO(TNAME), insertSql); + else + sql_ctl->UpdateTableData(T_DATA_INFO(TNAME), updateSql, whereCon); + } else { + + memset(whereCon,0x00,sizeof(whereCon)); + sprintf(whereCon, "channelID='%s' and sendMsg = '1' and timeStamp = '%s'", (strLongAddr + "-Y").c_str(),strTime.c_str()); +// sprintf(whereCon, "channelID='%s' and sendMsg = '1' ", (strLongAddr + "-Y").c_str()); + sql_ctl->UpdateTableData(szTableName, updateSql, whereCon); + memset(whereCon,0x00,sizeof(whereCon)); + sprintf(whereCon, "channelID='%s' ", (strLongAddr + "-Y").c_str()); sql_ctl->UpdateTableData(T_DATA_INFO(TNAME), updateSql, whereCon); - }*/ + } print_info("y: %s,%s,diagnosisPk=%f,integratPk=%f,integratRMS=%f,rmsValues=%f,envelopEnergy=%f,Amp1=%f,Amp2=%f,Amp3=%f,Amp4=%f,Amp5=%f,Phase1=%f,Phase2=%f,Phase3=%f,Phase4=%f,timeStamp=%s\n",\ strLongAddr.c_str(), (strLongAddr + "-Y").c_str(), dataDymY.DiagnosisPk, dataDymY.IntegratPk, dataDymY.IntegratRMS, dataDymY.RmsValues, dataDymY.EnvelopEnergy,\ dataDymY.Amp1, dataDymY.Amp2, dataDymY.Amp3, dataDymY.Amp4, dataDymY.Amp5,dataDymY.Phase1, dataDymY.Phase2, dataDymY.Phase3, dataDymY.Phase4, nowTimetamp.c_str()); @@ -1522,7 +2809,7 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) valNodeData.append(valNodeFeature); DataRecvDym dataDymZ; - memset(buf, 0, 8); + memset(buf, 0, sizeof(buf)); sprintf(buf, "%02x%02x", pRecvData->Data[65], pRecvData->Data[64]); iTemp = (unsigned int)strtol(buf, NULL, 16); highbit = iTemp >> 14 & 0x3; @@ -1544,7 +2831,7 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) } dataDymZ.DiagnosisPk = lowbit * n; - memset(buf, 0, 8); + memset(buf, 0, sizeof(buf)); sprintf(buf, "%02x%02x", pRecvData->Data[67], pRecvData->Data[66]); iTemp = (unsigned int)strtol(buf, NULL, 16); highbit = iTemp >> 14 & 0x3; @@ -1566,7 +2853,7 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) } dataDymZ.RmsValues = lowbit * n; - memset(buf, 0, 8); + memset(buf, 0, sizeof(buf)); sprintf(buf, "%02x%02x", pRecvData->Data[69], pRecvData->Data[68]); iTemp = (unsigned int)strtol(buf, NULL, 16); highbit = iTemp >> 14 & 0x3; @@ -1588,7 +2875,7 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) } dataDymZ.IntegratPk = lowbit * n; - memset(buf, 0, 8); + memset(buf, 0, sizeof(buf)); sprintf(buf, "%02x%02x", pRecvData->Data[71], pRecvData->Data[70]); iTemp = (unsigned int)strtol(buf, NULL, 16); highbit = iTemp >> 14 & 0x3; @@ -1610,7 +2897,7 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) } dataDymZ.IntegratRMS = lowbit * n; - memset(buf, 0, 8); + memset(buf, 0, sizeof(buf)); sprintf(buf, "%02x%02x", pRecvData->Data[73], pRecvData->Data[72]); iTemp = (unsigned int)strtol(buf, NULL, 16); highbit = iTemp >> 14 & 0x3; @@ -1632,7 +2919,7 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) } dataDymZ.Amp1 = lowbit * n; - memset(buf, 0, 8); + memset(buf, 0, sizeof(buf)); sprintf(buf, "%02x%02x", pRecvData->Data[75], pRecvData->Data[74]); iTemp = (unsigned int)strtol(buf, NULL, 16); highbit = iTemp >> 14 & 0x3; @@ -1654,7 +2941,7 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) } dataDymZ.Amp2 = lowbit * n; - memset(buf, 0, 8); + memset(buf, 0, sizeof(buf)); sprintf(buf, "%02x%02x", pRecvData->Data[77], pRecvData->Data[76]); iTemp = (unsigned int)strtol(buf, NULL, 16); highbit = iTemp >> 14 & 0x3; @@ -1676,7 +2963,7 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) } dataDymZ.Amp3 = lowbit * n; - memset(buf, 0, 8); + memset(buf, 0, sizeof(buf)); sprintf(buf, "%02x%02x", pRecvData->Data[79], pRecvData->Data[78]); iTemp = (unsigned int)strtol(buf, NULL, 16); highbit = iTemp >> 14 & 0x3; @@ -1698,7 +2985,7 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) } dataDymZ.Amp4 = lowbit * n; - memset(buf, 0, 8); + memset(buf, 0, sizeof(buf)); sprintf(buf, "%02x%02x", pRecvData->Data[81], pRecvData->Data[80]); iTemp = (unsigned int)strtol(buf, NULL, 16); highbit = iTemp >> 14 & 0x3; @@ -1720,7 +3007,7 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) } dataDymZ.Amp5 = lowbit * n; - memset(buf, 0, 8); + memset(buf, 0, sizeof(buf)); sprintf(buf, "%02x%02x", pRecvData->Data[83], pRecvData->Data[82]); iTemp = (unsigned int)strtol(buf, NULL, 16); highbit = iTemp >> 14 & 0x3; @@ -1742,7 +3029,7 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) } dataDymZ.EnvelopEnergy = lowbit * n; - memset(buf, 0, 8); + memset(buf, 0, sizeof(buf)); sprintf(buf, "%02x%02x", pRecvData->Data[85], pRecvData->Data[84]); iTemp = (unsigned int)strtol(buf, NULL, 16); highbit = iTemp >> 14 & 0x3; @@ -1764,7 +3051,7 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) } dataDymZ.Phase1 = lowbit * n; - memset(buf, 0, 8); + memset(buf, 0, sizeof(buf)); sprintf(buf, "%02x%02x", pRecvData->Data[87], pRecvData->Data[86]); iTemp = (unsigned int)strtol(buf, NULL, 16); highbit = iTemp >> 14 & 0x3; @@ -1786,7 +3073,7 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) } dataDymZ.Phase2 = lowbit * n; - memset(buf, 0, 8); + memset(buf, 0, sizeof(buf)); sprintf(buf, "%02x%02x", pRecvData->Data[89], pRecvData->Data[88]); iTemp = (unsigned int)strtol(buf, NULL, 16); highbit = iTemp >> 14 & 0x3; @@ -1808,7 +3095,6 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) } dataDymZ.Phase3 = lowbit * n; - memset(buf, 0, 8); sprintf(buf, "%02x%02x", pRecvData->Data[91], pRecvData->Data[90]); iTemp = (unsigned int)strtol(buf, NULL, 16); highbit = iTemp >> 14 & 0x3; @@ -1830,27 +3116,45 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) } dataDymZ.Phase4 = lowbit * n; - memset(whereCon, 0, 64); - sprintf(whereCon, "channelID='%s'", (strLongAddr + "-Z").c_str()); -// if ( 0 == sql_ctl->GetTableRows(T_DATA_INFO(TNAME), whereCon) ) { -// char insertSql[1024] = { 0 }; - memset(insertSql,0x00,sizeof(insertSql)); - sprintf(insertSql, "'%s','%s','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%s'", + memset(whereCon, 0, 1024); + sprintf(whereCon, "channelID='%s' and sendMsg = '1'", (strLongAddr + "-Z").c_str()); + memset(updateSql, 0, 1024); + + sprintf(updateSql, "diagnosisPk='%f',integratPk='%f',integratRMS='%f',rmsValues='%f',envelopEnergy='%f',\ + Amp1='%f',Amp2='%f',Amp3='%f',Amp4='%f',Amp5='%f',Phase1='%f',Phase2='%f',Phase3='%f',Phase4='%f',timeStamp='%s',StaticIndex = %d,nodeResend = %d ",\ + dataDymZ.DiagnosisPk, dataDymZ.IntegratPk, dataDymZ.IntegratRMS, dataDymZ.RmsValues, dataDymZ.EnvelopEnergy,\ + dataDymZ.Amp1, dataDymZ.Amp2, dataDymZ.Amp3, dataDymZ.Amp4, dataDymZ.Amp5,dataDymZ.Phase1, dataDymZ.Phase2, dataDymZ.Phase3, dataDymZ.Phase4, nowTimetamp.c_str(),staticIndex,nodeResend); + if ( /*0 == sql_ctl->GetTableRows(T_DATA_INFO(TNAME), whereCon)*/ Count *3 < SAVE_COUNT && (lTime < OneWeek || strTime.size() == 0)) { + char insertSql[1024] = { 0 }; + memset(insertSql,0x00,sizeof(insertSql)); + sprintf(insertSql, "'%s','%s','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f',%d,'%s','1',%d", strLongAddr.c_str(), (strLongAddr + "-Z").c_str(), dataDymZ.DiagnosisPk, dataDymZ.IntegratPk, dataDymZ.IntegratRMS, dataDymZ.RmsValues, dataDymZ.EnvelopEnergy,\ - dataDymZ.Amp1, dataDymZ.Amp2, dataDymZ.Amp3, dataDymZ.Amp4, dataDymZ.Amp5,dataDymZ.Phase1, dataDymZ.Phase2, dataDymZ.Phase3, dataDymZ.Phase4, nowTimetamp.c_str()); - sql_ctl->InsertData(T_DATA_INFO(TNAME), insertSql); - /* } else { - char updateSql[1024] = { 0 }; - sprintf(updateSql, "diagnosisPk='%f',integratPk='%f',integratRMS='%f',rmsValues='%f',envelopEnergy='%f',\ - Amp1='%f',Amp2='%f',Amp3='%f',Amp4='%f',Amp5='%f',Phase1='%f',Phase2='%f',Phase3='%f',Phase4='%f',timeStamp='%s'",\ - dataDymZ.DiagnosisPk, dataDymZ.IntegratPk, dataDymZ.IntegratRMS, dataDymZ.RmsValues, dataDymZ.EnvelopEnergy,\ - dataDymZ.Amp1, dataDymZ.Amp2, dataDymZ.Amp3, dataDymZ.Amp4, dataDymZ.Amp5,dataDymZ.Phase1, dataDymZ.Phase2, dataDymZ.Phase3, dataDymZ.Phase4, nowTimetamp.c_str()); + dataDymZ.Amp1, dataDymZ.Amp2, dataDymZ.Amp3, dataDymZ.Amp4, dataDymZ.Amp5,dataDymZ.Phase1, dataDymZ.Phase2, dataDymZ.Phase3, dataDymZ.Phase4, staticIndex,nowTimetamp.c_str(),nodeResend); + sql_ctl->InsertData(szTableName, insertSql); + + if(0 == sql_ctl->GetTableRows(T_DATA_INFO(TNAME), whereCon)) + sql_ctl->InsertData(T_DATA_INFO(TNAME), insertSql); + else + sql_ctl->UpdateTableData(T_DATA_INFO(TNAME), updateSql, whereCon); + } else { + + memset(whereCon,0x00,sizeof(whereCon)); + sprintf(whereCon, "channelID='%s' and sendMsg = '1' and timeStamp = '%s'", (strLongAddr + "-Z").c_str(),strTime.c_str()); +// sprintf(whereCon, "channelID='%s' and sendMsg = '1'", (strLongAddr + "-Z").c_str()); + sql_ctl->UpdateTableData(szTableName, updateSql, whereCon); + memset(whereCon,0x00,sizeof(whereCon)); + sprintf(whereCon, "channelID='%s' ", (strLongAddr + "-Z").c_str()); sql_ctl->UpdateTableData(T_DATA_INFO(TNAME), updateSql, whereCon); - } */ + } print_info("Z: %s,%s,diagnosisPk=%f,integratPk=%f,integratRMS=%f,rmsValues=%f,envelopEnergy=%f,Amp1=%f,Amp2=%f,Amp3=%f,Amp4=%f,Amp5=%f,Phase1=%f,Phase2=%f,Phase3=%f,Phase4=%f,timeStamp=%s\n",\ strLongAddr.c_str(), (strLongAddr + "-Z").c_str(), dataDymZ.DiagnosisPk, dataDymZ.IntegratPk, dataDymZ.IntegratRMS, dataDymZ.RmsValues, dataDymZ.EnvelopEnergy,\ dataDymZ.Amp1, dataDymZ.Amp2, dataDymZ.Amp3, dataDymZ.Amp4, dataDymZ.Amp5,dataDymZ.Phase1, dataDymZ.Phase2, dataDymZ.Phase3, dataDymZ.Phase4, nowTimetamp.c_str()); + memset(whereCon,0x00,sizeof(whereCon)); + sprintf(whereCon, "dataNodeNo='%s'", strLongAddr.c_str()); + sql_ctl->UpdateTableData(T_SENSOR_INFO(TNAME), "status='1'", whereCon); + //string strData = sql_ctl->GetNodeConfigureInfor(whereCon); + //data_publish(strData.c_str(), GlobalConfig::Topic_G.mPubConfig.c_str()); //无线传感器Z信息 valNodeFeature["dataNodeNo"] = strLongAddr; valNodeFeature["ChannelId"] = strLongAddr + "-Z"; @@ -1871,6 +3175,18 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) valNodeFeature["timeStamp"] = nowTimetamp; valNodeData.append(valNodeFeature); + memset(whereCon, 0, 1024); + sprintf(whereCon, "dataNodeNo='%s'", strLongAddr.c_str()); + + string strBattery = sql_ctl->GetData(T_SENSOR_INFO(TNAME),"batteryPower",whereCon); + vector vBattery; + vBattery.push_back("0"); + vBattery.push_back("0"); + if(strBattery.length() > 0){ + + boost::split( vBattery, strBattery, boost::is_any_of( "," ), boost::token_compress_on ); + } + //无线传感器信息 Json::Value root; Json::Value valdatastatic; @@ -1881,6 +3197,8 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) valdatastatic["ChannelType"] = "STATUS"; valdatastatic["ChannelId"] = strLongAddr + "-S"; valdatastatic["TimeStamp"] = nowTimetamp; + valdatastatic["bateryProportion"] = atof(vBattery[0].c_str()); + valdatastatic["batteryRemainDay"] = atof(vBattery[1].c_str()); valdatastatic["dataNodeNo"] = strLongAddr; valNodeData.append(valdatastatic); @@ -1891,18 +3209,46 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) Json::FastWriter featureValue; std::string strstatisticData = featureValue.write(root); //传感器发来的数据包中的表示设备信息的数据转化为json格式后,通过调用data_publish将数据传给mqttclient : Topic:wireless/cmd/60294D203717 - data_publish(strstatisticData.c_str(), GlobalConfig::Topic_G.mPubData.c_str()); + int iRet = data_publish(strstatisticData.c_str(), GlobalConfig::Topic_G.mPubData.c_str()); + print_info("dataNodeNo = '%s' and TimeStamp = '%s',MQTT ret = %d\n",strLongAddr.c_str(),nowTimetamp.c_str(),iRet); + if(iRet != 0){ + char updateSql[1024] = { 0 }; + memset(whereCon, 0, 64); + sprintf(whereCon, "dataNodeNo = '%s' and TimeStamp = '%s'", strLongAddr.c_str(),nowTimetamp.c_str()); + memcpy(updateSql, "sendMsg='0'",sizeof(updateSql)); + sql_ctl->UpdateTableData(szTableNameStatic, updateSql, whereCon); + sql_ctl->UpdateTableData(szTableNameData, updateSql, whereCon); + } //综上代码,把静态数据,x y z轴的特征值存放到sql数据库中(如果数据原来不存在,则插入新数据;如果存在,则更新数据) + print_info("Dip : %d TemBot : %f TemBot : %f Voltage : %d\n", dataStatic.Dip, dataStatic.TemBot, dataStatic.TemTop, dataStatic.Voltage); + memset(selectCon,0x00,sizeof(selectCon)); + sprintf(selectCon, "zigbeeSignal <> '' ORDER BY timeStamp desc LIMIT 0,1"); + strTime = sql_ctl->GetData(szTableNameStatic, "timeStamp", selectCon); + if((atol(nowTimetamp.c_str()) - atol(strTime.c_str()) > 3600) && + (unsigned short)GlobalConfig::Zigbee_G.MyAddr == 0x9999)// 24h = 86400s ; 8h = 36000 ; 16h = 72000 + { + LOG_DEBUG("Zigbee Signal !\n"); + int Times = 0; + bZigbeeSinal = true; + usleep(20000); + while(Times < 3 && bZigbeeSinal){ + getZigbeeSignal(pRecvData->ShortAddr); + Times ++ ; + usleep(20000);; + } + bZigbeeSinal = false; + } + } void Uart::DealDataNodeWave(const char *pData) { - print_info("recv wave\n"); + //print_info("recv wave\n"); RecvData * pRecvData = (RecvData *)pData; m_VecWaveData.push_back(*pRecvData); - print_blue("wave data size is(m_VecWaveData.size) : %d\n",m_VecWaveData.size()); + //print_blue("wave data size is(m_VecWaveData.size) : %d\n",m_VecWaveData.size()); char localtimestamp[32] = { 0 }; GetTimeNet(localtimestamp, 1); // 接收到原始数据信息,则更新时间戳,如果三秒种未收到原始数据,则重新从短地址 9999 切换回 短地址 8888 @@ -1920,7 +3266,7 @@ void Uart::DealWaveThread() //连续三秒没有原始数据,则处理缓存 // 接收到原始波形,则 m_TimeStamp 不为零 // 如果当前时间与记录时间超过3秒,要求,m_TimeStamp不变化,而数据在传输,则一定小于3秒 if (0 == m_TimeStamp) { - boost::this_thread::sleep(boost::posix_time::seconds(1)); + sleep(1); continue; } char localtimestamp[32] = { 0 }; @@ -1935,25 +3281,31 @@ void Uart::DealWaveThread() //连续三秒没有原始数据,则处理缓存 } //if ((nowTimeStamp - m_TimeStamp) > 3) { 时间戳需要修改为绝对值,可能丢失时钟,或工作一会儿,才同步时钟,可能减出异常值 if (tmpTimeStamp > 3 ) { // TODO: 时间戳需要修改为绝对值,可能丢失时钟,或工作一会儿,才同步时钟,可能减出异常值 print_info("yes!The time difference is more than 3,nowTimeStamp : %ld m_TimeStamp : %ld\n", nowTimeStamp, m_TimeStamp); - DealWave(); + //DealWave(); m_TimeStamp = 0; offSize = 0; GlobalConfig::EnterZigBeeWaveTransmittingFlag_G = NO_ENTER_TRANSMITTING_STATUS; GlobalConfig::EnterZigBeeWaveTransmittingCnt_G = 0; // 准备重新恢复到 8888 PanID,正常接收特征数据 - ZigbeeInit(); - pUart->UpdateZigbeeInfoCtrl(); + mPackgeIndex = -1; + //WriteLocalAddr(0x8888); + //GlobalConfig::Zigbee_G.MyAddr = 0x8888; + +// WriteShortAddr2Zigbee(0x8888); +// UpdateZigbeeInfoCtrl(); + } else { print_info("NO! The time difference is less than 3,nowTimeStamp : %ld m_TimeStamp : %ld\n", nowTimeStamp, m_TimeStamp); - } + } - boost::this_thread::sleep(boost::posix_time::seconds(1)); + sleep(1); } } void Uart::DealWave() { - print_info("begin deal Wave data !\n"); + LOG_DEBUG("begin deal Wave data !\n"); + print_blue("wave data size is(m_VecWaveData.size) : %d\n",m_VecWaveData.size()); std::string strShortAddr = ""; std::string strShortAddrTemp; std::string strLongAddr = ""; @@ -1965,7 +3317,8 @@ void Uart::DealWave() char buf[8]; RecvData recvTemp; - print_info("all wave data size is(m_VecWaveData.size) : %d\n", m_VecWaveData.size()); + LOG_INFO("all wave data size is(m_VecWaveData.size) : %d \n",\ + m_VecWaveData.size()); while (m_VecWaveData.size() > 0) { //对每个传感器的每个通道进行遍历然后处理数据,例如:传感器1x轴的数据处理完后,再去处理y轴的。传感器1的所有数据处理完后,再处理传感器2的 std::vector::iterator iter = m_VecWaveData.begin(); recvTemp = *iter; @@ -1975,14 +3328,16 @@ void Uart::DealWave() memset(buf, 0, 8); sprintf(buf, "%02d", recvTemp.Type&0xFF); - iChannel = boost::lexical_cast(buf); + iChannel = atoi(buf); char getLongAddr_sql[32] = { 0 }; sprintf(getLongAddr_sql, "zigbeeShortAddr='%s'", strShortAddr.c_str()); - strLongAddr = sql_ctl->GetData(T_SENSOR_INFO(TNAME), T_SENSOR_INFO(ZIGBEELONGADDR), getLongAddr_sql); + //strLongAddr = sql_ctl->GetData(T_SENSOR_INFO(TNAME), T_SENSOR_INFO(ZIGBEELONGADDR), getLongAddr_sql); + vec_t res = sql_ctl->GetDataSingleLine(T_SENSOR_INFO(TNAME)," * ",getLongAddr_sql); + strLongAddr = res[0]; //print_info("3.1.2.3--->strLongAddr : %s\n", strLongAddr.c_str()); if ( 0 == strLongAddr.length() ) { - boost::this_thread::sleep(boost::posix_time::seconds(1)); + sleep(1); continue; } @@ -1990,16 +3345,21 @@ void Uart::DealWave() int n = 0; int range = 0; float coe = 0; + int sampleRate = 0,ACCSampleTime = 0; char getrange[32] = {0}; std::string str = "range"; - sprintf(getrange, "scope='%s'", str.c_str()); - ran = sql_ctl->GetData(T_SENSOR_INFO(TNAME), T_SENSOR_INFO(RANGE), getrange); - //print_info("@@@@@@@@@@@@@@@@@@@@@@ran=%s\n",ran.c_str()); + sprintf(getrange, "zigbeeShortAddr='%s'", strShortAddr.c_str()); + //ran = sql_ctl->GetData(T_SENSOR_INFO(TNAME), T_SENSOR_INFO(RANGE), getrange); + ran = res[25]; + sampleRate = atoi(res[23].c_str()); + ACCSampleTime = atoi(res[36].c_str()); +// print_info("@@@@@@@@@@@@@@@@@@@@@@ran=%s\n",ran.c_str()); memset(getrange, 0, 32); sprintf(getrange, "%s", ran.c_str()); n = (int)strtol(getrange, NULL, 32); - //print_light_purple("!!!!!!!!!!!!!n=%d\n",n); - switch (n) +// print_light_purple("!!!!!!!!!!!!!n=%d\n",n); + if(res[17] == "01"){ + switch (n) { case 0:{ range = 8; @@ -2022,6 +3382,18 @@ void Uart::DealWave() } break; } + }else if(res[17] == "02"){ + if(iChannel == 3 || iChannel == 4){ + coe = 0.00048828125; + } + if(iChannel == 5){ + if(res[8] == "0.1"){ + coe = 0.0034521484375;//0.03265968810083316; + }else{ + coe = 0.00172607421875; + } + } + } //print_blue("##############range = %d,%f\n",range,coe); for(; iter != m_VecWaveData.end();) { @@ -2032,23 +3404,52 @@ void Uart::DealWave() memset(buf, 0, 8); sprintf(buf, "%02d", recvTemp.Type & 0xFF); - iChannelTemp = boost::lexical_cast(buf); + iChannelTemp = atoi(buf); if( 0 == strShortAddr.compare(strShortAddrTemp) && (iChannel == iChannelTemp) ) { float fTemp; - for (int i = 0; i < 46; i++) { - memset(buf, 0, 8); - sprintf(buf, "%02x%02x", recvTemp.Data[2*i+1],recvTemp.Data[i*2]); - iTemp = strtol(buf, NULL, 16); - if (iTemp < 0x8000) { - fTemp = iTemp * coe; - } else { - fTemp = (((~iTemp)&0xffff) + 1) * -coe; - } - //print_blue("wave data is %u,%f\n",iTemp,fTemp); - vecData.push_back(fTemp); + { + for (int i = 0; i < 46; i++) { + memset(buf, 0, 8); + sprintf(buf, "%02x%02x", recvTemp.Data[2*i+1],recvTemp.Data[i*2]); + iTemp = strtol(buf, NULL, 16); + if (iTemp < 0x8000) { + fTemp = iTemp * coe * 9.8; //convert to m/s2 + } else { + fTemp = (((~iTemp)&0xffff) + 1) * - coe * 9.8; //convert to m/s2 + } + // print_blue("wave data is %u,%f,%f\n",iTemp,fTemp, coe); + vecData.push_back(fTemp); + if(res[17] == "01"){ + //print_blue("vecData.size() = %d,sampleRate * ACCSampleTime = %d,iChannel = %d\n",vecData.size(),sampleRate * ACCSampleTime,iChannel); + if(vecData.size() >= sampleRate * ACCSampleTime && iChannel == 3 ){//过滤数据包结尾空数据 + print_blue("%d vecData.size() == %d,sampleRate * ACCSampleTime = %d\n",iChannel,vecData.size(),sampleRate * ACCSampleTime); + break; + } + if(vecData.size() >= sampleRate * ACCSampleTime && iChannel == 4 ){//过滤数据包结尾空数据 + print_blue("%d vecData.size() == %d,sampleRate * ACCSampleTime = %d\n",iChannel,vecData.size(),sampleRate * ACCSampleTime); + break; + } + if(vecData.size() >= sampleRate * ACCSampleTime && iChannel == 5 ){//过滤数据包结尾空数据 + print_blue("%d vecData.size() == %d,sampleRate * ACCSampleTime = %d\n",iChannel,vecData.size(),sampleRate * ACCSampleTime); + + break; + } + }else if(res[17] == "02"){ + if(vecData.size() >= 8192 && iChannel == 3 ){//过滤数据包结尾空数据 + break; + } + if(vecData.size() >= 8192 && iChannel == 4 ){//过滤数据包结尾空数据 + break; + } + if(vecData.size() >= sampleRate * ACCSampleTime && iChannel == 5 ){//过滤数据包结尾空数据 + break; + } + } + } } iter = m_VecWaveData.erase(iter); + //print_blue("m_VecWaveData.size() == %d,vecData = %d\n",m_VecWaveData.size(),vecData.size()); } else { iter++; } @@ -2061,9 +3462,12 @@ void Uart::DealWave() print_info("strLongAddr : %s\n", strLongAddr.c_str());*/ if ( 0 == strLongAddr.length() ) { - boost::this_thread::sleep(boost::posix_time::seconds(1)); + sleep(1); continue; } + char localtimestamp[32] = { 0 }; + GetTimeNet(localtimestamp, 1); + std::string nowTimetamp = std::string(localtimestamp); std::string strChannelID = ""; switch (iChannel) { @@ -2093,47 +3497,311 @@ void Uart::DealWave() FILE *fp = fopen(strFileName.c_str(), "w"); + fwrite(localtimestamp,sizeof(localtimestamp),1,fp); print_info("fopen FIle vecData.size : %d\n", vecData.size()); + float mean = pCalculation->mean(vecData); float frTemp; char buf[33]={0x00}; std::string strWaveData = ""; for (int i = 0; i < vecData.size(); i++) { - frTemp = vecData[i]; + frTemp = vecData[i] - mean; fwrite(&frTemp,sizeof(float),1,fp); memset(buf,0x00,sizeof(buf)); - sprintf(buf, "%.2f", vecData[i]); + sprintf(buf, "%.2f", frTemp); std::string waveTemp(buf); if(i == 0) strWaveData = waveTemp; strWaveData = strWaveData + "," + waveTemp; } - vecData.clear(); + fclose(fp); // Json::Value valWaveData; - valWaveData["number"] = strWaveData.length(); + int length = vecData.size(); + valWaveData["number"] = sampleRate; valWaveData["channelId"] = strChannelID; valWaveData["dataNodeNo"] = strLongAddr; valWaveData["dataNodeGatewayNo"] = GlobalConfig::MacAddr_G; valWaveData["SensorEngineeringUnit"] = ""; + valWaveData["timeStamp"] = nowTimetamp; valWaveData["waveData"] = strWaveData; + valWaveData["mean"] = mean; Json::FastWriter WaveValue; std::string WaveData = WaveValue.write(valWaveData); - //传感器发来的数据包中的表示设备信息的数据转化为json格式后,通过调用data_publish将数据传给mqttclient : Topic:wireless/cmd/60294D203717 - data_publish(WaveData.c_str(), GlobalConfig::Topic_G.mPubWaveData.c_str()); - print_info("write data to filename %s\n", strFileName.c_str()); - boost::this_thread::sleep(boost::posix_time::seconds(1)); - } - offSize = 0; + if(res[17] == "01"){ + //print_blue("vecData.size() = %d,sampleRate * ACCSampleTime = %d,iChannel = %d\n",vecData.size(),sampleRate * ACCSampleTime,iChannel); + if(vecData.size() < sampleRate * ACCSampleTime && iChannel == 3 ){//过滤数据包结尾空数据 + print_blue("%d vecData.size() == %d,sampleRate * ACCSampleTime = %d\n",iChannel,vecData.size(),sampleRate * ACCSampleTime); + std::vector().swap(vecData); + continue; + } + if(vecData.size() < sampleRate * ACCSampleTime && iChannel == 4 ){//过滤数据包结尾空数据 + print_blue("%d vecData.size() == %d,sampleRate * ACCSampleTime = %d\n",iChannel,vecData.size(),sampleRate * ACCSampleTime); + std::vector().swap(vecData); + continue; + } + if(vecData.size() < sampleRate * ACCSampleTime && iChannel == 5 ){//过滤数据包结尾空数据 + print_blue("%d vecData.size() == %d,sampleRate * ACCSampleTime = %d\n",iChannel,vecData.size(),sampleRate * ACCSampleTime); + std::vector().swap(vecData); + continue; + } + }else if(res[17] == "02"){ + if(vecData.size() < 8192 && iChannel == 3 ){//过滤数据包结尾空数据 + continue; + } + if(vecData.size() < 8192 && iChannel == 4 ){//过滤数据包结尾空数据 + continue; + } + if(vecData.size() < sampleRate * ACCSampleTime && iChannel == 5 ){//过滤数据包结尾空数据 + continue; + } + } + + char selectCon[128] = { 0 }; + sprintf(selectCon, "channelID='%s' and sendMsg = '1' ORDER BY timeStamp ASC LIMIT 0,1",strChannelID.c_str()); + std::string strTime = sql_ctl->GetData("t_data_waveSend", "timeStamp", selectCon); + long lTime = atol(nowTimetamp.c_str())-atol(strTime.c_str()); + int Count = sql_ctl->GetTableRows("t_data_waveSend", NULL); + std::string strFileName_Record = strFileName + "_" + nowTimetamp; + if ((Count * 3 < SAVE_COUNT && lTime < OneWeek ) || strTime.size() == 0 ) { + char insertSql[128]={0x00}; + sprintf(insertSql,"'%s','%s','%s',1,0",strChannelID.c_str(),strFileName_Record.c_str(),nowTimetamp.c_str()); + sql_ctl->InsertData("t_data_waveSend", insertSql); + }else{ + char updateSql[128] = { 0 },whereCon[128] = {0}; + sprintf(updateSql, "waveName='%s',timeStamp='%s'",strFileName_Record.c_str(),nowTimetamp.c_str()); + memset(whereCon,0x00,sizeof(whereCon)); + sprintf(whereCon, "channelID='%s' and sendMsg = '1' and timeStamp = '%s'", strChannelID.c_str(),strTime.c_str()); + print_info("update static data to sql\n"); + sql_ctl->UpdateTableData("t_data_waveSend", updateSql, whereCon); + } + //传感器发来的数据包中的表示设备信息的数据转化为json格式后,通过调用data_publish将数据传给mqttclient : Topic:wireless/cmd/60294D203717 + + int iRet = data_publish(WaveData.c_str(), GlobalConfig::Topic_G.mPubWaveData.c_str()); + if(iRet != 0){ + char whereCon[1024] = {0x00}; + char updateSql[1024] = {0x00}; + char tmpWhere[128]={0x00}; + sprintf(tmpWhere,"channelID = '%s' and sendMsg = 0 ",strChannelID.c_str()); + int count = sql_ctl->GetTableRows("t_data_waveSend", tmpWhere); + LOG_ERROR("save channlID %s dat count = %d\n",strChannelID.c_str(),count); + if(count <= 12) + { + sprintf(whereCon, "channelID='%s' and timeStamp = '%s' ", strChannelID.c_str(),nowTimetamp.c_str()); + sprintf(updateSql, "SendMsg = 0 "); + sql_ctl->UpdateTableData("t_data_waveSend", updateSql, whereCon); + LOG_ERROR("send failed,filename %s,iRet = %d\n",strFileName.c_str(),iRet); + string strFileName_failed = strFileName + "_" + nowTimetamp; + char tmpCmd[128]={0x00}; + sprintf(tmpCmd,"cp %s %s",strFileName.c_str(),strFileName_failed.c_str()); + system(tmpCmd); + }else { + memset(tmpWhere,0x00,sizeof(tmpWhere)); + memset(updateSql,0x00,sizeof(updateSql)); + sprintf(tmpWhere, " sendMsg = 0 and channelID='%s' ORDER BY timeStamp ASC LIMIT 0,1",strChannelID.c_str()); + vec_t vecRet = sql_ctl->GetDataSingleLine("t_data_waveSend","*",tmpWhere); + memset(tmpWhere,0x00,sizeof(tmpWhere)); + sprintf(tmpWhere, " sendMsg = 0 and timeStamp = '%s' and channelID = '%s' ",vecRet[2].c_str(),vecRet[0].c_str()); + sprintf(updateSql, "sendMsg = 3 "); + int iRet = sql_ctl->UpdateTableData("t_data_waveSend", updateSql, tmpWhere); + memset(tmpWhere,0x00,sizeof(tmpWhere)); + memset(updateSql,0x00,sizeof(updateSql)); + sprintf(whereCon, "channelID='%s' and timeStamp = '%s' ", strChannelID.c_str(),nowTimetamp.c_str()); + sprintf(updateSql, "sendMsg = 0"); + int iRet2 = sql_ctl->UpdateTableData("t_data_waveSend", updateSql, whereCon); + + string strFileName_failed = strFileName + "_" + nowTimetamp; + char tmpCmd[128]={0x00}; + sprintf(tmpCmd,"cp %s %s",strFileName.c_str(),strFileName_failed.c_str()); + system(tmpCmd); + LOG_ERROR("cp dat file %s \n",tmpCmd); + + memset(tmpWhere,0x00,sizeof(tmpWhere)); + sprintf(tmpWhere," channelID = '%s' and sendMsg = 0 ",strChannelID.c_str()); + int count = sql_ctl->GetTableRows("t_data_waveSend", tmpWhere); + + memset(tmpCmd,0x00,sizeof(tmpCmd)); + sprintf(tmpCmd,"rm %s ",vecRet[1].c_str()); + system(tmpCmd); + LOG_ERROR("rm dat file %s \n",tmpCmd); + + } + + }else{ + LOG_DEBUG("send data , filename %s\n", strFileName.c_str()); + } +#ifdef G2UL_GATEWAY//存储6条波形数据 + char whereCon[1024] = {0x00}; + char updateSql[1024] = {0x00}; + char tmpWhere[128]={0x00}; + sprintf(tmpWhere,"channelID = '%s' and save = 1 ",strChannelID.c_str()); + int count = sql_ctl->GetTableRows("t_data_waveSend", tmpWhere); + LOG_INFO("save channlID %s dat count = %d\n",strChannelID.c_str(),count); + if(count <= 5) + { + sprintf(whereCon, "channelID='%s' and timeStamp = '%s' ", strChannelID.c_str(),nowTimetamp.c_str()); + sprintf(updateSql, "save = 1 "); + sql_ctl->UpdateTableData("t_data_waveSend", updateSql, whereCon); + string strFileName_save = strFileName + "_" + nowTimetamp + "_save"; + char tmpCmd[128]={0x00}; + sprintf(tmpCmd,"cp %s %s",strFileName.c_str(),strFileName_save.c_str()); + system(tmpCmd); + }else { + memset(tmpWhere,0x00,sizeof(tmpWhere)); + memset(updateSql,0x00,sizeof(updateSql)); + sprintf(tmpWhere, " save = 1 and channelID='%s' ORDER BY timeStamp ASC LIMIT 0,1",strChannelID.c_str()); + vec_t vecRet = sql_ctl->GetDataSingleLine("t_data_waveSend","*",tmpWhere); + memset(tmpWhere,0x00,sizeof(tmpWhere)); + sprintf(tmpWhere, " save = 1 and timeStamp = '%s' and channelID = '%s' ",vecRet[2].c_str(),vecRet[0].c_str()); + sprintf(updateSql, "save = 0 "); + int iRet = sql_ctl->UpdateTableData("t_data_waveSend", updateSql, tmpWhere); + memset(tmpWhere,0x00,sizeof(tmpWhere)); + memset(updateSql,0x00,sizeof(updateSql)); + sprintf(whereCon, "channelID='%s' and timeStamp = '%s' ", strChannelID.c_str(),nowTimetamp.c_str()); + sprintf(updateSql, "save = 1"); + int iRet2 = sql_ctl->UpdateTableData("t_data_waveSend", updateSql, whereCon); + + string strFileName_save = strFileName + "_" + nowTimetamp + "_save"; + char tmpCmd[128]={0x00}; + sprintf(tmpCmd,"cp %s %s",strFileName.c_str(),strFileName_save.c_str()); + system(tmpCmd); + + memset(tmpWhere,0x00,sizeof(tmpWhere)); + sprintf(tmpWhere," channelID = '%s' and save = 1 ",strChannelID.c_str()); + int count = sql_ctl->GetTableRows("t_data_waveSend", tmpWhere); + + memset(tmpCmd,0x00,sizeof(tmpCmd)); + sprintf(tmpCmd,"rm %s ",(vecRet[1]+"_save").c_str()); + system(tmpCmd); + LOG_INFO("rm dat file %s \n",tmpCmd); + } + +#endif + print_info("write data to filename %s\n", strFileName.c_str()); + std::vector().swap(vecData); + sleep(1); + } + std::vector().swap(m_VecWaveData); + char whereCon[1024] = {0x00}; + char updateSql[1024] = {0x00}; + sprintf(whereCon, "dataNodeNo='%s'", strLongAddr.c_str()); + sprintf(updateSql, "WaveTime = WaveTime + 1"); + sql_ctl->UpdateTableData(T_SENSOR_INFO(TNAME), updateSql, whereCon); + + //string strData = sql_ctl->GetNodeConfigureInfor(whereCon); + //data_publish(strData.c_str(), GlobalConfig::Topic_G.mPubConfig.c_str()); // memset(buf, 0, 8); // sprintf(buf, "%02x%02x", recvTemp.ShortAddr[0], recvTemp.ShortAddr[1]); // std::string strShortAddr = std::string(buf); +} +void Uart::DealNodeSendTime(unsigned char* shortaddr) +{ + + /*char updateSql[1024]={0x00},whereCon[1024]={0x00},insertSql[1024]={0x00}; + memset(whereCon,0x00,sizeof(whereCon)); + memset(insertSql,0x00,sizeof(insertSql)); + sprintf(whereCon,"dataNodeNo = '%s'",dataNodeInfo.ZigbeeLongAddr.c_str()); + int nodegroup = 0; + int staticStartTime = 0; + int nodeindex = 0; + int statictime = 0; + int nodewaveindex = 1; + if(0 == sql_ctl->GetTableRows(T_DATANODE_TIME(TNAME), whereCon)){ + + sprintf(whereCon,"staticcycle = '%d' and wavecycle = '%d' order by nodeindex desc LIMIT 0 , 1",dataNodeInfo.FeatureInterVal,dataNodeInfo.WaveInterVal); + vec_t vecResult = sql_ctl->GetDataSingleLine(T_DATANODE_TIME(TNAME),"*",whereCon); + if(vecResult.size() == 0){ + string strResult = sql_ctl->GetData(T_DATANODE_TIME(TNAME),"nodegroup"," nodegroup > 0 order by nodegroup desc LIMIT 0 , 1"); + if(atoi(strResult.c_str()) > 0){ + print_info("strResult = %s\n",strResult.c_str()); + nodegroup = atoi(strResult.c_str()) + 1; + }else{ + nodegroup = 1; + } + staticStartTime = 0; + }else{ + nodegroup = atoi(vecResult[4].c_str()); + nodewaveindex = atoi(vecResult[6].c_str()) + 1; + statictime = atoi(vecResult[7].c_str()) + atoi(vecResult[2].c_str()); + if(statictime > atoi(vecResult[3].c_str())){ + staticStartTime = ceil(atof(vecResult[2].c_str()) / 2 ); + statictime = staticStartTime; + nodewaveindex = 1; + }else{ + staticStartTime = atoi(vecResult[8].c_str()); + } + } + std::string strnodeinex = sql_ctl->GetData(T_DATANODE_TIME(TNAME), "nodeindex", "nodeindex > 0 order by nodeindex desc LIMIT 0 , 1"); + LOG_INFO("DealNodeSendTime strnodeinex = %s\n",strnodeinex.c_str()); + nodeindex = atoi(strnodeinex.c_str())+1; + sprintf(insertSql,"'%s','%s','%d','%d',%d,%d,%d,%d,%d",dataNodeInfo.ZigbeeLongAddr.c_str(),dataNodeInfo.ZigbeeShortAddr.c_str(),\ + dataNodeInfo.FeatureInterVal,dataNodeInfo.WaveInterVal,nodegroup,nodeindex,nodewaveindex,statictime,staticStartTime); + sql_ctl->InsertData(T_DATANODE_TIME(TNAME), insertSql); + LOG_INFO("DealNodeSendTime InsertData = %s\n",insertSql); + UpdateWirelessNodeTime(shortaddr,nodewaveindex,staticStartTime,nodeindex);//更新时间戳 + }else{ + sprintf(whereCon,"staticcycle = '%d' and wavecycle = '%d' order by nodeindex desc LIMIT 0 , 1", + dataNodeInfo.FeatureInterVal,dataNodeInfo.WaveInterVal); + + vec_t vecResult = sql_ctl->GetDataSingleLine(T_DATANODE_TIME(TNAME),"*",whereCon); + if(vecResult.size() == 0){ + string strResult = sql_ctl->GetData(T_DATANODE_TIME(TNAME),"nodegroup"," nodegroup > 0 order by nodeindex desc LIMIT 0 , 1"); + if(atoi(strResult.c_str()) > 0){ + nodegroup = atoi(strResult.c_str()) + 1; + }else{ + nodegroup = 1; + } + staticStartTime = 0; + statictime = 0; + memset(whereCon,0x00,sizeof(whereCon)); + sprintf(whereCon,"dataNodeNo = '%s'",dataNodeInfo.ZigbeeLongAddr.c_str()); + sprintf(updateSql," staticcycle = '%d',wavecycle = '%d',nodegroup = %d,nodewaveindex = %d,statictime = %d, staticstarttime = %d",dataNodeInfo.FeatureInterVal,dataNodeInfo.WaveInterVal,\ + nodegroup,nodewaveindex,statictime,staticStartTime); + sql_ctl->UpdateTableData(T_DATANODE_TIME(TNAME), updateSql, whereCon); + LOG_INFO("DealNodeSendTime updateSql = %s\n",updateSql); + LOG_DEBUG("DealNodeSendTime1"); + UpdateWirelessNodeTime(shortaddr,nodewaveindex,staticStartTime,nodeindex);//更新时间戳 + }else{ + print_info("=======Send Time======\n"); + LOG_DEBUG("DealNodeSendTime2"); + UpdateWirelessNodeTime(shortaddr,atoi(vecResult[6].c_str()),atoi(vecResult[8].c_str()),atoi(vecResult[5].c_str()));//更新时间戳 + } + } + memset(whereCon,0x00,sizeof(whereCon)); + sprintf(whereCon,"dataNodeNo = '%s' and staticcycle <> '%d' and wavecycle <> '%d'",dataNodeInfo.ZigbeeLongAddr.c_str(),\ + dataNodeInfo.FeatureInterVal,dataNodeInfo.WaveInterVal); + sql_ctl->DeleteTableData(T_DATANODE_TIME(TNAME),whereCon);*/ + + +} +bool Uart::CheckCrc(char* pCheckBuff,int No) +{ + unsigned char tmp = 0x00; + for(int i = 0 ; i < No;i++){ + tmp += (unsigned char)pCheckBuff[i]; +// printf("%02x ",pCheckBuff[i]); + } + + if((unsigned char)pCheckBuff[No] != (unsigned char)tmp) + return false; + return true; + } void Uart::modify_distaddr_info(unsigned short id, char * zigbee,unsigned char* distAddr) { - char command[6]; + char command[6] = {0x00}; + command[0] = 0xDE; + command[1] = 0xDF; + command[2] = 0xEF; + command[3] = 0xDC; + command[4] = ((char *)&id)[1]; + command[5] = ((char *)&id)[0]; + WriteToUart(command, 6); + + usleep(10000); + memset(command,0x00,sizeof(command)); command[0] = 0xDE; command[1] = 0xDF; command[2] = 0xEF; @@ -2142,6 +3810,71 @@ void Uart::modify_distaddr_info(unsigned short id, char * zigbee,unsigned char* command[5] = distAddr[1]; WriteToUart(command, 6); + +} +void Uart::getZigbeeSignal(unsigned char* distAddr) +{ + usleep(10000); + char command[6] = {0x00}; + command[0] = 0xDE; + command[1] = 0xDF; + command[2] = 0xEF; + command[3] = 0xDA; + command[4] = distAddr[0]; + command[5] = distAddr[1]; + WriteToUart(command, 6); +} +void Uart::modify_DistAddr(unsigned char* distAddr) +{ + char command[6] = {0x00}; + memset(command,0x00,sizeof(command)); + command[0] = 0xDE; + command[1] = 0xDF; + command[2] = 0xEF; + command[3] = 0xD2; + command[4] = distAddr[0]; + command[5] = distAddr[1]; + WriteToUart(command, 6); +} +void Uart::modify_LocalAddr(unsigned short id) +{ + char command[6] = {0x00}; + + + command[0] = 0xDE; + command[1] = 0xDF; + command[2] = 0xEF; + command[3] = 0xDC; + command[4] = ((char *)&id)[1]; + command[5] = ((char *)&id)[0]; + WriteToUart(command, 6); +// ReadFromUart(); + +} +void Uart::modify_Localchannel(unsigned char pad) +{ + char command[6] = {0x00}; + command[0] = 0xDE; + command[1] = 0xDF; + command[2] = 0xEF; + command[3] = 0xD1; + command[4] = pad & 0xff; + WriteToUart(command, 5); +// ReadFromUart(); + +} +void Uart::modify_LocalPanID(unsigned short padID) +{ + char command[6] = {0x00}; + command[0] = 0xDE; + command[1] = 0xDF; + command[2] = 0xEF; + command[3] = 0xDB; + command[4] = ((char *)&padID)[1]; + command[5] = ((char *)&padID)[0]; + WriteToUart(command, 6); +// ReadFromUart(); + } void Uart::modify_info(unsigned short id, char * zigbee) { @@ -2153,8 +3886,8 @@ void Uart::modify_info(unsigned short id, char * zigbee) command[1] = 0xbc; command[2] = 0xcd; command[3] = 0xd6; - command[4] = ((char *)&id)[1]; - command[5] = ((char *)&id)[0]; + command[4] = ((char *)&id)[0]; + command[5] = ((char *)&id)[1]; command[6] = 0; if (zigbee != NULL) { con = 71; @@ -2166,9 +3899,9 @@ void Uart::modify_info(unsigned short id, char * zigbee) { tmp += command[i]; } - command[i] = tmp; + command[i] = 0xaa; WriteToUart(command, i+1); - boost::this_thread::sleep(boost::posix_time::seconds(1)); + sleep(1); } void Uart::zigbee_reset(unsigned short pad, unsigned short type) @@ -2197,10 +3930,13 @@ void Uart::WriteChanl2Zigbee(unsigned char pad) unsigned short tmp; tmp = GlobalConfig::Zigbee_G.MyAddr; //swap((char *)&pad1); - swap((char *)&tmp); + //swap((char *)&tmp); GlobalConfig::Zigbee_G.Chan = pad1; modify_info(tmp, (char *)& GlobalConfig::Zigbee_G); - zigbee_reset(tmp, 1); + + gpio_set(GlobalConfig::GPIO_G.zigReset,0); + usleep(10000); + gpio_set(GlobalConfig::GPIO_G.zigReset,1); } void Uart::WritePanId2Zigbee(unsigned short pad) @@ -2208,24 +3944,79 @@ void Uart::WritePanId2Zigbee(unsigned short pad) print_info("WritePanId2Zigbee : %d\n", pad); unsigned short pad1 = pad,tmp; tmp = GlobalConfig::Zigbee_G.MyAddr; + print_info("MyAddr : %d\n", GlobalConfig::Zigbee_G.MyAddr); swap((char *)&pad1); - swap((char *)&tmp); + //swap((char *)&tmp); GlobalConfig::Zigbee_G.PanID = pad1; - modify_info(tmp, (char *)&GlobalConfig::Zigbee_G); - zigbee_reset(tmp, 1); -} + modify_info(tmp, (char *)&GlobalConfig::Zigbee_G); + gpio_set(GlobalConfig::GPIO_G.zigReset,0); + usleep(10000); + gpio_set(GlobalConfig::GPIO_G.zigReset,1); +} +void Uart::WriteSpeed2Zigbee() +{ + GlobalConfig::Zigbee_G.Serial_Rate = 0x07; + GlobalConfig::Zigbee_G.Serial_DataB = 0x08; + GlobalConfig::Zigbee_G.Serial_StopB = 0x01; + unsigned short tmp; + tmp = GlobalConfig::Zigbee_G.MyAddr; + modify_info(tmp, (char *)&GlobalConfig::Zigbee_G); + gpio_set(GlobalConfig::GPIO_G.zigReset,0); + usleep(10000); + gpio_set(GlobalConfig::GPIO_G.zigReset,1); +} +/*void Uart::WriteLocalAddr(unsigned short id) +{ + gpio_set(116,0); + usleep(10000); + gpio_set(116,1); + sleep(1); + char command[8]={0x00}; + command[0] = 0xab; + command[1] = 0xbc; + command[2] = 0xcd; + command[3] = 0xdc; + command[4] = ((char *)&id)[1]; + command[5] = ((char *)&id)[0]; + command[6] = 0x00; + command[7] = 0xaa; + WriteToUart(command, 8); + usleep(600000); + gpio_set(116,0); + usleep(10000); + gpio_set(116,1); +}*/ +void Uart::WriteTranTimeout2Zigbee(unsigned char Time) +{ + print_info("WriteTranTimeout2Zigbee : %d\n", Time); + + unsigned short tmp = GlobalConfig::Zigbee_G.MyAddr; + //print_info("MyAddr : %d\n", GlobalConfig::Zigbee_G.MyAddr); + GlobalConfig::Zigbee_G.PowerLevel = 0x03; + GlobalConfig::Zigbee_G.RetryNum = 0x64; + GlobalConfig::Zigbee_G.TranTimeout = Time; + modify_info(tmp, (char *)&GlobalConfig::Zigbee_G); + + gpio_set(GlobalConfig::GPIO_G.zigReset,0); + usleep(10000); + gpio_set(GlobalConfig::GPIO_G.zigReset,1); +} void Uart::WriteShortAddr2Zigbee(unsigned short pad) { print_info("WriteShortAddr2Zigbee : %4x\n", (unsigned short)pad); unsigned short pad1 = pad,tmp; tmp = GlobalConfig::Zigbee_G.MyAddr; - swap((char *)&pad1); - swap((char *)&tmp); + //swap((char *)&pad1); + //swap((char *)&tmp); GlobalConfig::Zigbee_G.MyAddr = pad1; modify_info(tmp, (char *)& GlobalConfig::Zigbee_G); - zigbee_reset(tmp, 1); + + gpio_set(GlobalConfig::GPIO_G.zigReset,0); + usleep(10000); + gpio_set(GlobalConfig::GPIO_G.zigReset,1); + sleep(1); } void Uart::WriteShortAddr_DistAddr2Zigbee(unsigned short pad,unsigned char* pDestShortAddr) @@ -2236,55 +4027,64 @@ void Uart::WriteShortAddr_DistAddr2Zigbee(unsigned short pad,unsigned char* pDes swap((char *)&pad1); swap((char *)&tmp); char tmpDest[8]={0x00}; - sprintf(tmpDest,"%02d%02d",pDestShortAddr[0],pDestShortAddr[1]); + sprintf(tmpDest,"%02x%02x",pDestShortAddr[0],pDestShortAddr[1]); memcpy(&GlobalConfig::Zigbee_G.DstAddr,pDestShortAddr,2); GlobalConfig::Zigbee_G.MyAddr = pad1; // GlobalConfig::Zigbee_G.DstAddr = (short)atoi((char*)tmpDest); - printf("DstAddr = %d\n",GlobalConfig::Zigbee_G.DstAddr); + print_info("DstAddr = %x\n",GlobalConfig::Zigbee_G.DstAddr); GlobalConfig::ZigbeeInfo_G.MyAddr = "9999"; modify_info(tmp, (char *)& GlobalConfig::Zigbee_G); - zigbee_reset(tmp, 1); + + gpio_set(GlobalConfig::GPIO_G.zigReset,0); + usleep(10000); + gpio_set(GlobalConfig::GPIO_G.zigReset,1); } void Uart::ZigbeeInit() { - std::string strPanId = GlobalConfig::MacAddr_G.substr(8); + std::string strPanId = sql_ctl->GetData("t_gateway_info","zigbeePanID",NULL); + + { + unsigned short shortAddr = 0x8888; + //GlobalConfig::Zigbee_G.MyAddr = shortAddr; + //WriteLocalAddr(shortAddr); + WriteShortAddr2Zigbee(shortAddr); + usleep(100000); + // 更新GlobalConfig::ZigbeeInfo_G.MyAddr,用于外部显示 + + } + + //std::string strPanId = GlobalConfig::MacAddr_G.substr(8); print_info("strPanId : %s\n", strPanId.c_str()); + print_info("MacAddr_G : %s\n", GlobalConfig::MacAddr_G.c_str()); // 新增管理ZigBee代码 std::string strchan = ReadStrByOpt(ZIGBEECONFIG, "Zigbee", "channel"); - unsigned char Chan = (unsigned char)strtol(strchan.c_str(), NULL, 10); - printf("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%the chan = %u\n",Chan); + + unsigned short Chan = (unsigned short)strtol(strchan.c_str(), NULL, 10); + print_info("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%the chan = %u\n",Chan); print_info("ZigbeeInfo_G.Channel=%d\n",GlobalConfig::ZigbeeInfo_G.Channel); if(Chan > 10 && Chan < 27) { - if (Chan != GlobalConfig::ZigbeeInfo_G.Channel) { - printf("the chanl is different\n"); - WriteChanl2Zigbee(Chan); - boost::this_thread::sleep(boost::posix_time::seconds(1)); - } + //if (Chan != GlobalConfig::ZigbeeInfo_G.Channel) + { + WriteChanl2Zigbee(Chan); + //modify_Localchannel(Chan); + usleep(100000); + } } - - if (0 != GlobalConfig::ZigbeeInfo_G.PanID.compare(strPanId.c_str())) { + print_info("PanID1 = %s,strPanId = %s\n",GlobalConfig::ZigbeeInfo_G.PanID.c_str(),strPanId.c_str()); + //if (0 != GlobalConfig::ZigbeeInfo_G.PanID.compare(strPanId.c_str())) + { long lShortAddr = strtol(strPanId.c_str(), NULL, 16); unsigned short panid = lShortAddr & 0xffff; - print_info("the panid is different\n"); - WritePanId2Zigbee(panid); - boost::this_thread::sleep(boost::posix_time::seconds(1)); - } + //modify_LocalPanID(panid); - if (0 != GlobalConfig::ZigbeeInfo_G.MyAddr.compare("8888")) { - unsigned short shortAddr = 0x8888; - print_info("the short addr is different\n"); - WriteShortAddr2Zigbee(shortAddr); - boost::this_thread::sleep(boost::posix_time::seconds(1)); - LOG_INFO("[ZigbeeInit---------] ZigBee PanID: %s ; Channel: %d ; MyAddr : %4x ",GlobalConfig::ZigbeeInfo_G.PanID.c_str(),GlobalConfig::ZigbeeInfo_G.Channel, - (unsigned short)GlobalConfig::Zigbee_G.MyAddr); - // 更新GlobalConfig::ZigbeeInfo_G.MyAddr,用于外部显示 - char tmp[16]; - sprintf(tmp,"%4x",(unsigned short)GlobalConfig::Zigbee_G.MyAddr); - std::string strTmp(tmp); - GlobalConfig::ZigbeeInfo_G.MyAddr = strTmp; + WritePanId2Zigbee(panid); + usleep(100000); } + + //if (0 != GlobalConfig::ZigbeeInfo_G.MyAddr.compare("8888")) + print_info("ZigbeeInfo_G.MyAddr=%s\n",GlobalConfig::ZigbeeInfo_G.MyAddr.c_str()); } diff --git a/uart/SH_Uart.hpp b/uart/SH_Uart.hpp index 1868e77..1c769ba 100644 --- a/uart/SH_Uart.hpp +++ b/uart/SH_Uart.hpp @@ -11,7 +11,7 @@ #include "../common/SH_CommonFunc.hpp" #include "../common/SH_global.h" #include "../dbaccess/SH_SqlDB.hpp" - +#include "../calculation/Calculation.hpp" @@ -20,25 +20,47 @@ //using boost::system::error_code; typedef unsigned int UINT; +typedef void (*pTestRecvCallBack)(int Status); class Uart : public MySingleton { private : - boost::posix_time::ptime mLocalTime; - boost::asio::io_service mIoSev; - boost::asio::serial_port mUart; - int mRdLength; - enum{BUF_LENGTH = 1107}; - char mUartRecvBuf[BUF_LENGTH]; - boost::mutex mLock; - boost::asio::io_service::strand mStrand; + boost::posix_time::ptime mLocalTime; + boost::asio::io_service mIoSev; + boost::asio::serial_port mUart; + int mRdLength; + int mlastSize; + int mPackgeIndex; + string strTimetamp; + + //DataNodeInfo dataNodeInfo; + std::string m_strDestShortAddr; + int waittime; + enum{BUF_LENGTH = 40960}; + unsigned char mUartRecvBuf[BUF_LENGTH]; + char mUartRecvTmpBuf[BUF_LENGTH*15]; + boost::mutex mLock; + boost::asio::io_service::strand mStrand; public : Uart(); - void InitUart(); ~Uart(); + void InitZigbee(); + void InitUart(speed_t speed); + void Close(); + void InitTestUart(speed_t speed); + void ReadTestUart(); + int fd,TestFd; + bool bUpdate; + bool bUpdatePre; + bool bUpdateconfig; + bool bTest; + bool bZigbeeSinal; + bool bModifyAddr; + bool bSendTimeStamp; + std::string DataNodeUpdateFile; void WriteToUart(const char *strSend,int pLen); - void ReadFromUart(); + int ReadFromUart(); void setCallBack(onReceiveUart _callback); void Run(); void Stop(); @@ -46,30 +68,48 @@ public : void UpdateZigbeeInfo(const char *pData); void DealRecvData(const char *pData); void DealDataNodeInfo(const char *pData); + void DealDataNodeName(const char *pData); void DealDataNodeFeature(const char *pData, int flag); void DealDataNodeWave(const char *pData); void DealWaveThread(); void DealWave(); + void DealNodeSendTime(unsigned char* shortaddr); void ZigbeeInit(); + int ZigbeeTest(); void modify_info(unsigned short id, char * zigbee); void modify_distaddr_info(unsigned short id, char * zigbee,unsigned char* distAddr); + void modify_LocalAddr(unsigned short id); + void modify_DistAddr(unsigned char* distAddr); + void modify_Localchannel(unsigned char pad); + void modify_LocalPanID(unsigned short padID); + void getZigbeeSignal(unsigned char* distAddr); void zigbee_reset(unsigned short pad, unsigned short type); void WriteChanl2Zigbee(unsigned char pad); void WritePanId2Zigbee(unsigned short pad); + void WriteSpeed2Zigbee(); + //void WriteLocalAddr(unsigned short id); + void WriteTranTimeout2Zigbee(unsigned char Time); void WriteShortAddr2Zigbee(unsigned short pad); void WriteShortAddr_DistAddr2Zigbee(unsigned short pad,unsigned char* pDestShortAddr); void UpdateWirelessNode(unsigned short shortAdd); + void UpdateWirelessNodeTime(unsigned char* pDestShortAddr,int modifyaddr/*,int nodewaveindex,int nodetime,int nodeindex*/); + int UpdateConfig(unsigned char* pDestShortAddr); bool ReadUpdatePackge(unsigned char* shortAddr); + bool CheckCrc(char* pCheckBuff,int No); + int FindRecvPackage(int bytesRead, char* mUartRecvBuf,char* head); virtual void DataAnalysis_R(DevDataOfGwid &pData); virtual void DataAnalysis_W(DevData &pData,bool pFlag); virtual void ThreadInit(); + int UartRecv(int fd, char srcshow,char* buffer); + void openSwitch(); private : - void ReadHandle(const boost::system::error_code &ec,size_t bytesRead); + void ReadHandle(char* pUartRecvBuf,size_t bytesRead); void WriteHandle(const char *strSend,const boost::system::error_code &ec,size_t bytesWrite); onReceiveUart m_callback; std::vector m_VecWaveData; unsigned long m_TimeStamp; + bool m_waveTrans; }; diff --git a/udpqt/SH_UdpQt.cpp b/udpqt/SH_UdpQt.cpp index e692297..9a61974 100644 --- a/udpqt/SH_UdpQt.cpp +++ b/udpqt/SH_UdpQt.cpp @@ -121,7 +121,7 @@ void UdpSys::AnalysisDataSys(std::string cmd) GlobalConfig::ServerPort = localServerPort; WriteStr2Config(SERVERCONFIG, "Server", "localServerIpAddress", GlobalConfig::ServerIP); - WriteStr2Config(SERVERCONFIG, "Server", "localServerPort", boost::lexical_cast(GlobalConfig::ServerPort)); + WriteStr2Config(SERVERCONFIG, "Server", "localServerPort", to_string(GlobalConfig::ServerPort)); std::string fileserver = ReadStrByOpt(SERVERCONFIG, "FileServer", "FileServerIpAddress"); if (0 == fileserver.compare("0.0.0.0") || 0 == fileserver.length()) { @@ -191,4 +191,4 @@ UdpSys::~UdpSys() { if (udpSock.is_open()) udpSock.close(); -} \ No newline at end of file +} diff --git a/wifi/wpa_client.cpp b/wifi/wpa_client.cpp new file mode 100644 index 0000000..51a43c3 --- /dev/null +++ b/wifi/wpa_client.cpp @@ -0,0 +1,555 @@ +#include "wpa_client.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +namespace wifi { + +size_t strlcpy (char *dst, const char *src, size_t dst_sz) +{ + size_t n; + + for (n = 0; n < dst_sz; n++) { + if ((*dst++ = *src++) == '\0') + break; + } + + if (n < dst_sz) + return n; + if (n > 0) + *(dst - 1) = '\0'; + return n + strlen (src); +} + +static std::string to_string(int val) { + char *buf = NULL; + int size; + int temp; + if (val < 0) + { + temp = -val; + size = 2; + } + else + { + temp = val; + size = 1; + } + for(; temp > 0; temp = temp / 10, size++); + size++; + + buf = (char *)malloc(size); + if (buf == NULL) + { + return ""; + } + memset(buf, 0, size); + sprintf(buf, "%d", val); + std::string re(buf); + free(buf); + return re; +} + + +MXDHCP::MXDHCP() +{ + pstream = NULL; +} + +MXDHCP::~MXDHCP() +{ + if(pstream!=NULL) + { + pclose(pstream); + pstream = NULL; + } +} + +bool MXDHCP::Start(const std::string & net_interface) +{ + if(pstream!=NULL) + { + pclose(pstream); + pstream = NULL; + } + std::string cmd = "udhcpc -b -i " + net_interface + " &"; + system("killall -9 udhcpc &"); + usleep(1000*100); + pstream = popen(cmd.data(),"r"); + if(pstream == NULL) + { + return false; + } + return true; +} + +/* +* dhcp 这个类的主要原理是通过读取udhcpc 的输出来判断是否拿到了ip地址,实际情况中可以使用别的方法 +*/ +bool MXDHCP::GetDHCPStatus() +{ + if(pstream == NULL) + { + return false; + } + int len = 1024; + char *buff = (char *)malloc(sizeof(char)*len); + if(buff==NULL) + { + return false; + } + int res = fread(buff,sizeof(char),len,pstream); + if(res<=0) + { + free(buff); + return false; + } + if(!CheckString(buff,res)) + { + free(buff); + return false; + } + pclose(pstream); + pstream = NULL; + free(buff); + return true; +} + +bool MXDHCP::CheckString(char *buf ,int len) +{ + if(strstr(buf,"adding dns")==NULL) + { + return false; + } + return true; +} + + +WPAClient::WPAClient(const std::string & wpa_control_path) +{ + wpa_context_ = NULL; + wpa_control_path_ = wpa_control_path; + SetConnStatus(STEP_SCAN); + Init(); +} + +WPAClient::~WPAClient() +{ + Close(wpa_context_); +} + +bool WPAClient::Init() +{ + wpa_context_ = Open(wpa_control_path_); + if (wpa_context_ == NULL) + { + print_error("open wpa failed\n"); + return false; + } + SetConnStatus(STEP_SCAN); + return true; +} + +std::string WPAClient::GetCurrentSSID() +{ + std::string cmd = "STATUS"; + std::string ssid_key = "\nssid="; + std::string recv; + std::string ssid = ""; + + if (!Request(wpa_context_, cmd, recv)) + { + return ""; + } + char temp[1024] = {0}; + strcpy(temp, recv.data()); + char *key = NULL; + key = strstr(temp, ssid_key.data()); + if (key == NULL) + { + return ""; + } + key += ssid_key.length(); + for(; (*key != '\0') && (*key != '\n') && (*key != '\r'); key++) + { + ssid += *key; + } + + return ssid; +} + +std::string WPAClient::GetNetSsid() +{ + std::string cmd = "SCAN"; + std::string recv; + if (!Request(wpa_context_, cmd, recv)) + { + return ""; + } + + recv.clear(); + cmd = "SCAN_RESULTS"; + + if (!Request(wpa_context_, cmd, recv)) + { + return ""; + } + return recv; +} +int WPAClient::GetWiFiRssi() +{ + std::string cmd = "SIGNAL_POLL"; + std::string rssi_key = "RSSI"; + std::string recv; + if (!Request(wpa_context_, cmd, recv)) + { + return 0; + } + char temp[1024] = {0}; + strcpy(temp, recv.data()); + print_info("recv = %s\n",recv.c_str()); + char *key = NULL; + key = strstr(temp, rssi_key.data()); + if (key == NULL) + { + return 0; + } + for(; (*key != '\0') && (*key != '\n') && (*key != '\r'); key++) + { + if ((*key >= '0') && (*key <= '9')) + { + return atoi(key); + } + } + return 0; +} + +bool WPAClient::ConnectWiFi(const std::string & ssid, const std::string & password) { + int net_id; + SetConnStatus(STEP_SCAN); + if (!CleanAllWiFi()) + { + return false; + } + print_info("CleanAllWiFi \n"); + if (!AddWiFi(net_id)) + { + return false; + } + print_info("AddWiFi \n"); + if (!SetSSID(ssid, net_id)) + { + return false; + } + print_info("SetSSID \n"); + if (!SetPassword(password, 0)) + { + return false; + } + if (!SetProtocol(net_id, 1)) + { + return false; + } + print_info("SetProtocol\n"); + SetScanSSID(net_id); + if (!EnableWiFi(net_id)) + { + return false; + } + print_info("EnableWiFi\n"); + return CheckCommandWithOk("SAVE_CONFIG"); + //return true; +} + +bool WPAClient::ConnectWiFiWithNoPassword(const std::string & ssid) +{ + int net_id; + SetConnStatus(STEP_SCAN); + if (!CleanAllWiFi()) + { + return false; + } + print_info("CleanAllWiFi\n"); + if (!AddWiFi(net_id)) + { + return false; + } + print_info("AddWiFi\n"); + if (!SetSSID(ssid, net_id)) + { + return false; + } + print_info("SetSSID\n"); + if (!SetProtocol(net_id, 0)) + { + return false; + } + print_info("SetProtocol\n"); + SetScanSSID(net_id); + if (!EnableWiFi(net_id)) + { + return false; + } + print_info("EnableWiFi\n"); + + return CheckCommandWithOk("SAVE_CONFIG"); +} + +bool WPAClient::ConnectWiFiWithLast() +{ + SetConnStatus(STEP_SCAN); + if (!CheckCommandWithOk("ENABLE_NETWORK all")) + { + return false; + } + return true; +} + +bool WPAClient::GetConnectStatus() { + std::string cmd = "STATUS"; + std::string recv; + int addr; + switch (step_) { + case STEP_SCAN: + if (!Request(wpa_context_, cmd, recv)) { + return false; + } + addr = recv.find("COMPLETED"); + if (addr == -1) { + return false; + } + SetConnStatus(STEP_CONNECT_AP_OK); + case STEP_CONNECT_AP_OK: + if (!dhcp_.Start("wlan0")) { + return false; + } + SetConnStatus(STEP_DHCP_IP); + case STEP_DHCP_IP: + if (!dhcp_.GetDHCPStatus()) { + return false; + } + SetConnStatus(STEP_SUCCESS); + case STEP_SUCCESS: + return true; + default: + return false; + } + return false; +} + +void WPAClient::SetConnStatus(ConnectStatus status) { + step_ = status; +} + +void WPAClient::wifiup() +{ + system("ifconfig mlan0 up"); + system("ifconfig mlan0 up"); + system("ifconfig mlan0 up"); +} + +bool WPAClient::CleanWifi() +{ + bool flag = CleanAllWiFi(); + CheckCommandWithOk("SAVE_CONFIG"); + return flag; +} + +int WPAClient::GetConnStatus() { + return step_; +} + +WPAContext * WPAClient::Open(const std::string & path) { + struct WPAContext *ctrl; + ctrl = (struct WPAContext*)malloc(sizeof(struct WPAContext)); + if (ctrl == NULL) { + print_error("malloc failed\n"); + return NULL; + } + memset(ctrl, 0, sizeof(struct WPAContext)); + static int counter = 0; + int ret; + int tries = 0; + size_t res; + ctrl->s = socket(PF_UNIX, SOCK_DGRAM, 0); + if (ctrl->s < 0) { + print_error("socket failed\n"); + free(ctrl); + return NULL; + } + ctrl->local.sun_family = AF_UNIX; + counter++; +try_again: + ret = snprintf(ctrl->local.sun_path, sizeof(ctrl->local.sun_path), + "/tmp" "/" + "wpa_ctrl_" "%d-%d", + (int)getpid(), counter); + if (ret < 0 || (size_t)ret >= sizeof(ctrl->local.sun_path)) { + print_error("snprintf failed\n"); + close(ctrl->s); + free(ctrl); + return NULL; + } + tries++; + if (bind(ctrl->s, (struct sockaddr *) &ctrl->local, + sizeof(ctrl->local)) < 0) { + if (errno == EADDRINUSE && tries < 2) { + /* + * getpid() returns unique identifier for this instance + * of wpa_ctrl, so the existing socket file must have + * been left by unclean termination of an earlier run. + * Remove the file and try again. + */ + unlink(ctrl->local.sun_path); + goto try_again; + } + print_error("bind failed\n"); + close(ctrl->s); + free(ctrl); + return NULL; + } + ctrl->dest.sun_family = AF_UNIX; + res = strlcpy(ctrl->dest.sun_path, wpa_control_path_.data(), + sizeof(ctrl->dest.sun_path)); + if (res >= sizeof(ctrl->dest.sun_path)) { + close(ctrl->s); + free(ctrl); + return NULL; + } + if (connect(ctrl->s, (struct sockaddr *) &ctrl->dest, + sizeof(ctrl->dest)) < 0) { + print_error("connect failed\n"); + close(ctrl->s); + unlink(ctrl->local.sun_path); + free(ctrl); + return NULL; + } + return ctrl; +} + +void WPAClient::Close(WPAContext * context) { + if (context == NULL) + return; + unlink(context->local.sun_path); + if (context->s >= 0) + close(context->s); + free(context); +} + +bool WPAClient::Request(WPAContext * context, const std::string & cmd, std::string& reply) { + int res; + fd_set rfds; + struct timeval tv; + const char *_cmd; + char *cmd_buf = NULL; + size_t _cmd_len; + _cmd = cmd.data(); + _cmd_len = cmd.length(); + if (wpa_context_ == NULL) { + print_error("wpa_context_ is null\n"); + return false; + } + if (send(wpa_context_->s, _cmd, _cmd_len, 0) < 0) { + free(cmd_buf); + return -1; + } + free(cmd_buf); + for (;;) { + tv.tv_sec = 10; + tv.tv_usec = 0; + FD_ZERO(&rfds); + FD_SET(wpa_context_->s, &rfds); + res = select(wpa_context_->s + 1, &rfds, NULL, NULL, &tv); + if (res < 0) + return false; + if (FD_ISSET(wpa_context_->s, &rfds)) { + char temp[1024] = {0}; + int temp_len = 1024; + res = recv(wpa_context_->s, temp, temp_len, 0); + if (res < 0) + return false; + if (res > 0 && temp[0] == '<') { + continue; + } + reply = temp; + break; + } else { + return false; + } + } + return true; +} + +bool WPAClient::CheckCommandWithOk(const std::string cmd) { + std::string recv; + if (!Request(wpa_context_, cmd, recv)) { + print_error("send cmd falied\n"); + return false; + } + print_error("recv cmd %s\n",recv.data()); + if (strstr(recv.data(), "OK") == NULL) { + return false; + } + return true; +} + +bool WPAClient::AddWiFi(int & id) { + std::string add_cmd = "ADD_NETWORK"; + std::string recv; + if (!Request(wpa_context_, add_cmd, recv)) { + return false; + } + id = atoi(recv.data()); + return true; +} + +bool WPAClient::SetScanSSID(int id) { + std::string cmd = "SET_NETWORK " + to_string(id) + " scan_ssid 1"; + return CheckCommandWithOk(cmd); +} +bool WPAClient::SetSSID(const std::string & ssid, int id) { + std::string cmd = "SET_NETWORK " + to_string(id) + " ssid " + "\"" + ssid + "\""; + return CheckCommandWithOk(cmd); +} +bool WPAClient::SetPassword(const std::string & password, int id) { + std::string cmd = "SET_NETWORK " + to_string(id) + " psk " + "\"" + password + "\""; + return CheckCommandWithOk(cmd); +} +bool WPAClient::SetProtocol(int id, int en_crypt) { + std::string cmd = "SET_NETWORK " + to_string(id); + if (en_crypt) { + cmd += " key_mgmt WPA-PSK"; + return CheckCommandWithOk(cmd); + } else { + cmd += " key_mgmt NONE"; + return CheckCommandWithOk(cmd); + } +} +bool WPAClient::CleanAllWiFi() { + CheckCommandWithOk("REMOVE_NETWORK all"); + CheckCommandWithOk("DISABLE_NETWORK all"); + return true; +} +bool WPAClient::EnableWiFi(int id) { + std::string cmd = "ENABLE_NETWORK " + to_string(id); + return CheckCommandWithOk(cmd); +} + +bool WPAClient::ReconnectWiFi() { + std::string cmd = "RECONNECT"; + return CheckCommandWithOk(cmd); +} +} diff --git a/wifi/wpa_client.h b/wifi/wpa_client.h new file mode 100644 index 0000000..c3d7d0e --- /dev/null +++ b/wifi/wpa_client.h @@ -0,0 +1,90 @@ +/* +# +# wifi连接接口 +# 说明:通过进程间通信与wpa_supplicant进行交互实现wifi连接 +# 注意:使用该接口的应用运行前要确保wpa_supplicant应用已经启动 +# 并且能明确进程间通信地址。 +# +*/ +#ifndef __WPA_CLIENT_H__ +#define __WPA_CLIENT_H__ +#include +#include +#include "../utility/SH_MySingleton.hpp" +#include "../common/SH_global.h" + +namespace wifi +{ +#ifdef G2UL_GATEWAY +const std::string WPA_PATH = "/var/run/wpa_supplicant/wlan0"; //进程间通信地址加上网络接口额名称 +#endif +#ifdef IMX6UL_GATEWAY +const std::string WPA_PATH = "/var/run/wpa_supplicant/wlan2"; //进程间通信地址加上网络接口额名称 +#endif +struct WPAContext +{ + int s; + struct sockaddr_un local; + struct sockaddr_un dest; +}; + +enum ConnectStatus +{ + STEP_SCAN = 0, + STEP_CONNECT_AP_OK, + STEP_DHCP_IP, + STEP_SUCCESS +}; +class MXDHCP +{ //dhcp ip地址的工具类,实现方法不算特别合理。可以根据具体情况进行更改 +public: + MXDHCP(); + ~MXDHCP(); + bool Start(const std::string& net_interface); + bool GetDHCPStatus(); +private: + bool CheckString(char *buf,int len); + FILE *pstream; +}; + +class WPAClient //: public MySingleton +{ +public: + WPAClient(const std::string& wpa_control_path = WPA_PATH); + ~WPAClient(); + bool GetInitStatus(){return wpa_context_!=NULL;} //获取wpa进程间通信是否建立连接 + int GetWiFiRssi(); //获取wifi信号强度,需要在连接成功之后调用 + std::string GetCurrentSSID(); //获取当前连接的wifi的名称 + bool ConnectWiFi(const std::string& ssid, const std::string& password); //连接加密wifi,传入wifi名称和密码 + bool ConnectWiFiWithNoPassword(const std::string& ssid); //连接无加密的wifi,传入wifi名称即可 + bool ConnectWiFiWithLast(); //直接连接上次已保存的wifi + bool GetConnectStatus(); //获取wifi连接状态 + std::string GetNetSsid(); + void wifiup(); //mlan0 up + bool CleanWifi(); + bool ReconnectWiFi(); //重新连接WIFI +protected: + bool Init(); + struct WPAContext* Open(const std::string& path); + void Close(struct WPAContext* context); + bool Request(struct WPAContext* context, const std::string& cmd,std::string& reply); + bool CheckCommandWithOk(const std::string cmd); + bool AddWiFi(int& id); + bool SetScanSSID(int id); + bool SetSSID(const std::string& ssid, int id); + bool SetPassword(const std::string& password, int id); + bool SetProtocol(int id, int en_crypt); + bool CleanAllWiFi(); + bool EnableWiFi(int id); + void SetConnStatus(ConnectStatus status); + int GetConnStatus(); +protected: + struct WPAContext* wpa_context_; + std::string wpa_control_path_; + MXDHCP dhcp_; +private: + int step_; +}; + +} +#endif // __WPA_CLIENT_H__