Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Vladislav Rykov
gateway_protocol
Commits
132ea374
Commit
132ea374
authored
Mar 31, 2020
by
vladislav
Browse files
bug fixes
parent
e1e8ab40
Changes
2
Hide whitespace changes
Inline
Side-by-side
gateway_protocol/gateway_protocol.c
View file @
132ea374
...
...
@@ -12,13 +12,16 @@ void gateway_protocol_packet_encode (
*
packet_length
=
0
;
packet
[
*
packet_length
]
=
dev_id
;
packet_length
++
;
(
*
packet_length
)
++
;
packet
[
*
packet_length
]
=
packet_type
;
(
*
packet_length
)
++
;
packet
[
*
packet_length
]
=
payload_length
;
(
*
packet_length
)
++
;
memcpy
(
&
packet
[
*
packet_length
],
payload
,
payload_length
);
*
packet_length
+=
payload_length
;
(
*
packet_length
)
+=
payload_length
;
}
uint8_t
gateway_protocol_packet_decode
(
...
...
@@ -37,6 +40,7 @@ uint8_t gateway_protocol_packet_decode (
*
packet_type
=
(
gateway_protocol_packet_type_t
)
packet
[
p_len
];
p_len
++
;
p_len
++
;
*
payload_length
=
packet_length
-
p_len
;
memcpy
(
payload
,
&
packet
[
p_len
],
*
payload_length
);
...
...
gateway_protocol/gateway_protocol.h
View file @
132ea374
...
...
@@ -27,7 +27,7 @@ typedef enum {
}
gateway_protocol_stat_t
;
void
gateway_protocol_packet_encode
(
const
uint8_t
dev_id
,
const
uint8_t
dev_id
,
const
gateway_protocol_packet_type_t
packet_type
,
const
uint8_t
payload_length
,
const
uint8_t
*
payload
,
...
...
@@ -35,7 +35,7 @@ void gateway_protocol_packet_encode (
uint8_t
*
packet
);
uint8_t
gateway_protocol_packet_decode
(
uint8_t
*
dev_id
,
uint8_t
*
dev_id
,
gateway_protocol_packet_type_t
*
packet_type
,
uint8_t
*
payload_length
,
uint8_t
*
payload
,
...
...
Write
Preview
Supports
Markdown
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