get a broadcast to android app on BLE connection - bluetooth-lowenergy

A question about registering BLE notification on android:
I am developing an app that once the android device detects our beacon/ble hardware, should write something to one of the writable characteristics of that hardware.
Trying to understand, on the android app side how can I register some intent to be called when a ble connection was made to the android framework.
since a broadcast receiver registered in manifest can no longer launch my app and android background services policy was changed, this can't be done. so..
I am trying to use JobScheduler which was designed to be launched based on criteria. this can launch a JobService to do the job.
When the app is in foreground or background this seems to be working.
The thing is, I need to be notified when the app is not running (Not even in background)

Related

ChromeOS / Chromebook exception when connecting to BLE devices (getCharacteristic)

In a small team we're developing an application that is deployed to both Android (Tablets) and ChromeOS devices. For this, we have a couple build targets such as Pixel C's, Galaxy Tabs, an Asus C302 Chromebook and a Pixelbook.
The App we're developing interfaces over BLE with a Windows 10 system that runs an application that accepts incoming BLE connections. What we perform in our App:
We perform a scan to find a device with a specific name
We connect to this device: using the Android Native BluetoothDevice class: mBluetoothDevice.connectGatt();
We request the services: using the Android Native BluetoothGatt class: mBluetoothGatt.discoverServices();
When our App is deployed to Android targets, it successfully connects to the W10 app and retrieves its services (onServicesDiscovered).
However, when the same builds of the App are ran on ChromeOS, the following exception is thrown for retrieving services:
08-17 10:46:52.750 3827-3846/com.(our namespace) D/TheApp: BleGattHandler | onServicesDiscovered() called with: gatt = [android.bluetooth.BluetoothGatt#baff2ee], status = [0]
08-17 10:46:52.751 3827-3846/com.(our namespace) W/BluetoothGatt: Unhandled exception in callback
java.lang.NullPointerException: Attempt to invoke virtual method 'android.bluetooth.BluetoothGattCharacteristic android.bluetooth.BluetoothGattService.getCharacteristic(java.util.UUID)' on a null object reference
at com.(our namespace).communication.bluetooth.lowenergy.BleGattHandler.onServicesDiscovered(BleGattHandler.java:90)
at android.bluetooth.BluetoothGatt$1.onSearchComplete(BluetoothGatt.java:237)
at android.bluetooth.IBluetoothGattCallback$Stub.onTransact(IBluetoothGattCallback.java:103)
at android.os.Binder.execTransact(Binder.java:565)
Our conclusion is that for some reason, ChromeOS fails to retrieve the services of a BLE device. We're at a loss here and hope to hear if anyone of you knows the cause or possible resolution (we're also open to professional help)
What ChromeOS version are we using
Our most recent test (today) was on the Pixelbook with:
ChromeOS 68.0.3440.87 (from beta channel)
ChromeOS 69.0.3497.21 (from dev channel)
What we have found up till now
This ChromeOS issue, yet it is reported Fixed:
https://bugs.chromium.org/p/chromium/issues/detail?id=722987
Android app which interacts with BLE devices not working on Chromebook
Why are we not using 'normal' Bluetooth (classic)?
We're currently using a C# W10 App to connect to using the App. However, this application serves as a Stub for now and will in the near future be replaced by a low-power embedded solution (wearable product) we are developing that requires operation over BLE. We're therefore bound to use BLE.

Keep SignalR connected in background in Android Oreo

I used a service in my android app that check SignalR connection state every 10 seconds and if was disconnected, try to init SignalR and make it connected.
But in Android 8 some limitation added (Read more), that kill background services and also we can't call startService method to start service from BroadcastReceiver that detect device boot completed.
What's your best solution to resolve this problem for all Android versions, that is better without any dependency?

Configure Gimbal iBeacon without iPhone?

Is there a way to configure the physical gimbal beacon without an iPhone?
In these instruction, it says you need to use the iPhone app. Is there another way with Android, PC, etc?
To apply custom configurations to a Gimbal Beacon or to change the Beacon Type from "Gimbal" to "iBeacon", you need the Gimbal Beacon Manager iOS App: https://itunes.apple.com/ca/app/gimbal-beacon-manager/id785688563
The configuration app is iOS only, there is no desktop or Android version of this configuration utility.
The steps to configure a beacon are:
-- register the beacon at Gimbal.com
-- create a configuration for your beacon(s)
-- set the beacon to use the specified configuration on gimbal.com
-- Launch the app on your iOS device, and go to the "Configure" section
-- reset the beacon by opening it and taking out the battery and closing it again
-- at this point the app will see the newly reset beacon (via Bluetooth), and ask if you want to update it. Press the "Update" button, and you're done.
So yes, you need an iOS device to configure the beacons.
As of today, Gimbal's beacons will work on both iOS and Android. You are certainly able to set everything up on your Gimbal Developer Account and configure the Gimbal SDK to work with your application and OS of choice. However, you won't be able to test these beacons without a device with BLE or Bluetooth Low Energy support.
This could be a tablet or a phone but most certainly will need a physical device to test things with. Also, keep in mind Gimbal's beacons are compatible with the iBeacon specification but aren't necessarily considered to be official iBeacons (strictly from a trademark/brand perspective). You must have a Gimbal Developer Account in order to use their beacons (whether running in iBeacon or Gimbal proprietary mode) and when going to production will want to consider the pricing per active user to use the service.
As noted before, what's nice about the Gimbal beacons is they are cross-platform. Some manufacturers will only allow their beacons to work on certain platforms or require the use of a proprietary SDK other than one which is open/public. Gimbal uses a proprietary SDK and requires the use of their backend service.
I hope I cleared things up for you. If you wish to know more about using the Gimbal Proximity SDK for Android or setting up the Gimbal Proximity SDK for Android Studio, please click on the respective links.
Update 10/11/2016
You are also able to configure a subset of items directly with the SDK inside your application but Gimbal is really pushing everything to be configured via your Gimbal Developer Account (a.k.a. Gimbal Admin Dashboard).
As far as configuring everything with a separate application from the one you are developing (e.g. a standalone application that allows you to configure your beacons which are associated with your Gimbal account), the only option I'm aware of is the Gimbal Manager for iOS.
Keep in mind this app basically accomplishes the same thing as if you were at your computer and logging into your Gimbal Developer Account. This could be convenient in situations where you are running around placing beacons and are not directly near a computer.
Granted, you could also accomplish the same thing on a mobile browser logging into your Gimbal Developer Account but a native app is likely to work better.
Thus, looking back at your question, the only standalone app for any platform to configure your beacons is the Gimbal Manager for iOS. With that being said, below is a simple list showing current options to configure your beacons.
Gimbal Developer Account
Gimbal Manager for iOS
Gimbal SDK from Within Your Application
Finally, if you need any assistance troubleshooting your beacon signals please see this article.
The Gimbal proximity feature is currently only available on iOS. The beacons are set up in such a way that they can only be seen from an iOS device with the Gimbal SDK (On any other platform, the Gimbal beacons signal appears with a different ID each time it is transmitted). Because of this, the only way to identify a Gimbal beacon is with an iOS device, and therefore the only way to change its configuration is with the Gimbal Beacon manager for iOS. Hopefully they will soon release an android sdk, and then you should be able to configure them from an android device as well.
I think you should have iphone or ipad to configure it. Since it use gimbal beacon manager app to reconfigure it after we configure in gimbal manager (via web).
you can also check this link : Gimbal beacon discovery

How do you listen for messages while the app is running in the background?

How do you listen for firebase messages while the ios app is running in the background?
How can I check for new messages while the ios app is running in the background?
The Firebase SDK uses iOS's underlying sockets, so the library will report new messages as long as the OS keeps the socket open. This can depend on the configuration of your app. If it is configured to be able to run in the background and use the network, then your observers will continue to function just like when the app runs in the foreground. If you app is not set up as able to run in the background, then the OS typically keeps the socket open for a short time before closing it. In that case, your app will need to enter the foreground again before it can start receiving new messages.

Is it possible to push data from the server to the client (phone, computer) without OS integration

is there a way for a server to push some data to a client, wirelessly and seamlessly, which may be Windows(Phone), iPhone, Mac, or Android device, without any OS integration?
If so, what's the best design pattern to do this, and what are the best technologies to go about this?
Push technology is simply a methodology of the server initiating the transfer of data, rather than the client asking the server for it.
Apple makes push technology relatively easy to use by providing such functionality built-in on the OS. As well as Android through the Google Cloud Messaging for Android. Windows, however, does not.
Apple push notifications and Google's messaging for Android is seemingly magical and/or functionality that the OS needs to handle; however, this isn't necessarily the case. The advantage of having it "integrated" in the OS, is the same as having a framework handle the functionality for you.
Speaking in technical terms, push technology is a long-lived connection from the client to the server that accepts messages. These messages would be considered pushed messages, since the client did not make an individual request for them.
The main thing to keep in mind when implementing push technology yourself, is that the client is in charge of keeping that long-lived connection alive as much as possible. Because client IP addresses can change between disconnects, servers are not guaranteed that a client's address will be persistent across disconnects. Moreover, clients can be connected from behind a firewall, making it impossible for a server to reach the client.
For comparison, pull technology is the more traditional process of a client connecting to a server and requesting data.
Your best bet for Apple iOS will be using their push notification service.
For Android devices you should use the Google Cloud Messaging for Android. Alternatively, you can create your own background service to handle the messaging; here's a guide.
For Windows (desktop at least), you will have to create your own service to perform such duty. Here's an MSDN guide explaining how to create a Windows Service using Visual Studio (VB and C#). There might be frameworks already built that handle such messaging on Windows, however, I don't know of any.
Use WebSocket (with or without socket.io).
In the future, you could use WebRTC.
With Websockets, the setup is really simple. The client (a user agent, like a browser or a WebView) connects to the Websocket server, over http(s) (less problems with firewalls) and that's it. There's a bidirectional socket with an event-based API.
If by "OS integration" you mean "write special code for each platform" then the answer is no.
As you mentioned, you would like file system access, and background processing. That combination is not available in a cross-platform way at this moment.
If by "OS integration" you meant "without having to wait for apple/google/ms to provide the ability" then the answer is yes/maybe.
All the popular platforms have Push notifications and background processing support, as long as you code it the way each particular platform expects it.
But file system access will be limited to what restrictions the platform places on you. For instance in ios and win8(phone) there is no wy to write or read a file outside of your own apps private file structure. For security reasons, you cannot access the file system of other apps.
UPDATE:
The general pattern here is to release an app for every platform you want to support.
The app will register itself with its respective platform's push notification service.
You will write generic server side code to accept the data you want to push to all your client devices. Then you will invoke the respective push API's for each platform you support, causing the client devices to wake up and trigger the app that you provided to respond.
When the app opens, you get the app to contact your server and download the full data "the push notification being just the wakeup call for your app"
This way you can easily tell how which of your devices have received the data.
Each platform specific app must save the data to its own local storage and provide a way for the data to be shared via the methods supported by its respective platform.
On IOS it can be as simple as supporting the "Open In.." paradigm.
On W8Phone, you'll have to publish the data via one of the available "sharing contracts"
And so forth for every platform you want to support.
This is the general pattern at the moment. There are some caveats. On IOS, the app will nt automatically start when a push notification is received. This means your app will only download the whole of the data when the app is opened by the user.
A mobile app also cannot generally run indefinitely in the background. This means that once the app is started, you have a limited window for push notifications to be automatically processed by your app. After the allowed "background time". The app will close and any push notifications beep on the device, but wont open the app until the user taps on one of the notifications or opens the app directly.
Technically you could use XMPP Libraries, it is meant for implementing chat system (msn, gtalk, facebook chat, etc...) but this could work well as a push message system because it is opensource and well built to handle all the cases you never thought of. Also you could host your own server and send push message that way...
Why not use a webservice? In my previous project I used webservice to deliver data from mysql database. The webservice I used was nusoap. On the client side I used kSoap library for Android. Hope this helps.
if you want to receive and send real time communication between a server and client (irrespective of the device or OS), i would highly recommend you use XMPP technology because it is designed for the sort of things you're asking for.
The Extensible Messaging and Presence Protocol (XMPP) is an application profile of the Extensible Markup Language [XML] that enables the near-real-time exchange of structured yet extensible data between any two or more network entities. The core features of XMPP defined in [XMPP‑CORE] provide the building blocks for many types of near-real-time applications, which can be layered on top of the core by sending application-specific data qualified by particular XML namespaces.
http://xmpp.org/rfcs/rfc6121.html#intro - that is the latest RFC which will give you a good starting point.

Resources