how to get Rssi value in tossim smulator - tinyos

I am using TinyOS 2.1.0 under Xubuntos in my project. I want to get the
RSSI values in my simulation using TOSSIM as simulator. I used the command
call CC2420Packet.getRssi(msg)
The component is successfully buit. But when I built it for the simulation
(make micaz sim), i get an error saying that the component CC2420PacketC not
found.e
i used also :
event message_t* Receive.receive(message_t* pck,unit_8 len){
unit_8 Rssi_value=pck->metadata[1];
dbg(DBG_USR2, "Receive signal strength as %d\n"
(int)Rssi_value);
but i get allways 0 value for Rssi

From what I learned from the forums(https://www.millennium.berkeley.edu/pipermail/tinyos-help/2007-July/026348.html) TOSSIM always sends at 0dbm and doesn't give dynamic change in the signal strength. Remember simulators have the limitations and Tossim assumes everything runs smoothly. But if you are interested in estimating quality you should consider some other parameter such as gain which can be programmed using the TOSSIM.

Related

Sim800L lag/delay before incoming calls are visible to arduino

I use SIM800L GSM module to detect incoming calls and generally it works fine. The only problem is that sometimes it takes up to 8 RINGS before the GSM module tells arduino that someone is calling (before RING appears on the serial connection). It looks like a GSM Network congestion but I do not have such issues with normal calls (I mean calls between people). It happens to often - so it cannot be network/Provider overload. Does anybody else had such a problem?
ISP/Provider: Plus GSM in Poland
I don't put any code, because the problem is in different layer I think
sorry that I didn't answer earlier. I've tested it and it turned out that in bare minimum code it worked OK! I mean, I can see 'RING' on the serial monitor immediately after dialing the number. So it's not a hardware issue!
//bare minimum code:
void loop() {
if(serialSIM800.available()){
Serial.write(serialSIM800.read());
}
if(Serial.available()){
serialSIM800.write(Serial.read());
}
}
In my real code I need to compare calling number with the trusted list. To do that I saved all trusted numbers in the contact list on the sim card (with the common prefix name 'mytrusted'). So, in the main loop there's if statement:
while(mySerial.available()){
incomingByte = mySerial.read();
inputString += incomingByte;
}
if (inputString.indexOf("mytrusted") > 0){
isTrusted = 1;
Serial.println("A TRUSTED NUMBER IS CALLING");
}
After adding this "if condition" Arduino sometimes recognize trusted number after 1'st call, and sometimes after 4'th or 5'th. I'm not suspecting the if statement itself , but the preceding while loop, where incoming bytes are combined into one string.
Any ideas, what can be improved in this simply code?
It seems, I found workaround for my problem. I just send a simple 'AT' command every 20 seconds to SIM800L (it replies with 'OK' ). I use timer to count this 20 seconds interval (instead of simply delay function)
TimerObject *timer2 = new TimerObject(20000); //AT command interval
....
timer2->setOnTimer(&SendATCMD);
....
void SendATCMD () {
mySerial.println("AT");
timer2->Stop();
timer2->Start();
}
With this simple modification Arduino always sees incoming call immediately (after 1 ring)

Using Winsock (TCP/IP) functions in ATEASY development enviroment

I am using WsReceive() function of the ATEasy framework and wanted to ask what is the meaning of the values "aioDefault
and aioDisableWsReceiveEarlyReturn" of "enMode" parameter?
I found this in the ATEASY documentation:
If enMode, input receive mode includes aioDisableWsReceiveEarlyReturn,
it prevents WsReceive from an "early return" when there is a momentary
interruption in the data being received.
And this from the online help of ateasy (By a tip of an expert from the ateasy forum) :
If sEos parameter is an empty string and aioDisableWsReceiveEarlyReturn mode flag is not used (default case), the function will return immediately if characters are found in the input buffer, and the timeout will be ignored. Using the aioDisableWsReceiveEarlyReturn flag will ensure that the function will return only if the timeout is reached or all lBytes characters were received.

Cortex-M3 NVIC_EnableIRQ(Systick_IRQn) causes hard fault exception

I'm using a Cortex-M3 LPC1548 from NXP with uVision IDE.
In the main() function, if I use:
SysTick_Config(SystemCoreClock * SYSTICK_INT_FREQ);
NVIC_EnableIRQ(SysTick_IRQn); // <--- HardFault happens in this line.
I got a HardFault exception everytime.
However, if I remove the NVIC_EnableIRQ(...) like this:
SysTick_Config(SystemCoreClock * SYSTICK_INT_FREQ);
code runs fine.
Does anyone knows why enabling Systick interrupt causes a HardFault?
I've done this before in a Cortex-M0 and never had problems.
Systick_IRQn is a negative value, you cannot use NVIC_EnableIRQ() with Systick. The out-of-bounds register access probably causes your hardfault.
The systick interrupt is enabled as soon as the corresponding bit in Systick->CTRL is set.
However, NVIC_SetPriority() supports Systick_IRQn among others like PendSV_IRQn.
What needs to be very clear here is that NVIC_EnableIRQ() can only be used to enable/disable exceptions numbers with values greater than 16.
Exceptions with numbers greater than 16 are called interrupt inputs while below 16 are system exceptions.
That means that the system exceptions listed below (example for Cortex-M3) cannot be used with NVIC_EnableIRQn():
1 Reset
2.NMU
3.HardFault
4.MemManage Fault
5.Bus Fault
6.Usage Fault
7-10. Reserved
11 SVC
12 Debug Monitor
13 Reserved
14 PendSV
15 Systick
So, the Systick Interrupt should never be activated using NVIC_EnableIRQ because it's an system exception. If one is using the CMSIS function SysTick_Config() no interrupt activation is needed since this function takes care of activating the Systick interrupt.
P.S. Information was taken from the excelent book from Joseph Yiu, The Definitive Guide to ARM Cortex-M3 and Cortex-M4 Processors and by analysing the function NVIC_EnableIRQ().

TinyOS interrupts handlling

Please give me an advice for this:
I want to get the time when a signal is sent from a mote(I was thinking to generate a interruption when the SFD pin gets from 1 to 0) I didn't find a solution for that, but I found this component:
Component: tos.chips.cc2420_tkn154.CC2420TransmitP
which provides cc2420Tx which seems to give me the time a need. But I can't manage to use it, as by default it usest the component from cc2420 folder and not the one from cc2420_tkn154 folder.
The main ideea is that I'd like to measure the time from sending the signal to recieving ack. I need Microsecond precision. All these would help me to get the distance between two motes.
Any ideea would be helpfull. I searched all over: forums, tinyos documentantion, examples...
Thank you :)
I do not know how low-level you want to get, but if you have a timer, in nesC you can get the local time every time the timer fires:
uint32_t timestamp;
event void myTimer.fired() {
timestamp = call myTimer.getNow();
printf("Timestamp: %ld \n", timestamp);
}
If you do not have a timer, you can use the component LocalTimeMilliC.
Add this to your configuration file:
components LocalTimeMilliC;
TestC.LocalTime -> LocalTimeMilliC;
...and in the module section of the implementation:
uses interface LocalTime<TMilli>;
...and in the code:
timestamp = call LocalTime.get();
However, the local time of each mote will start again when you reset the mote. You would have to synchronize the different times. If you want to calculate the distance between motes, this may not be the best way. To cite from the abstract of this paper:
Location of the deployed sensor nodes can be found either by TOA, TDOA or Received Signal Strength (RSS) measurements.
For RSSI, there is a demo in the folder tinyos-2.1.1/apps/tutorials.

Qt: Mobility GeoLocation works on Simulator but not on N900

I use the following code to get GeoLocation for my app
QGeoPositionInfoSource *source = QGeoPositionInfoSource::createDefaultSource(this);
if (source) {
source->setUpdateInterval(1000); // time in milliseconds
source->setPreferredPositioningMethods(QGeoPositionInfoSource::AllPositioningMethods);
connect(source, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(positionUpdated(QGeoPositionInfo)));
source->startUpdates();
source->requestUpdate(30000);
const QGeoPositionInfo &info =source->lastKnownPosition();
ui->label->setText(QString("Latitude - %1 Longitude - %2").arg(info.coordinate().latitude()).arg(info.coordinate().longitude()));
}
This code runs perfectly on the Simulator and gives me the coordinates provided by the simulator however this does not work when i try to run it on my N900. It returns Nan instead of the latitude and longitude coordinate. The current GPS signal on the phone is coarse accuracy. Also geolocation is working in the OVI Maps app on the phone. Any idea why the above code is unable to get the geolocation on the phone but works perfectly on the simulator ?
You should be setting the label from the slot for positionUpdated() as the signal is fired when an update has been received. Your call to requestUpdate() also triggers the positionUpdated() signal. If it does not get an update after your timeout setting, it will signal requestTimeout() which you might want to connect a slot to for informational purposes. It is likely that when you retrieve lastKnownPosition(), no position has been determined yet and the value returned is a null value. It's difficult to be sure just from the documentation but I think it implies that requestUpdate() will always return immediately, not after it has successfully received an update so you should call source->lastKnownPosition.isValid() to see if it contains a good position.
You should really be checking the position in the positionUpdated() slot or after that slot has been called at least once. It's likely the simulator has a postion available immediately and works in that case.
Does your positionUpdated() slot ever get called?

Resources