Skip to content
Snippets Groups Projects
Commit 2ed270e5 authored by Sven Robertz's avatar Sven Robertz
Browse files

read channel ID to reply on the same channel

parent 18916fef
No related branches found
No related tags found
No related merge requests found
......@@ -40,8 +40,8 @@ static int encode(int argc, char *argv[]) {
else
{
p_thr_chn = thr_open_chn(dest_mac, chn_id, frag_size, freq,NULL);
p_thr_chn2 = thr_open_chn(dest_mac, 17, frag_size, 100,(thr_msg_handler_t)labcomm_decoder_decode_one);
encoder = labcomm_encoder_new(labcomm_thr_writer, p_thr_chn);
p_thr_chn2 = thr_open_chn(dest_mac, chn_id, frag_size, freq,(thr_msg_handler_t)labcomm_decoder_decode_one);
encoder = labcomm_encoder_new(labcomm_thr_writer, p_thr_chn2);
labcomm_encoder_register_simple_TwoInts(encoder);
labcomm_encoder_register_simple_IntString(encoder);
decoder = labcomm_decoder_new(labcomm_thr_reader, p_thr_chn2);
......@@ -79,9 +79,10 @@ static int encode(int argc, char *argv[]) {
static void handle_simple_TwoInts(simple_TwoInts *v,void *context) {
unsigned char *src = get_sender_addr((struct thr_chn_t *)context);
unsigned char ch_id = get_channel((struct thr_chn_t *)context);
printf("Got TwoInts. a=%d, b=%d\n", v->a, v->b);
printf("... src addr: %x:%x:%x:%x:%x:%x\n", src[0], src[1], src[2], src[3], src[4], src[5]);
struct thr_chan_t *ch = thr_open_chn(src, 17, (unsigned short)50, (unsigned short)100, NULL);
struct thr_chan_t *ch = thr_open_chn(src, ch_id, (unsigned short)50, (unsigned short)100, NULL);
struct labcomm_encoder *enc = labcomm_encoder_new(labcomm_thr_writer, ch);
labcomm_encoder_register_simple_TwoInts(enc);
v->a *= 2;
......
......@@ -404,3 +404,7 @@ int thr_read(struct thr_chn_t* thr_chn, unsigned char* data, int length)
unsigned char* get_sender_addr(struct thr_chn_t* ch) {
return ch->last_sender_adr;
}
unsigned char get_channel(struct thr_chn_t* ch) {
return ch->id;
}
......@@ -16,4 +16,5 @@ int thr_send(const struct thr_chn_t* thr_chn, const char* data, unsigned int len
int thr_read(struct thr_chn_t* thr_chn, unsigned char* data, int length);
unsigned char* get_sender_addr(struct thr_chn_t* ch);
unsigned char get_channel(struct thr_chn_t* ch);
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment