Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
A
ademco_hb
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
captainwong
ademco_hb
Commits
7bc325ec
Commit
7bc325ec
authored
Mar 22, 2022
by
captainwong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix 2
parent
5dbcdb7f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
7 deletions
+30
-7
SimpleServer.java
examples/javademo/jni/SimpleServer.java
+30
-7
No files found.
examples/javademo/jni/SimpleServer.java
View file @
7bc325ec
...
@@ -20,6 +20,21 @@ public class SimpleServer {
...
@@ -20,6 +20,21 @@ public class SimpleServer {
return
s
;
return
s
;
}
}
public
static
String
printable_bytes
(
char
[]
b
){
String
HEX_STRING
=
"0123456789ABCDEF"
;
String
s
=
""
;
for
(
int
i
=
0
;
i
<
b
.
length
;
i
++){
char
c
=
b
[
i
];
if
(
32
<=
c
&&
c
<=
127
){
s
+=
(
char
)
c
;
}
else
{
s
+=
"\\x"
+
HEX_STRING
.
charAt
(
b
[
i
]
>>>
4
);
s
+=
HEX_STRING
.
charAt
(
b
[
i
]
&
0x0F
);
}
}
return
s
;
}
public
static
String
printable_bytes
(
String
b
){
public
static
String
printable_bytes
(
String
b
){
String
HEX_STRING
=
"0123456789ABCDEF"
;
String
HEX_STRING
=
"0123456789ABCDEF"
;
String
s
=
""
;
String
s
=
""
;
...
@@ -62,6 +77,19 @@ public class SimpleServer {
...
@@ -62,6 +77,19 @@ public class SimpleServer {
// test pack2
// test pack2
{
{
System
.
out
.
println
(
"testing pack2..."
);
System
.
out
.
println
(
"testing pack2..."
);
System
.
out
.
println
(
"using seq=1234, acct=861234567890, ademco_id=666666, event=3400, zone=0, gg=0, xdata=123456"
);
String
data
=
lib
.
pack2
(
1234
,
"861234567890"
,
666666
,
3400
,
0
,
0
,
"123456"
);
try
{
byte
[]
bytes
=
data
.
getBytes
(
data
);
System
.
out
.
println
(
"data="
+
printable_bytes
(
bytes
));
}
catch
(
UnsupportedEncodingException
e
){
System
.
out
.
println
(
"data="
+
printable_bytes
(
data
));
}
}
// test pack3
{
System
.
out
.
println
(
"testing pack3..."
);
System
.
out
.
println
(
"using seq=1234, acct=861234567890, ademco_id=666666, event=3400, zone=0, gg=0, xdata=EB BA 3F A1 76"
);
System
.
out
.
println
(
"using seq=1234, acct=861234567890, ademco_id=666666, event=3400, zone=0, gg=0, xdata=EB BA 3F A1 76"
);
// byte[] xdata = new byte[5];
// byte[] xdata = new byte[5];
// xdata[0] = '\u00EB';
// xdata[0] = '\u00EB';
...
@@ -80,13 +108,8 @@ public class SimpleServer {
...
@@ -80,13 +108,8 @@ public class SimpleServer {
xdata
[
2
]
=
0x3F
;
xdata
[
2
]
=
0x3F
;
xdata
[
3
]
=
0xA1
;
xdata
[
3
]
=
0xA1
;
xdata
[
4
]
=
0x76
;
xdata
[
4
]
=
0x76
;
String
data
=
lib
.
pack2
(
1234
,
"861234567890"
,
666666
,
3400
,
0
,
0
,
xdata
,
5
);
char
[]
data
=
lib
.
pack3
(
1234
,
"861234567890"
,
666666
,
3400
,
0
,
0
,
xdata
,
5
);
try
{
System
.
out
.
println
(
"data="
+
printable_bytes
(
data
));
byte
[]
bytes
=
data
.
getBytes
(
data
);
System
.
out
.
println
(
"data="
+
printable_bytes
(
bytes
));
}
catch
(
UnsupportedEncodingException
e
){
System
.
out
.
println
(
"data="
+
printable_bytes
(
data
));
}
}
}
// test pack ack
// test pack ack
...
...
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