Hello!
I want to send data and counter from one node to other with priority!
I have two task but I don't know which part of code should be in this two task
to send
these data with priority! I know it should be a common event to call priorities
task! but which event?
I tried different code but no success!
please help me!!!!!
event void VHPriority.runTask() {
if (call
AMSend.send(AM_BROADCAST_ADDR,
&pkt,
sizeof(BlinkToRadioMsg)) == SUCCESS) {
dbg("BlinkToRadioC","Timer Fired-
%s\n",sim_time_string());
busy = TRUE;
}
}
event void VHPriority2.runTask() {
if (call AMSend.send(AM_BROADCAST_ADDR,
&pkt, sizeof(radio_sense_msg_t)) == SUCCESS) {
dbg("BlinkToRadioC","data packet sent, data is
%hu.\n",pdata);
locked = TRUE;
}
}
event void Boot.booted() {
call AMControl.start();
}
event void AMControl.startDone(error_t
err) {
if (err == SUCCESS) {
call
Timer0.startPeriodic(TIMER_PERIOD_MILLI);
dbg("BlinkToRadioC","Radio Start-
%s\n",sim_time_string());
}
else {
call AMControl.start();
dbg("BlinkToRadioC","NRadio Start-
%s\n",sim_time_string());
}
}
event void Timer0.fired() {
counter++;
if (!busy) {
BlinkToRadioMsg* btrpkt =
(BlinkToRadioMsg*)(call
Packet.getPayload(&pkt, sizeof(BlinkToRadioMsg)));
if (btrpkt == NULL) {
return;
}
btrpkt->nodeid =
TOS_NODE_ID;
btrpkt->counter = counter;
/* if (call
AMSend.send(AM_BROADCAST_ADDR,
&pkt, sizeof(BlinkToRadioMsg))
== SUCCESS) {
dbg("BlinkToRadioC","Timer Fired-
%s\n",sim_time_string());
busy = TRUE;
}*/
call VHPriority.postTask(20);
}
call Read.read();
}
event void AMSend.sendDone(message_t*
msg, error_t err) {
if (&pkt == msg) {
busy = FALSE;
dbg("BlinkToRadioC","Send %d Packet-
%s\n",counter,sim_time_string());
}
}
event void Read.readDone(error_t result,
uint16_t data) {
if (locked) {
return;
}
else {
radio_sense_msg_t* rsm;
rsm = (radio_sense_msg_t*)call
Packet.getPayload(&pkt, sizeof(radio_sense_msg_t));
if (rsm == NULL) {
return;
}
rsm->error = result;
rsm->data = data;
pdata=data;
/* if (call
AMSend.send(AM_BROADCAST_ADDR, &pkt, sizeof(radio_sense_msg_t)) == SUCCESS)
{
dbg("BlinkToRadioC","data packet sent, data is
%hu.\n",data);
locked = TRUE;
} */
call VHPriority2.postTask(30);
}
}_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help