Qt: Mobility GeoLocation works on Simulator but not on N900 - qt

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?

Related

Firebase Stream function not working correctly

I am working with ESP8266 and Firebase-Arduino library. I am trying to use the stream function but I am facing a problem with Firebase.available().
I know that Firebase.available() returns a true value whenever a change occurs on the real time database. But in my case it returns a true value every 30 seconds irrespective of the change has taken place or not.
Is this normal?
If not then how to fix it?
I am using the example code provided for FirebaseStream.

iphone: didUpdateLocations not invoked when testing with the simulator

When debugging my app with the simulator, the routine didUpdateLocations is never involved. What I do:
In the simulator, I select Debug>location>Custom Location and the window with longitude and latitude pops up. When pressing ok, I would expect the didUpdateLocations to be called.
I use locMgr as a global variable in a ViewController-module:
locMgr = CLLocationManager()
and in the viewDidLoad-function includes the following sequence:
locMgr.delegate = self
if CLLocationManager.authorizationStatus() == .NotDetermined {
locMgr.requestWhenInUseAuthorization()
}
I have coded the didUpdateLocations-function as a method of my viewcontroller class. I also verified (debugger), that the requestWhenInUseAuthorization-routine is invoked during initialisation. So were is the problem, why is the didUpdateLocations protocol-routine not invoked?
dasdom solved the problem by suggesting: Why requestWhenInUseAuthorization doesn't prompt the user for access to the location?

how to get Rssi value in tossim smulator

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.

Altbeacon library not working on Android 5.0

Yesterday I got the update for Android 5.0 on my Nexus 4, and the altbeacon library stopped detecting beacons. It appears that didEnterRegion and didRangeBeaconsInRegion are not even getting called when monitoring and ranging, respectively.
Even the Locate app from Radius Networks behaves differently now, the values from beacons, once they are detected, doesn't get updated anymore and often it appears as if the beacons went out of range.
One thing I noted differently, is that now in the logcat it appears the following line "BluetoothLeScanner﹕ could not find callback wrapper". I went ahead and looked for that class and saw that it was introduced with Android L, but I don't know if that has something to do with it.
It's important to say that before the update I had been working with both the Locate app and the Reference Application without any trouble.
I don't know if this is a generalized problem or not, but if it happened to me I'm sure it could happen to someone else, so any help it would really be appreciated.
Thanks in advance!
UPDATE:
After failing at getting the library to work I decided to try the Android L branch of the library. What I did was that I plugged in the new library into the Reference App, but didn't work as expected either.
The Monitor Activity seems to be working ok by notifying when the device has entered a new region. However, the Ranging Activity doesn't report any beacons, although didRangeBeaconsInRegion is getting called, always report zero beacons. Curiously, when the activity is paused (switching momentarily to another app) the logcat shows that now didRangeBeaconsInRegion does get called with actual beacons.
I'm kind of stuck right now because I don't know how to get any of libraries working on Android L, so again, any help would really be appreciated.
I'm using the latest Altbeacon build on 5.0+ and have no problem with it. in fact, I never used it on kitkat so i'm not really sure i can help but here is my working code which listen to iBeacons.
implement beaconConsumer:
public class MainActivity implements BeaconConsumer
init BeaconManager
beaconManager = BeaconManager.getInstanceForApplication(this);
if (beaconManager != null && !beaconManager.isBound(this)) {
beaconManager.getBeaconParsers().add(new BeaconParser().
setBeaconLayout("m:0-3=4c000215,i:4-19,i:20-21,i:22-23,p:24-24"));
beaconManager.bind(this);
}
onConnect and start listner
#Override
public void onBeaconServiceConnect() {
beaconManager.setRangeNotifier(new RangeNotifier() {
#Override
public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
if (beacons.size() > 0) {
Beacon firstBeacon = beacons.iterator().next();
}
}
});
beaconManager.startRangingBeaconsInRegion(new Region("com.example.app", null, null, null));
}
this code is working on 3 devices
Nexus 4 5.0.1
Samsung Galaxy s4 - Stock 5.0.1
Samsung Galaxy s4 - CM12 5.1.1
Old question, but maybe some people will try to find answer for higher systems where you have to ask for permissions. You need to ask for Manifest.permission.ACCESS_FINE_LOCATION before scanning. At least that was the problem I met. In my opinion lib should crash such cases at least and indicate the problem

When listening for keypress in Flash Lite should I be listening for Key.Down or the numeric code for this key?

The adobe documentation says that when listening for a keypress event from a phone you should listen for Key.Down, however when I trace the Key.getCode() of keypresses I see a number not the string "Key.Down". I am tesing this locally in device central and do not have a phone to test this with at present. Here is my code -
keyListener = new Object();
keyListener.onKeyDown = function() {
switch (Key.getCode()) {
trace(Key.getCode()) // outputs 40
case (Key.DOWN) : // according to the docs
pressDown();
break;
}
}
My question is - is this simply because Im testing in device central and when I run it on the phone I will need to be listening for Key.Down? or is the documentation wrong? Also is the numeric code (40) consistent across all devices? What gives adobe?
thanks all
Key.Down is equal to 40 so it will recognize it as the same. So you can use whichever one you prefer, however, I would recommend using Key.Down because it will be easily recognizeable for those who dont have Key Codes memorized (most of us).
These are the Key Code Values for Javascript. However, I think they are pretty much universal

Resources