0
私は以下の問題を抱えています。私のシミュレーション結果はwhileループに詰まっています。私の意見では、ループが終了する前にmote 1.0でrecv_ucを実行することができないからです。 はしかし、私はwhileループで立ち往生することを回避する必要があるContiki、whileループ、関数が実行されない
value = true;
を変更
unicast_send(&my_conn, &addr);
を呼び出しモテ1.0そのものです。 これはコードの最も重要な部分です。
static void my_func(struct unicast_conn *c, const rimeaddr_t *addr){
value = true;
...
}
static const struct unicast_callbacks my_call = {my_func};
//only mote 1 execute recv_uc
static void recv_uc(struct unicast_conn *c, const rimeaddr_t *from)
{
my_msg_t mess_rec;
rimeaddr_t addr;
addr.u8[0]= from->u8[0];
addr.u8[1]= from->u8[1];
memcpy(&mess_rec, packetbuf_dataptr(), sizeof(mess_rec));
...
packetbuf_copyfrom(&mess_rec, 16);
unicast_send(&my_conn, &addr);
}
static const struct unicast_callbacks unicast_call = {recv_uc};
PROCESS_THREAD(sending_rand, ev, data)
{
...
PROCESS_BEGIN();
unicast_open(&unicast, 120, &unicast_call); //importante
unicast_open(&my_conn, 130, &my_call); //importante
...
addr.u8[0] = 1;
addr.u8[1] = 0;
if(!rimeaddr_cmp(&addr, &rimeaddr_node_addr)){
...
while(value == false){
packetbuf_copyfrom(&mess, 16);
unicast_send(&unicast, &addr);
}
}
PROCESS_END();
}
ありがとうございます。