1
0
mirror of https://github.com/rene-dev/stmbl.git synced 2024-12-30 04:24:29 +00:00
stmbl/shared/common_f1.c

25 lines
605 B
C
Raw Permalink Normal View History

2017-10-30 02:26:47 +00:00
#include "common_f1.h"
2017-11-01 22:56:47 +00:00
void buff_packet(packet_header_t *p, uint8_t size) {
uint8_t nonkey_count = 0;
uint8_t *buf = ((uint8_t *)p) + sizeof(packet_header_t);
for(int i = size - 1; i >= 0; i--) {
if(buf[i] == p->start) {
buf[i] = nonkey_count;
nonkey_count = 0;
} else {
nonkey_count++;
}
}
p->key = nonkey_count;
2017-10-30 02:26:47 +00:00
}
2017-11-01 22:56:47 +00:00
void unbuff_packet(packet_header_t *p, uint8_t size) {
uint8_t temp;
uint8_t *buf = ((uint8_t *)p) + sizeof(packet_header_t);
for(int j = p->key; j < size;) {
temp = buf[j];
buf[j] = p->start;
j += temp + 1;
}
2017-10-30 02:26:47 +00:00
}