Phonegap GPS in offline mode - gps

I'm creating a quick very simple mobile app using phone gap.
One of the APIs I'm hooking into is the gps. For some reason, the gps is not working while the device has no wifi or cell connection. I'm testing on a nexus10 which should have a gps receiver.
Is there anyway to force the device to use the gps receiver or is a connection a requirement to the GPS API?

Try using:
navigator.geolocation.watchPosition(onSuccess, onError, { enableHighAccuracy: true });
"enableHighAccuracy" tells the Android device to use the GPS receiver rather than rely on Wifi or cell triangulation. An internet connection isn't required to use the GPS receiver.

Related

Communication is lost on wifi toggle and onDisconnect and onPeersDisconnected not being fired

I'm using code from Google's sample game "ButtonClicker2000" found here: https://github.com/playgameservices/android-basic-samples
I have 3 androids running this game in genymotion plus one on my own phone, debugging them all from android studio. I've gotten to a point where I'm trying to gracefully handle disconnect in the event of network issues. The way I'm simulating network issues is toggling the wifi on my phone. (on or off, same behavior) After that, real time messages from my phone are no longer being received by the virtual devices, and my phone is no longer receiving real time messages from the other devices. However, my phone never enters onDisconnect() and the other devices never enter onPeersDisconnected. If I exit the app on my phone after communication ceases, onPeerLeft fires on the other devices.
How can I either ensure communication between devices in a game isn't lost in the likely event that a user at some point comes in or out of range of their wifi? If that's not possible, how can I at least ensure the onDisconnect event is firing from the offending device and onPeersDisconnected event is firing on the others?
If we're going with what the documentation states, onDisconnect usually happens when there's a problem with the remote services (crash or resource problem). having the WiFi turned off doesn't look like it fits with those criteria. [onPeersDisconnected](https://developers.google.com/android/reference/com/google/android/gms/games/multiplayer/realtime/RoomStatusUpdateListener#onPeersDisconnected(com.google.android.gms.games.multiplayer.realtime.Room, java.util.List)) is called when the participants are disconnected from the room.
Determine if the onP2PConnected is called when its connected and onP2PDisconnected when disconnected (hopefully this can catch WiFi toggling cases) since I think its more appropriate when you're using real-time multiplayer.
You can also read more about it in the Real-time Multiplayer section of the documentaiton.
Hope this helps!

KMDF USB Device Stop, Remove or Disable

I develope KMDF with MS sample code. On an event call, I want to disable a specified device.
IRP_MJ_PNP come, and I can catch some MN irp. Here is some code to register the callback function.
WdfFdoInitSetFilter(DeviceInit);
WdfDeviceInitSetDeviceType(DeviceInit, FILE_DEVICE_BUS_EXTENDER);
status = WdfDeviceInitAssignWdmIrpPreprocessCallback(
DeviceInit,
WdfFltrWdmPnp,
IRP_MJ_PNP,
NULL,
0);
I can get the hardware id. In the past, in user mode application, I could remove the device driver with Setup~, cm_~ API. Can I use this API in the driver code? If not, how can I stop or remove the device driver? Or the device?

Send notification when bluetooth connection has been made like an iBeacon

Hi I am looking to see if I can send a notification when my iPhone connects to a bluetooth device with my app running in the background. This is similar to what happens with an iBeacon in iOS 7 I am just wondering if this can be done with any bluetooth device. I am ok with using private API's if necessary. If I understand bluetooth correctly, any bluetooth device has to at least communicate its identifier and wait and receive pairing codes so I am hoping i can be able to determine that if a bluetooth device broadcasts an identifier and my phone connects to it then send a notification like an iBeacon.
I have used an Estimote and it can broadcast the proximity and send notifications accordingly, I just want to be able to send a notification when a bluetooth connection has been made from any bluetooth device.
Thank you
On Apple's documentation you can find that you can act as a Bluetooth Central in the background. You should get callbacks if you are scanning for the correct UUID.
I haven't tested this but check that you have the correct UIBackgroundMode key in the info.plist file.
Also your CBCentralManagerDelegate should call the selector centralManager:didDiscoverPeripheral:advertisementData:RSSI: while your app is in the background.

Detect GPS in iOS device with CoreTelephony

I was looking for a way to detect whether an iOS device has a GPS unit or not, and I ran into this question. I found the last answer very interesting:
CTTelephonyNetworkInfo* netInfo = [[CTTelephonyNetworkInfo alloc] init];
if(netInfo) {
CTCarrier* carrier = [netInfo subscriberCellularProvider];
if([[carrier carrierName] length] <=0) {
//NO operator=>NO 3G and no real GPS
}
}
I was looking for some confirmation as the the validity of this technique/whether or not it is entirely accurate. I don't have enough devices to test it myself.
After doing some digging, I've found this article from Apple which, as a footnote, explains that:
iOS devices without a cellular connection use only Wi-Fi for Location Services (if a Wi-Fi network is available).
GPS is available [only] on iPhone and iPad Wi-Fi + 3G models.
So it seems that detecting a cellular connection is a reliable way to determine whether or not and iOS device has a GPS unit. No cellular connection, no GPS.
Note that iOS supports external GPS units through bluetooth and dock connector. The above methods will tell whether the device has a internal GPS but not whether LocationManager will be able to provide GPS driven location updates.

GameKit (GKSession) : Is there a priority order when GKSession decides to use Wifi or Bluetooth (if both are available)

If I have two iOS devices, both on same WiFi network and both with Bluetooth turned on, and I use GameKit (specifically GKSession) to manually setup a communications channel between them (without using GKPeerPickerController), I cant tell if it is using WiFi or Bluetooth.
Does iOS prioritise one over the other? I'm hoping that it uses Wifi before Bluetooth, but id like to be sure.
If WiFi is available and bluetooth isn't, it uses Wifi, if Bluetooth is available and Wifi isn't, it uses Bluetooth. Im wondering how they're talking if both bluetooth and WiFi are available, which does GameKit choose over the other?
The only way I can see to find this out is by running a packet sniffer on my WiFi and running several tests across different devices. Kinda hoping someone can save me that effort!
Thanks :-)
According to Apple's documentation if you use a GKPeerPickerController to create your GKSession you will be able to select bluetooth or wifi connectivity (see GKPeerPickerConnectionType).
I'm hoping that it uses Wifi before Bluetooth, but id like to be sure.
It seems an internet connections requires a bit of user code (but not bluetooth) so I would guess it defaults to bluetooth to avoid making this requirement mandatory.