Revision 344
changed protocol
hltp.c | ||
---|---|---|
18 | 18 |
} |
19 | 19 |
|
20 | 20 |
static host_info_t* hltp_interpret_host_info(const uint8_t *p, const size_t sz) { |
21 |
printf("%s\n", __func__); |
|
22 |
printf("sizeof(host_info_t)=%d, sz=%d\n", sizeof(host_info_t), sz); |
|
21 | 23 |
if (sz != sizeof(host_info_t)) { printf("%d should equal %d\n", sz, sizeof(host_info_t)); return NULL;} |
22 | 24 |
host_info_t *ret = (host_info_t*)malloc(sizeof(host_info_t)); |
23 | 25 |
//size_t pos = 0; |
... | ... | |
51 | 53 |
*/ |
52 | 54 |
return ret; |
53 | 55 |
} |
54 |
int hltp_send_host_info(const host_info_t *p) { |
|
56 |
int hltp_send_host_info(const host_info_t *p) { printf("%s, %d\n",__func__, rand());
|
|
55 | 57 |
|
58 |
printf(" sending angle: 0x%04X\n", p->host_angle); |
|
59 |
|
|
56 | 60 |
uint8_t type = hltp_type_host; |
57 | 61 |
const uint8_t* ptr[11]; size_t sz[11]; |
58 | 62 |
ptr[0] = (uint8_t*)& type ; sz[0] = 1; |
... | ... | |
113 | 117 |
return nctp_send(2, ptr, sz); |
114 | 118 |
} |
115 | 119 |
|
116 |
hltp_type hltp_interpret(const uint8_t *p, const size_t sz, void **dest){ |
|
120 |
hltp_type hltp_interpret(const uint8_t *p, const size_t sz, void **dest){ printf("%s %d\n",__func__, rand());
|
|
117 | 121 |
uint8_t ret = p[0]; |
122 |
printf(" ret=%d\n", ret); |
|
118 | 123 |
switch(ret){ |
119 | 124 |
case hltp_type_string: *dest = hltp_interpret_string (p+1, sz-1); break; |
120 | 125 |
case hltp_type_host : *dest = hltp_interpret_host_info (p+1, sz-1); break; |
Also available in: Unified diff