2016-02-14 07:11:26 +00:00
|
|
|
#include <stdio.h>
|
2016-02-14 06:20:17 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
|
#include "airspy_adsb.h"
|
|
|
|
|
|
|
|
|
|
bool airspy_adsb_parse(struct buf *buf, struct packet *packet) {
|
2016-02-14 20:35:43 +00:00
|
|
|
if (buf->length < 35 ||
|
|
|
|
|
buf_chr(buf, 0) != '*') {
|
2016-02-14 06:20:17 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
2016-02-14 20:35:43 +00:00
|
|
|
if (buf->length >= 35 &&
|
|
|
|
|
buf_chr(buf, 34) == '\n' &&
|
|
|
|
|
buf_chr(buf, 15) == ';') {
|
|
|
|
|
packet->type = MODE_S_SHORT;
|
2016-02-14 07:11:26 +00:00
|
|
|
buf_consume(buf, 35);
|
|
|
|
|
return true;
|
2016-02-14 06:20:17 +00:00
|
|
|
}
|
2016-02-14 20:35:43 +00:00
|
|
|
if (buf->length >= 49 &&
|
|
|
|
|
buf_chr(buf, 48) == '\n' &&
|
|
|
|
|
buf_chr(buf, 29) == ';') {
|
|
|
|
|
packet->type = MODE_S_LONG;
|
2016-02-14 07:11:26 +00:00
|
|
|
buf_consume(buf, 49);
|
|
|
|
|
return true;
|
2016-02-14 06:20:17 +00:00
|
|
|
}
|
2016-02-14 07:11:26 +00:00
|
|
|
return false;
|
2016-02-14 06:20:17 +00:00
|
|
|
}
|