Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
HTAnticollision
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
马乐
HTAnticollision
Commits
928a7ec7
Commit
928a7ec7
authored
Mar 23, 2023
by
马乐
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.增加8103设备配置命令
parent
e8456fbb
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
105 additions
and
16 deletions
+105
-16
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+13
-6
Settings.kt
...rc/main/java/com/waytous/anticollision/config/Settings.kt
+55
-2
Session.kt
app/src/main/java/com/waytous/anticollision/tcp/Session.kt
+25
-5
SyncMessageListener.kt
...java/com/waytous/anticollision/tcp/SyncMessageListener.kt
+9
-2
SyncParser.kt
...src/main/java/com/waytous/anticollision/tcp/SyncParser.kt
+3
-1
No files found.
app/src/main/AndroidManifest.xml
View file @
928a7ec7
...
@@ -2,32 +2,39 @@
...
@@ -2,32 +2,39 @@
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
>
xmlns:tools=
"http://schemas.android.com/tools"
>
<uses-permission
android:name=
"android.permission.READ_PRIVILEGED_PHONE_STATE"
/>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<uses-permission
android:name=
"android.permission.READ_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.READ_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.WRITE_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.WRITE_EXTERNAL_STORAGE"
/>
<application
<application
android:name=
".MyApp"
android:name=
".MyApp"
android:allowBackup=
"true"
android:allowBackup=
"true"
android:dataExtractionRules=
"@xml/data_extraction_rules"
android:dataExtractionRules=
"@xml/data_extraction_rules"
android:fullBackupContent=
"@xml/backup_rules"
android:fullBackupContent=
"@xml/backup_rules"
android:icon=
"@mipmap/
ic_launcher
"
android:icon=
"@mipmap/
waytous_logo
"
android:label=
"@string/app_name"
android:label=
"@string/app_name"
android:roundIcon=
"@mipmap/ic_launcher_round"
android:supportsRtl=
"true"
android:supportsRtl=
"true"
android:usesCleartextTraffic=
"true"
android:theme=
"@style/Theme.HTAnticollision"
android:theme=
"@style/Theme.HTAnticollision"
android:usesCleartextTraffic=
"true"
tools:targetApi=
"31"
>
tools:targetApi=
"31"
>
<activity
<activity
android:name=
".
Main
Activity"
android:name=
".
Splash
Activity"
android:exported=
"true"
android:exported=
"true"
android:screenOrientation=
"landscape"
android:screenOrientation=
"landscape"
android:
label=
"@string/app_na
me"
>
android:
theme=
"@style/SplashThe
me"
>
<intent-filter>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
<action
android:name=
"android.intent.action.MAIN"
/>
<category
android:name=
"android.intent.category.LAUNCHER"
/>
<category
android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
</intent-filter>
</activity>
<activity
android:name=
".activity.MainActivity"
android:exported=
"true"
android:screenOrientation=
"landscape"
>
<intent-filter>
<category
android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
<meta-data
<meta-data
android:name=
"android.app.lib_name"
android:name=
"android.app.lib_name"
...
...
app/src/main/java/com/waytous/anticollision/config/Settings.kt
View file @
928a7ec7
...
@@ -35,8 +35,60 @@ object Settings {
...
@@ -35,8 +35,60 @@ object Settings {
var
token
:
String
by
PreferenceDelegate
(
"token"
,
""
)
var
token
:
String
by
PreferenceDelegate
(
"token"
,
""
)
/**
/**
*
心跳周期
*
DWORD 终端心跳发送间隔,单位为秒(s),默认2分钟
* */
* */
var
heartbeatInterval
:
Long
by
PreferenceDelegate
(
"heartbeatInterval"
,
2
)
var
x0001
:
Long
by
PreferenceDelegate
(
"x0001"
,
120
)
/**
* DWORD 消息应答超时时间,单位为秒(s)
* */
var
x0002
:
Long
by
PreferenceDelegate
(
"x0002"
,
60
)
/**
* DWORD TCP 消息重传次数
* */
var
x0003
:
Long
by
PreferenceDelegate
(
"x0003"
,
3
)
/**
* STRING 主服务器 APN,无线通信拨号访问点,若网络制式为 CDMA,则该处为 PPP 拨号号码
* */
var
x0010
:
String
by
PreferenceDelegate
(
"x0010"
,
""
)
/**
* STRING 主服务器无线通信拨号用户名
* */
var
x0011
:
String
by
PreferenceDelegate
(
"x0011"
,
""
)
/**
* STRING 主服务器无线通信拨号密码
* */
var
x0012
:
String
by
PreferenceDelegate
(
"x0012"
,
""
)
/**
* STRING 主服务器地址,IP 或域名(2019 版以冒号分割主机和端口,多个服务器使用分号分隔)
* */
var
x0013
:
String
by
PreferenceDelegate
(
"x0013"
,
""
)
/**
* STRING 备份服务器 APN,无线通信拨号访问点
* */
var
x0014
:
String
by
PreferenceDelegate
(
"x0014"
,
""
)
/**
* STRING 备份服务器无线通信拨号用户名
* */
var
x0015
:
String
by
PreferenceDelegate
(
"x0015"
,
""
)
/**
* STRING 备份服务器无线通信拨号密码
* */
var
x0016
:
String
by
PreferenceDelegate
(
"x0016"
,
""
)
/**
* STRING 备份服务器地址、IP 或域名(2019 版以冒号分割主机和端口,多个服务器使用分号分隔)
* */
var
x0017
:
String
by
PreferenceDelegate
(
"x0017"
,
""
)
/**
* DWORD 服务器 TCP 端口 // 2019 del
* */
var
x0018
:
Long
by
PreferenceDelegate
(
"x0018"
,
-
1
)
/**
* STRING 道路运输证 IC 卡认证主服务器 IP 地址或域名
* */
var
x001A
:
String
by
PreferenceDelegate
(
"x001A"
,
""
)
/**
* DWORD 道路运输证 IC 卡认证主服务器 TCP 端口
* */
var
x001B
:
Long
by
PreferenceDelegate
(
"x001B"
,
-
1
)
}
}
\ No newline at end of file
app/src/main/java/com/waytous/anticollision/tcp/Session.kt
View file @
928a7ec7
...
@@ -287,6 +287,7 @@ internal class Session : ConnectListener, SyncMessageListener<AbstractToStringJo
...
@@ -287,6 +287,7 @@ internal class Session : ConnectListener, SyncMessageListener<AbstractToStringJo
* 开始心跳
* 开始心跳
* */
* */
private
fun
startHeartbeat
()
{
private
fun
startHeartbeat
()
{
scheduleFutureTask
=
scheduler
.
scheduleAtFixedRate
(
scheduleFutureTask
=
scheduler
.
scheduleAtFixedRate
(
::
sendPing
,
::
sendPing
,
0
,
0
,
...
@@ -361,10 +362,10 @@ internal class Session : ConnectListener, SyncMessageListener<AbstractToStringJo
...
@@ -361,10 +362,10 @@ internal class Session : ConnectListener, SyncMessageListener<AbstractToStringJo
}
}
override
fun
onCommonResponse
(
payload
:
AbstractToStringJoiner
)
{
override
fun
onCommonResponse
(
payload
:
AbstractToStringJoiner
)
{
val
codec
=
(
payload
as
B8001
)
val
messageBody
=
(
payload
as
B8001
)
when
(
codec
.
replyId
)
{
when
(
messageBody
.
replyId
)
{
0
x0100
->
{
0
x0100
->
{
when
(
codec
.
result
)
{
when
(
messageBody
.
result
)
{
B8001
.
RESULT_SUCCESSFUL
->
{
B8001
.
RESULT_SUCCESSFUL
->
{
deviceStatus
.
set
(
DeviceStatus
.
Registered
)
deviceStatus
.
set
(
DeviceStatus
.
Registered
)
if
(
BuildConfig
.
DEBUG
)
{
if
(
BuildConfig
.
DEBUG
)
{
...
@@ -392,7 +393,7 @@ internal class Session : ConnectListener, SyncMessageListener<AbstractToStringJo
...
@@ -392,7 +393,7 @@ internal class Session : ConnectListener, SyncMessageListener<AbstractToStringJo
}
}
}
}
0
x0102
->
{
0
x0102
->
{
when
(
codec
.
result
)
{
when
(
messageBody
.
result
)
{
B8001
.
RESULT_SUCCESSFUL
->
{
B8001
.
RESULT_SUCCESSFUL
->
{
if
(
deviceStatus
.
get
()
==
DeviceStatus
.
Authenticating
)
{
if
(
deviceStatus
.
get
()
==
DeviceStatus
.
Authenticating
)
{
deviceStatus
.
set
(
DeviceStatus
.
Authenticated
)
deviceStatus
.
set
(
DeviceStatus
.
Authenticated
)
...
@@ -430,7 +431,7 @@ internal class Session : ConnectListener, SyncMessageListener<AbstractToStringJo
...
@@ -430,7 +431,7 @@ internal class Session : ConnectListener, SyncMessageListener<AbstractToStringJo
}
}
}
}
0
x0002
->
{
0
x0002
->
{
when
(
codec
.
result
)
{
when
(
messageBody
.
result
)
{
B8001
.
RESULT_SUCCESSFUL
->
{
B8001
.
RESULT_SUCCESSFUL
->
{
if
(
BuildConfig
.
DEBUG
)
{
if
(
BuildConfig
.
DEBUG
)
{
LogUtils
.
d
(
"心跳响应成功!"
)
LogUtils
.
d
(
"心跳响应成功!"
)
...
@@ -457,4 +458,22 @@ internal class Session : ConnectListener, SyncMessageListener<AbstractToStringJo
...
@@ -457,4 +458,22 @@ internal class Session : ConnectListener, SyncMessageListener<AbstractToStringJo
}
}
}
}
override
fun
onDeviceSetting
(
payload
:
AbstractToStringJoiner
)
{
val
messageBody
=
payload
as
B8103
Settings
.
x0001
=
messageBody
.
x0001
Settings
.
x0002
=
messageBody
.
x0002
Settings
.
x0003
=
messageBody
.
x0003
Settings
.
x0010
=
messageBody
.
x0010
Settings
.
x0011
=
messageBody
.
x0011
Settings
.
x0012
=
messageBody
.
x0012
Settings
.
x0013
=
messageBody
.
x0013
Settings
.
x0014
=
messageBody
.
x0014
Settings
.
x0015
=
messageBody
.
x0015
Settings
.
x0016
=
messageBody
.
x0016
Settings
.
x0017
=
messageBody
.
x0017
Settings
.
x0018
=
messageBody
.
x0018
Settings
.
x001A
=
messageBody
.
x001A
Settings
.
x001B
=
messageBody
.
x001B
}
}
}
\ No newline at end of file
app/src/main/java/com/waytous/anticollision/tcp/SyncMessageListener.kt
View file @
928a7ec7
...
@@ -7,13 +7,19 @@ interface SyncMessageListener<in T> {
...
@@ -7,13 +7,19 @@ interface SyncMessageListener<in T> {
/**
/**
* 设备注册
* 设备注册
* @param
data
* @param
payload
* */
* */
fun
onSignUp
(
payload
:
T
)
fun
onSignUp
(
payload
:
T
)
/**
/**
* 平台通用应答
* 平台通用应答
* @param
data
* @param
payload
* */
* */
fun
onCommonResponse
(
payload
:
T
)
fun
onCommonResponse
(
payload
:
T
)
/**
* 平台下发通知
* @param payload
* */
fun
onDeviceSetting
(
payload
:
T
)
}
}
\ No newline at end of file
app/src/main/java/com/waytous/anticollision/tcp/SyncParser.kt
View file @
928a7ec7
...
@@ -7,6 +7,7 @@ import io.github.toggery.jt808.codec.MessageMetadata
...
@@ -7,6 +7,7 @@ import io.github.toggery.jt808.codec.MessageMetadata
import
io.github.toggery.jt808.messagebody.AbstractToStringJoiner
import
io.github.toggery.jt808.messagebody.AbstractToStringJoiner
import
io.github.toggery.jt808.messagebody.B8001
import
io.github.toggery.jt808.messagebody.B8001
import
io.github.toggery.jt808.messagebody.B8100
import
io.github.toggery.jt808.messagebody.B8100
import
io.github.toggery.jt808.messagebody.B8103
import
io.netty.buffer.ByteBuf
import
io.netty.buffer.ByteBuf
import
io.netty.util.DefaultAttributeMap
import
io.netty.util.DefaultAttributeMap
import
io.netty.util.ReferenceCountUtil
import
io.netty.util.ReferenceCountUtil
...
@@ -31,8 +32,9 @@ class SyncParser(private val syncMessageListener: SyncMessageListener<AbstractTo
...
@@ -31,8 +32,9 @@ class SyncParser(private val syncMessageListener: SyncMessageListener<AbstractTo
LogUtils
.
file
(
"【解析】:$message"
)
LogUtils
.
file
(
"【解析】:$message"
)
}
}
when
(
val
payload
:
Any
=
message
.
body
){
when
(
val
payload
:
Any
=
message
.
body
){
is
B8100
->
syncMessageListener
.
onSignUp
(
payload
)
is
B8001
->
syncMessageListener
.
onCommonResponse
(
payload
)
is
B8001
->
syncMessageListener
.
onCommonResponse
(
payload
)
is
B8100
->
syncMessageListener
.
onSignUp
(
payload
)
is
B8103
->
syncMessageListener
.
onDeviceSetting
(
payload
)
}
}
}
catch
(
e
:
Exception
)
{
}
catch
(
e
:
Exception
)
{
if
(
BuildConfig
.
DEBUG
)
{
if
(
BuildConfig
.
DEBUG
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment