This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

how to setup a pipe to access iOS7's ANCS?

Hi,

I'm going to try not to get into stuff that is under apple's NDA, but my question is really on the nRF8001 side. Basically, the ANCS is a service that offers three characteristics: NS, CP and DS. I have followed nRFgo documentation, and added UUID bases for the service and the characteristics, then created a ANCS service, and three characteristics matching their properties (Notifiable, Writeable with response and Notifiable), and then I dragged and dropped the service in the "remote" part of the nRFgo Gatt services tab. I also have setup a local service, with a custom (generated by nRFGo) UUID) and a few characteristics (one which is a boolean read/write, just for testing purposes, TX Power Level and Battery Level).

Then I took the SDK's arduino code (with lib_aci), and based my code on "ble_my_project_template". I then compiled it as is, with the newly generated services.h, and LightBlue can connect to my nRF8001+Arduino, and I could browse through the local service and characteristics, and see the test boolean going out of the pipe on the serial line of the arduino.

But now, what I'm trying to do is to subscribe to ANCS notification from the Arduino side. So, based on the webinar and the lib_aci.h documentation, I'm doing the following:


  if (lib_aci_event_get(&aci_state, &aci_data)) {
    aci_evt_t * aci_evt;
    
    aci_evt = &aci_data.evt;
    switch(aci_evt->evt_opcode)
    {
      case ACI_EVT_PIPE_STATUS:
        if (lib_aci_open_remote_pipe(&aci_state, PIPE_ANCS_CP_TX_ACK))
            Serial.println(F("Success opening ANCS CP Pipe!"));
        else
            Serial.println(F("Failure opening ANCS CP Pipe!"));
        if (lib_aci_is_pipe_available(&aci_state, PIPE_ANCS_CP_TX_ACK)) {
            Serial.println(F("ANCS CP available!"));
        } else
            Serial.println(F("ANCS CP not available :-("));
    }
 }

And sadly, when I connect to the device from the iOS device, I'm getting failure opening any pipe, and checking if the pipe is available. I also tried to open remote pipes that are only made for notifications, but they fail to open too.

All the examples are about exposing stuff in the nRF8001 bound MCU, but there's almost nothing about subscribing to notifications on a remote GATT... Is there any example I may have missed?

So, have you got any idea what am I doing wrong here?

  • Hi,

    developer.apple.com/.../Specification.html

    The Apple Notification Center Service is on the iPhone GATT Server. You need to setup the nRF8001 as a GATT client to access the iPhone GATT server. Drag and drop the Services you are looking for i.e ANCS on the "Remote" column of the nRFgo studio, this will make the nRF8001 GATT Client look for those Services. Remember to set the UUIDs correctly.

    1. Use the proximity template for Arduino as the start point to add the ANCS pipes to the "Remote" and do the below modifications

    2. nRFgo studio: Set the IO Capability to Display only

    3. nRFgo studio: Set the Device Security to Security Required

    4. Print the ACI_EVT_KEY_REQUEST to the Arduino serial monitor Type the key printed on serial monitor in the iPhone popup.

    The ANCS pipes will not be discovered the first service discovery. Watch the Service Discovery bit in the ACI_EVT_PIPE_STATUS Look at the datasheet of the nRF8001 for System Events, www.nordicsemi.com/.../nRF8001_PS_v1.2.pdf

    After bonding is successful the ANCS pipes will still NOT be seen.

    Disconnect

    Wait for a few mins

    Re-connect to the iPhone, make sure that some apps are using the ANCS.

    Now the Service Discovery will automatically run and you will see the ANCS pipes in the Closed pipes.

    Open the ANCS Pipes that are closed using the ACI OpenRemotePipe. You need to wait for the first call to OpenRemotePipe to finish before calling the next OpenRemotePipe (ANCS has 2 Pipes that need to be opened). Additionally wait for Service Discovery to complete before doing the OpenRemotePipe.

    Now ANCS is available and you can have fun.

    Enjoy

Related