Commit 132ea374 authored by vladislav's avatar vladislav
Browse files

bug fixes

parent e1e8ab40
......@@ -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);
......
......@@ -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,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment