sandeepmistry / node-ancs

A node.js lib to access the Apple Notification Center Service (ANCS)
MIT License
67 stars 19 forks source link

Discovery doesn’t work (OS X 10.11, iOS 9) #9

Open sander opened 8 years ago

sander commented 8 years ago

The library used to work well between my MacBook and iPhone, but a few months later (with an iOS reinstallation and OS X upgrade in between) it doesn’t. I’m trying it this way:

  1. Install ANCSExample on iOS.
  2. Run DEBUG=* node test.js on OS X.
  3. Run ANCSExample on iOS.

Expected: Node recognizes the phone advertisement (with device name ‘testje’) and displays a sequence ‘discovered’, ‘connected’, ‘services and characteristics discovered’.

Instead: Node just outputs all advertisements it finds, and doesn’t handle the ‘testje’ one differently. No connection etc. See the relevant output lines below:

yosemite-bindings xpcEvent: {
  "kCBMsgId": 37,
  "kCBMsgArgs": {
    "kCBMsgArgAdvertisementData": {
      "kCBAdvDataIsConnectable": 1
    },
    "kCBMsgArgRssi": -41,
    "kCBMsgArgDeviceUUID": {
      "type": "Buffer",
      "data": [
        120,
        176,
        230,
        29,
        235,
        205,
        64,
        36,
        164,
        236,
        13,
        228,
        189,
        1,
        255,
        113
      ]
    },
    "kCBMsgArgName": "testje"
  }
} +611ms
  yosemite-bindings peripheral 78b0e61debcd4024a4ec0de4bd01ff71 discovered +0ms

I’ve tried both with and without the devices being paired using Bluetooth Settings. ANCS from the same phone to Linux works, using https://github.com/robotastic/ble-ancs.

Am I missing a step? Should node-ancs still be working with this combination of OS versions?

sandeepmistry commented 8 years ago

@sander please provide a full debug log.

Also, I'm wondering if CoreBluetooth/blued is not reporting the ANCS GATT service anymore in OS X 10.11. Would you be able to get a screenshot from the LightBlue OS X app connected to an iOS 9 peripheral?

sander commented 8 years ago

Debug log: https://gist.githubusercontent.com/sander/411e34f692ba9395f69e/raw/d3e948585912435876d0bbc64079ff87b8d75cff/debug.txt

Screenshot: schermafbeelding 2015-10-27 om 09 21 31

sandeepmistry commented 8 years ago

@sander thanks

From the logs looks like no services are discovered:

Tue, 27 Oct 2015 08:25:13 GMT yosemite-bindings xpcEvent: {
  "kCBMsgId": 56,
  "kCBMsgArgs": {
    "kCBMsgArgServices": [],
    "kCBMsgArgDeviceUUID": {
      "type": "Buffer",
      "data": [
        124,
        73,
        31,
        4,
        26,
        90,
        70,
        93,
        186,
        56,
        126,
        81,
        246,
        6,
        11,
        42
      ]
    },
    "kCBMsgArgResult": 0
  }
}

node-ancs is looking for the following service UUID when it discovers services: 7905f431b5ce4e99a40f4b1e122d00d0

Here's a screenshot from my OS X 10.10 (Yosemite) Mac connecting to an iOS 9 iPhone:

screen shot 2015-10-27 at 7 21 26 pm

Again, no service UUID 7905f431b5ce4e99a40f4b1e122d00d0 seen for whatever reason ...

sander commented 8 years ago

Thank you @sandeepmistry. I’ve asked about this on the Apple dev forums:

ANCS service on iOS 9 not discovered in OS X 10.11 (pending mod approval)

This post about Mac/iOS listening to iOS’s ANCS suggests that ANCS may be filtered out indeed in CoreBluetooth.