Hi.
We are having a lot of trouble getting the LQI. We are working in a blip
network with telosb motes. We are trying to obtain it with this event:
event void Status.recvfrom(struct sockaddr_in6 *from, void *data, uint16_t
len, struct ip_metadata *meta)
We try to extract the LQI from the struct ip_metadata which is like this:
struct ip_metadata {
ieee154_saddr_t sender;
uint8_t lqi;
uint8_t padding[1];
};
We have another mote sending UDP packets to this mote with the command:
call Status.sendto(&route_dest, &payload, STATUS_SIZE);
The route_dest is defined in the makefile:
CFLAGS += -DREPORT_DEST=\"fec0::2\"
We can send to the base station without any problem (adress fec0::21).
Our problem is that the Status.recvfrom event seems to never occurs because
the LQI is always 0 (the initial value). We print it with the UDP Shell. Do
we have to open any port to send and receive messages between motes? And if
it is the case, how do we do this?
Our modified UDPEcho is below so you can see if we made mistakes:
#include <IPDispatch.h>
#include <lib6lowpan.h>
#include <ip.h>
#include <lib6lowpan.h>
#include <ip.h>
#include "UDPReport.h"
#include "PrintfUART.h"
#include "RssiDemoMessages.h"
#include "message.h"
#define REPORT_PERIOD 75L
module UDPEchoP {
uses {
interface Boot;
interface SplitControl as RadioControl;
interface UDP as Echo;
interface UDP as Status;
interface Leds;
interface Timer<TMilli> as StatusTimer;
interface Statistics<ip_statistics_t> as IPStats;
interface Statistics<udp_statistics_t> as UDPStats;
interface Statistics<route_statistics_t> as RouteStats;
interface Statistics<icmp_statistics_t> as ICMPStats;
interface Random;
// --- Shell Command Interface ----------------
interface ShellCommand as ShellLQI;
// ----------------------------------------------------------
}
} implementation {
bool timerStarted;
nx_struct udp_report stats;
struct sockaddr_in6 route_dest;
event void Boot.booted() {
call RadioControl.start();
timerStarted = FALSE;
call IPStats.clear();
call RouteStats.clear();
call ICMPStats.clear();
printfUART_init();
#ifdef REPORT_DEST
route_dest.sin6_port = hton16(7000);
inet_pton6(REPORT_DEST, &route_dest.sin6_addr);
call StatusTimer.startOneShot(call Random.rand16() % (1024 *
REPORT_PERIOD));
#endif
dbg("Boot", "booted: %i\n", TOS_NODE_ID);
call Echo.bind(7);
call Status.bind(7001);
}
event void RadioControl.startDone(error_t e) {
}
// --- UDP Shell -------------------------------------------------------
uint16_t datalqi = 0;
uint16_t test1=0;
uint16_t test2=0;
event char *ShellLQI.eval(int argc, char **argv) {
char *ret = call ShellLQI.getBuffer(15);
snprintf(ret, 50, "%i\n%i\n%i\n", datalqi, test1, test2);
return ret;
}
//
----------------------------------------------------------------------------
event void RadioControl.stopDone(error_t e) {
}
event void Status.recvfrom(struct sockaddr_in6 *from, void *data,
uint16_t len, struct ip_metadata *meta) {
// --- Get the LQI from the ip_metadata structure -----------------
test=12; // Test variable to check if the event occurs
datalqi=meta->lqi;
//
------------------------------------------------------------------------------------
}
event void Echo.recvfrom(struct sockaddr_in6 *from, void *data,
uint16_t len, struct ip_metadata *meta) {
// --- Trying to get it from here too -------------------------------
test=22; // Test variable to check if the event occurs
datalqi=meta->lqi;
//
-----------------------------------------------------------------------------
call Echo.sendto(from, data, len);
}
event void StatusTimer.fired() {
if (!timerStarted) {
call StatusTimer.startPeriodic(1024 * REPORT_PERIOD);
timerStarted = TRUE;
}
stats.seqno++;
stats.sender = TOS_NODE_ID;
call IPStats.get(&stats.ip);
call UDPStats.get(&stats.udp);
call ICMPStats.get(&stats.icmp);
call RouteStats.get(&stats.route);
call Status.sendto(&route_dest, &stats, sizeof(stats));
}
}
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help