Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GPN_BadgeLasertag
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sebastian
GPN_BadgeLasertag
Commits
de1488bc
Commit
de1488bc
authored
7 years ago
by
HoelShare
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of
ssh://gitlab.warpzone.ms:444/HoelShare/GPN_BadgeLasertag
parents
b8280176
f328038d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
GPN_BadgeLasertag.ino
+32
-13
32 additions, 13 deletions
GPN_BadgeLasertag.ino
with
32 additions
and
13 deletions
GPN_BadgeLasertag.ino
+
32
−
13
View file @
de1488bc
...
...
@@ -81,19 +81,36 @@ void hostGame() {
#endif
}
bool
isNumber
(
char
number
){
return
number
>=
0x30
&&
number
<=
0x39
;
}
bool
isValidIp
(
String
ip
){
unsigned
short
pos0
=
ip
.
indexOf
(
'.'
);
unsigned
short
pos1
=
ip
.
indexOf
(
'.'
,
pos0
);
unsigned
short
pos2
=
ip
.
indexOf
(
'.'
,
pos1
);
unsigned
short
pos3
=
ip
.
indexOf
(
'.'
,
pos2
);
unsigned
short
pos1
=
ip
.
indexOf
(
'.'
,
pos0
+
1
);
unsigned
short
pos2
=
ip
.
indexOf
(
'.'
,
pos1
+
1
);
String
tuple0
=
ip
.
substring
(
0
,
pos0
);
String
tuple1
=
ip
.
substring
(
pos0
+
1
,
pos1
);
String
tuple2
=
ip
.
substring
(
pos1
+
1
,
pos2
);
String
tuple3
=
ip
.
substring
(
pos2
+
1
,
ip
.
length
()
-
1
);
String
part0
=
ip
.
substring
(
0
,
pos0
);
String
part1
=
ip
.
substring
(
pos0
,
pos1
);
String
part2
=
ip
.
substring
(
pos1
,
pos2
);
String
part3
=
ip
.
substring
(
pos2
,
ip
.
length
());
bool
isValid
=
true
;
Serial
.
printf
(
"Zerhackstuekelte IP: %s:%s:%s:%s"
,
part0
.
c_str
(),
part1
.
c_str
(),
part2
.
c_str
(),
part3
.
c_str
());
for
(
int
i
=
0
;
i
<
tuple0
.
length
();
i
++
){
Serial
.
printf
(
"tuple0: %d -> %c
\n
"
,
i
,
tuple0
[
i
]);
isValid
&=
isNumber
(
tuple0
[
i
]);
}
for
(
int
i
=
0
;
i
<
tuple1
.
length
();
i
++
){
Serial
.
printf
(
"tuple1: %d -> %c
\n
"
,
i
,
tuple1
[
i
]);
}
for
(
int
i
=
0
;
i
<
tuple2
.
length
();
i
++
){
Serial
.
printf
(
"tuple2: %d -> %c
\n
"
,
i
,
tuple2
[
i
]);
}
for
(
int
i
=
0
;
i
<
tuple3
.
length
();
i
++
){
Serial
.
printf
(
"tuple3: %d -> %c
\n
"
,
i
,
tuple3
[
i
]);
}
}
...
...
@@ -106,9 +123,9 @@ String recv_ir() {
bool
dataVerified
=
false
;
uint8_t
checksumRec
=
0
;
bool
done
=
false
;
//
bool done = false;
while
(
!
dataCompleted
&&
!
done
)
{
while
(
!
dataCompleted
)
{
int
on_time
=
0
;
decode_results
results
;
// Somewhere to store the results
if
(
irrecv
.
decode
(
&
results
))
{
...
...
@@ -116,18 +133,19 @@ String recv_ir() {
Serial
.
println
(
"IR code too long. Edit IRremoteInt.h and increase RAWBUF"
);
return
"a12
\n
7.0
\n
.0.
\n
1b"
;
}
char
*
buf
=
reinterpret_cast
<
char
*>
(
&
results
.
value
);
if
(
millis
()
-
on_time
>
500
)
{
pixels
.
setPixelColor
(
1
,
pixels
.
Color
(
0
,
0
,
0
));
pixels
.
show
();
}
uint8_t
checksum
=
'X'
;
if
(
stringCompleted
)
{
uint8_t
checksum
=
buf
[
1
];
dataCompleted
=
true
;
Serial
.
printf
(
"checksum?? %c;%c
\n
"
,
checksumRec
<<
8
|
222
,
checksum
);
if
(
checksum
==
checksumRec
)
{
dataVerified
=
true
;
pixels
.
setPixelColor
(
1
,
pixels
.
Color
(
0
,
100
,
0
));
...
...
@@ -142,7 +160,8 @@ String recv_ir() {
Serial
.
printf
(
"->:
\n\t
0: %c
\n\t
1: %c
\n\t
2: %c
\n\t
3: %c
\n
"
,
buf
[
0
],
buf
[
1
],
buf
[
2
],
buf
[
3
]);
if
(
buf
[
0
]
==
'\n'
||
buf
[
1
]
==
'\n'
||
buf
[
2
]
==
'\n'
||
buf
[
3
]
==
'\n'
)
{
stringCompleted
=
true
;
done
=
isValidIp
(
received
.
substring
(
1
,
received
.
length
()
-
2
));
Serial
.
printf
(
"string complete %s
\n
"
,
received
.
c_str
());
//done = true; //isValidIp(received.substring(1, received.length() - 2));
}
}
irrecv
.
resume
();
// Prepare for the next value
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment