External heart rate monitor integration with watchOS 3 - bluetooth

I have a watchOS 3 fitness application and some of my users are asking for External Heart Rate Monitor support. I was hoping that if a heart rate monitor was paired with the watch then I'd get this for "free" using the same mechanism used to get data for the watch heart sensor (HKAnchoredObjectQuery on the HKHealthStore). That does not appear to be the case. Any advice on how to support this? Do I need to integrate by hand using Core Bluetooth?

Turns out my problem was using sample code without scrutinizing it. I removed the following line and now external heart rate monitors work fine:
let devicePredicate = HKQuery.predicateForObjects(from: [HKDevice.local()])

Related

Interacting with BLE Cycle Trainer

My current is on Flutter using Dart and working with Bluetooth low energy devices. I have the basics up using this library and am able to do the following
1. Search for devices and list
2. Connect to device
3. Retrieve services and read characteristic values
4. Subscribe to changes on characteristics.
In order to interact with device correctly I need to read and write from the correct services/characteristics to read data and set things like resistance on the flywheel
I have used the below link and have started mapping out the services, however although the reading can be worked out. The writing to characteristics is a bit out of my reach.
https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.service.cycling_power.xml
The question is.
Does any have experience working BLE cycle trainers and could provide
some insight into how to read and manage services and characteristics
appropriately?

Is it possible to dynamically set UUID on iBeacon app?

I have a beacon device that broadcasts different UUID values based on a custom rotation scheme.
Usually, the developer has to set static UUID to be recognized by the app like that (example for iOS):
CLBeaconRegion *region = [[CLBeaconRegion alloc] initWithProximityUUID:uuid major:major minor:minor identifier:identifier];
I was wondering if there is a way to dynamically generate (or receive from a server) the UUIDs to be recognized.
Having said that I am still having difficulties understanding the internal mechanisms of how beacons are understood by iOS and Android. From my understanding, the BLE module of the phone forwards all well-formated iBeacons to the OS which maintains a list of recognized UUIDs. After a simple look-up and if a match is found the OS will bring the corresponding app to the foreground.
However, when does the app's recognized UUID(s) get registered with the OS? How often do they get re-registered? I would be grateful if anyone would point me to any relevant online material or at least the mention the mechanisms involved in this process.
On both Android and iOS registering for beacon ProximityUUIDs to detect amounts to nothing more than applying a filter on Bluetooth packets that match the byte pattern of the beacon and ProximityUUID. The important difference is that on iOS the operating system framework that does the filtering, CoreLocation, puts severe limits on the filters you can have. The iOS limits include:
You can have only 20 UUIDs monitored at any given time for a single app.
A device-wide limit of the first 30 UUIDs monitored gets hardware assisted fast detection. Later UUIDs to register get slower (several minute delays in the background) detections.
You cannot monitor or range for any UUID (global wildcard)
You can, however, change the 20 UUIDs you app is monitoring at any time -- even once every few seconds. The trick is that your app must be in the foreground to do this, or have a permitted way to run in the background to do this UUID rotation.
To register a UUID for monitoring on iOS, you simply declare a region with that UUID ( typically without specifying major and minor values) then call:
[locationManager startMonitoringForRegion:region];
To keep from going over your 20 region limit you also have to call:
[locationManager stopMonitoringForRegion:oldRegion];
On your old regions you do not want to monitor anymore. Otherwise if you go over the 20 limit you will not get detections on newly registered regions.
Of course, you may use a web service to provide the UUIDs for your new regions to monitor.
On Android it is much simpler -- you can monitor for all UUIDs by specifying a global wildcard using the Android Beacon Library and similar SDKs.
Full disclosure: I am the lead developer on the Android Beacon Library, the first beacon implementation on that platform.

How to determine the power status of a monitor/TV in Linux

I asked this same question a few months ago, but I've run into another roadblock and I'm hoping someone will have a flash of insight. The is the previous thread: Detecting if the monitor is powered off
I'm trying to figure out the power status of a monitor, in particular a TV that is plugged in via HDMI. I'm running Ubuntu 10.10 with nVidia ION video cards. These PCs will be running some digital signage and I need to make sure the power is on to the TV during business hours. I have a working Python script controlling an IR transmitter to turn the TV off and on. The last piece of the puzzle is to know the current state of the TV.
In my previous thread, I found I could use ddccontrol to get information from the monitor. That worked great for a traditional Asus monitor plugged in via HDMI. However, the Vizio TV says it doesn't support DDC.
I've also tried using get-edid to get live resolution and color information, but that fails to return any information from the TV.
I've tried udevadm monitor but an event only fires on the initial monitor plugin.
I have a feeling that the nVidia drivers are blocking these calls to the monitor, but I can't confirm that.
Ultimately, all I'm looking for is a single byte of information that changes when the monitor turns off.
EDIT: So, I'm coming to the conclusion that this may not be possible. At least not consistently possible across various combinations of video cards and monitors/TVs. The next idea I have is to monitor power usage on an outlet. I first looked at Kill A Watts, but they are completely stand alone. After several hours of searching, I came across Digi and their XBee radios. I ordered one of XBee's Smart Plugs from Digi and a XBee radio and USB adapter from Spark Fun. My current plan is to use a Python script that polls the Smart Plug for power usage.
The plug and radio were kind of expensive. Does anybody know of a power meter that plugs in? Everything I found was wireless. I'd like to be able to connect to it via USB, ethernet, or serial.
EDIT 2:
I could never get the XBee plug to work. It's incredibly difficult to configure the plug unless you buy one of Digi's gateways.
I ended up building my own current sensor. It's Arduino based and cost about $60 in parts. I wrote about it here: http://trafficlightads.net/2011/09/06/an-arduino-current-sensor/
I have a couple of Watts up? .Net models that have USB and Ethernet for monitoring devices and controlling devices. The .Net model adds Ethernet and an internal relay to turn the attached device on and off. This could be used to eliminate the possibility of IR being blocked and not being able to transition the state of the TV.
Watts up? .Net Product Link
They aren't cheap, but they are well-built. I recommend getting the international model if you want the most flexibility in outlet type. This allows you to use your own in and out cords. In the USA model the input cord is hard-wired/integrated.
Good luck.

QOS measurement tool?

Can anyone suggest a good audio QOS monitoring tool?
If its a open source one and freely available, it will be great. Its fine otherwise too.
Iam trying to measure QOS for a softphone on a PC and also on a mobile.
Try the following link and search for QoS: http://www.slac.stanford.edu/xorg/nmtf/nmtf-tools.html
Bear in mind that a users perception of the quality of a voice call is not an absolute thing so treat any results with this in mind. See: http://en.wikipedia.org/wiki/PESQ for one way (probably the most accepted way) to measure and score voice quality.
You can measure absolutely the delay and packet loss which may give you the information you need.
We have developed a tool for Measuring QoS for both Audio and Video and have some patented algorithms to find out the MOS for Video and used E-model for Audio MOS.
It has been tested on VoIP calls over LTE.
You can check one more tool from EMpirix called Hammer Call analyser or any Elecard tool as well.
But i don't know of any freeware tool in this domain.
I have done voice quality monitoring system for conferencing services provider. Tools used: Empirix Hammer and CallMaster. System in a nutshell: every so often two virtual participants called into conference call. Then each of them spoke a phrase and the other one measured PESQ score. Results were sent to another monitoring system. This worked well. I think PESQ measurement is the way to go for automated testing.

How to programmatically use the mobile phone's IrDA to remote control a media player?

which API or library on which mobile OS is to be used when one needs to write a code to use the phone's IrDA to create the necessary impulses to remote control consumer electronics e.g. a HDD media player?
Is maybe a certain mobile OS better suited for that kind of application than others?
First you need to know that IrDA is not the best choice for remote control. It can be done, but IrDA is by design high speed/low range, you can emulate low speeds but ranges (IMO) are far from practical usage (Nokia e50 is able to control digital camera shutter from 2-3m... with very, very careful aiming). The amount of hacking needed to achieve this is shown here, you basically need to trick IrDA to send correct impulses with correct frequency.
The second thing is that CIR remote control is not as simple as you might think. There are countless standards that differ in used frequency, modulation, wavelength, command codes and so on. You need to know what you want to support. LIRC site can be very helpful in determining that http://lirc.sourceforge.net/remotes/. Approachable explanation of what it all means is available here: http://www.sbprojects.com/knowledge/ir/ir.htm
As for ready made libraries and platforms... I honestly don't know. I've seen it done on PocketPC (nevo among others) and Symbian S60 (irRemote). Haven't seen working J2ME app yet.
Last time I needed the IR remote I hacked it together using IR diode, AVR ATTiny and surprisingly short piece of assembly :)

Resources