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

bug fixes

parent e1e8ab40
...@@ -12,13 +12,16 @@ void gateway_protocol_packet_encode ( ...@@ -12,13 +12,16 @@ void gateway_protocol_packet_encode (
*packet_length = 0; *packet_length = 0;
packet[*packet_length] = dev_id; packet[*packet_length] = dev_id;
packet_length++; (*packet_length)++;
packet[*packet_length] = packet_type; packet[*packet_length] = packet_type;
(*packet_length)++; (*packet_length)++;
packet[*packet_length] = payload_length;
(*packet_length)++;
memcpy(&packet[*packet_length], payload, payload_length); memcpy(&packet[*packet_length], payload, payload_length);
*packet_length += payload_length; (*packet_length) += payload_length;
} }
uint8_t gateway_protocol_packet_decode ( uint8_t gateway_protocol_packet_decode (
...@@ -37,6 +40,7 @@ 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]; *packet_type = (gateway_protocol_packet_type_t) packet[p_len];
p_len++; p_len++;
p_len++;
*payload_length = packet_length - p_len; *payload_length = packet_length - p_len;
memcpy(payload, &packet[p_len], *payload_length); memcpy(payload, &packet[p_len], *payload_length);
......
...@@ -27,7 +27,7 @@ typedef enum { ...@@ -27,7 +27,7 @@ typedef enum {
} gateway_protocol_stat_t; } gateway_protocol_stat_t;
void gateway_protocol_packet_encode ( void gateway_protocol_packet_encode (
const uint8_t dev_id, const uint8_t dev_id,
const gateway_protocol_packet_type_t packet_type, const gateway_protocol_packet_type_t packet_type,
const uint8_t payload_length, const uint8_t payload_length,
const uint8_t *payload, const uint8_t *payload,
...@@ -35,7 +35,7 @@ void gateway_protocol_packet_encode ( ...@@ -35,7 +35,7 @@ void gateway_protocol_packet_encode (
uint8_t *packet); uint8_t *packet);
uint8_t gateway_protocol_packet_decode ( uint8_t gateway_protocol_packet_decode (
uint8_t *dev_id, uint8_t *dev_id,
gateway_protocol_packet_type_t *packet_type, gateway_protocol_packet_type_t *packet_type,
uint8_t *payload_length, uint8_t *payload_length,
uint8_t *payload, 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