subscribe notification characteristics linux/ios - ios

I am trying to write a simple Gatt peripheral on linux device. I am currently able to see my service thanks to btgatt-client binary. I can read/write characteristics, enable notification, etc... I am using API from src/shared/gatt-db.h from bluez5, inspiration comes from tools/btgatt-server.c
However I am not able to make it work with my ios application without success. The subscription to notification failed. This ios application is able to work with a CC2541 bluetooth device so this is not an issue in ios side.
To enable the notification subscription I put some changes on the property value in the creation of the characteristics function like this :
gatt_db_service_add_characteristic(service, &uuid,
BT_ATT_PERM_READ | BT_ATT_PERM_WRITE,
BT_GATT_CHRC_PROP_READ | BT_GATT_CHRC_PROP_NOTIFY
signal_live_read_cb,
signal_live_write_cb,
server);
Do I forget to call some specific code to make it work correctly ?

Related

PunchThrough LightBlue how do you make a virtual device send a notification?

I'm developing an Android app that is a BLE central. I don't yet have access to the peripheral device. This would be a typical scenario for a virtual device simulator like LightBlue. I can scan and connect client-peri and I can enable notifications by writing the CCCD. If I use LightBlue's Time profile I can get Current Time characteristic notifications once per second. What I need to do is to add a custom characteristic and make that send notifications either at a specified interval or preferrably when pressing a button. How do I do that?
I'm also all ears for other methods or apps that can help me. I can't program my own peripheral app because I only have an iPhone and I don't have access to a development environment for iOS at the moment.
Hoping for insights!
thanks!

Sending notifications to Bluetooth devices (such as Fitbit)

The device in question (Fitbit Surge) currently has no public BLE API exposed, so there is no documented way of interacting with it.
It does however support displaying some mobile device notifications (only incoming calls and text messages AFAIK). My guess is that in case of iOS it uses ANCS.
I'm interested in making the wristband vibrate programmatically from an iOS application. I figured that maybe dispatching system notifications is the way to go.
I saw that for Android there is bitTicker which basically acts as a proxy so that e.g. WhatsApp notifications get passed to Fitbit as text message notifications.
I was wondering if the same is actually possible on iOS as well. I'm considering both private and public iOS API solutions (not planning to release this application to App Store). Is there a way of somehow synthesising incoming call / message notifications so that they are passed to Fitbit? Is there some other way of approaching this problem?
I would appreciate any insights in this matter.

Background Bluetooth with iOS device

I am working on developing a bluetooth peripheral to work with my iOS device. I need to make the iOS app receive data whilst it's in background and process that data as it comes. Looking through Apple's CoreBluetooth framework, I can see how the background execution modes can be used. Now to save power, I want the iOS device to only connect to the bluetooth peripheral at a certain time (without need of user interaction). I've looked through Local Notifications on iOS and it has very limited functionality and don't think it provides what I need.
So is there anyway to wake up an app at 6pm and ask the application to start scanning for bluetooth devices? And then execute other code once device is connected? All this without user interaction.
Any suggestions would be appreciated!
Thanks!
You can't really schedule operations to occur at a specific time in iOS (aside from local notification, which as you said isn't what you need).
You can use background fetch mode to periodically allow your app to check for new data. You can set an interval (although this is only a guideline to iOS, not a strict schedule) for how often your app is woken.
When iOS calls your app delegate performFetchWithCompletionHandler method you can check the current time and decide whether you want to transfer data. If not then you can quickly return UIBackgroundFetchResultNoData. If you do get new data then you can retrieve it before returning UIBackgroundFetchResultNewData

Keep iOS App alive to work with MQTT protocol

For a project I need many clients to subscribe to different hardware devices. In this setup the clients are iOS - Devices. The hardware is something like a raspberry pi but i don't think this matters. This hardware devices send a signal if it measures some kind of information. This is a rare event and possibly could never happen.
Purpose of the app is to warn the user when some kind of event appears in a location he is interested to.
I planed to implement this using the MQTT protocol.
That is where my problem is. To work with MQTT the app needs to send PINGREQ every few minutes even when the app is in background. Also the app needs to receive its subscriptions and handle them immediately.
This is what I planned to do:
Set the "UIBackgroundModes" key in Info.plist to "voip".
Mark the socket as voip socket to wake the app when it receives something
Set the keepAliveTimer:callback: and send the PINGREQ
.. as described here
My questions are: Will Apple allow this? My app is not an VoIP app. If no, are there any alternatives to this approach?
If Apple policies doesn't allow your to put your MQTT client App running in the background, then the solution should be to implement an additional push service.
A push service subscribes to your MQTT broker and sends push notifications to your mobile devices, so that either they have the MQTT client App running or not they will get the events.
Yes!
There is a chance that apple can reject your application when you are using VOIP(even though your app is not a VOIP Kind of application) to keep application alive!
I'm using Location services which is a proper solution to keep application alive in background mode.
Ask permissions to use location services even when the app in background mode & after getting the allow call back,set your location manager's desired accuracy to worst,distance filter to 99999(means your app will be notified if the user travels more than 99999 Meters from last location update call back)
By altering the desired Accuracy and distance filters you can save the user's battery consumption,otherwise your app will consumes lot of energy
That was one proper way which makes your application to run in background for more than 2 days continuously (Already using in our projects).
HTH! Have fun in coding :)

How to run ios app continuously in background with user's permission

I'm developing one iOS application which is related with OBD2. The app provides feature like connecting with obd2 device and read out data.
With user's permission, I want to implement below feature even if app is not running at all :
Now I want to do When user enters car, connection to obd2 device is to be done automatically and check for some params if i gets failure on those data then i need to send data to cloud for analysis.
How can i know about user enter car ? I'm thinking one way like continuously checking the Wifi Availability to OBD2 device and if i get wifi available then i can say "user is nearer to car or in the car".
But again problem is that if app is not running in the background then how can trigger this kind of event.My app is not supporting any background mode like voip, audio, location, newstand etc..
Is there any other way like local notification or any other way by which i can trigger event that user has entered in car even if app is not running at all ?
Can Background mode like Receive updates from External Accessory mode or External Accessory framework support me in this feature implementation ?
Can i develop this feature in such way that Apple approves this feature ?
Any other feedback or suggestion will be appreciated !

Resources