fixed bulk read and updated unit listing to support unit types

master
Ondřej Hruška 6 years ago
parent 9eb4984b1f
commit e82d45eefb
  1. 13
      gex/gex_bulk.c
  2. 10
      gex/gex_client.c

@ -66,16 +66,15 @@ uint32_t GEX_BulkRead(GexUnit *unit, GexBulk *bulk)
return 0;
}
if (resp.type == MSG_BULK_END) {
// No more data
// fprintf(stderr, "Bulk read OK, closed.\n");
return at;
}
if (resp.type == MSG_BULK_DATA) {
if (resp.type == MSG_BULK_DATA || resp.type == MSG_BULK_END) {
// hexDump("Rx chunk", resp.payload, resp.len);
memcpy(bulk->buffer+at, resp.payload, resp.len);
at += resp.len;
// quit if we're done
if (resp.type == MSG_BULK_END) {
return at;
}
} else {
fprintf(stderr, "Bulk read failed! Bad response type.\n");
return 0;

@ -76,17 +76,19 @@ static TF_Result list_units_lst(TinyFrame *tf, TF_Msg *msg)
PayloadParser pp = pp_start((uint8_t*)msg->data, msg->len, NULL);
uint8_t count = pp_u8(&pp);
char buf[100];
char buf[20];
char buf2[20];
struct gex_unit *tail = NULL;
for(int i = 0; i < count; i++) {
uint8_t callsign = pp_u8(&pp);
pp_string(&pp, buf, 100);
fprintf(stderr, "- Found unit \"%s\" @ callsign %d\n", buf, callsign);
pp_string(&pp, buf, 20);
pp_string(&pp, buf2, 20);
fprintf(stderr, "- Found unit \"%s\" (type %s) @ callsign %d\n", buf, buf2, callsign);
// append
struct gex_unit *lu = malloc(sizeof(struct gex_unit));
lu->next = NULL;
lu->type = strdup("UNKNOWN"); // TODO
lu->type = strdup(buf2);
lu->name = strdup(buf);
lu->callsign = callsign;
lu->gex = gex;

Loading…
Cancel
Save