Commit 2ed270e5 authored by Sven Robertz's avatar Sven Robertz
Browse files

read channel ID to reply on the same channel

parent 18916fef
......@@ -40,8 +40,8 @@ static int encode(int argc, char *argv[]) {
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);
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);
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);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment