This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

how do I "subscribe" to notifications in ANCS?

Other Parts Discussed in Thread: CC2540, ASH

I'm working on an ANCS client, and Apple's spec example diagrams say the NC should "subscribe" to their notification source.  I don't really understand whtat they mean by subscribe.  Does anyone have an idea how to make this work?

  • It's a little tricky because Apple wants to save battery. You advertise with a custom payload, iPhone OS scans, after connection, the services are discoverable and the roles switch with iPhone as NP in a server-like peripheral role. Note:  if you do it right, you don't need to have a special app running on the phone.

    You need to look at at the iOS Dev Forums for discussions on the topic.

    I used a Beaglebone from TI and BlueGiga BLE112 with TI CC2540 in a "pebble-like" accessory demo video. This is for a funny Internet show called The GizWiz 

    http://youtu.be/O-YWMl7IS-g

  • DId you have any luck subscribing to the ANCS?  I'm trying to do the same thing but have had little luck.  My understanding is that once you have made a connection you need to ask for the services that the iOS has.  Once you do that and find the ANCS you subscribe and enable it.  I'm looking for code examples but have yet to find any.  Anyone have ideas?

  • The iPhone should therefore be running a Gatt server something similar to the TimeApp example from TI.  I figured that "subscribing" to the ANCS should be similar to the enabling of notifications on the TimeApp sample.  But it didn't work for me.  I can retrieve the handles but I'm not receiving any notifications.  Any suggestion from anyone is much appreciated.

  • I'm sorry I can't respond to everyone who messaged me. I'll try to write this up over the Hodidays when I have some time. Thanks for your patients.

  • Solved my problem. After getting the handles, enable the notifications by sending a 0x1, 0x0 to the handle assigned to the client characteristic configuration of the Notification Source Characteristic.  Everything should now work.

  • I can connect to my device.

    Then I do, GATT_DiscPrimaryServiceByUUID and find ANCS, store the handles.

    Then I do, GATT_DiscCharsByUUID and Notification Source, store the handles at datalist[3], datalist[4]

    Then I try to write 0x0001 to char at these handles, but I get an authentication error

    To which handles ( details ) are you writing 0x0001 to once you discover the Notification Source ?

  • You need to bond with ipod to have authorization.

    I have this code:

      // Setup the GAP Bond Manager
      {
        uint32 passkey = 0; // passkey "000000"
        uint8 pairMode = GAPBOND_PAIRING_MODE_INITIATE;
        uint8 mitm = TRUE;
        uint8 ioCap = GAPBOND_IO_CAP_DISPLAY_ONLY;
        uint8 bonding = TRUE;
        GAPBondMgr_SetParameter( GAPBOND_DEFAULT_PASSCODE, sizeof ( uint32 ), &passkey );
        GAPBondMgr_SetParameter( GAPBOND_PAIRING_MODE, sizeof ( uint8 ), &pairMode );
        GAPBondMgr_SetParameter( GAPBOND_MITM_PROTECTION, sizeof ( uint8 ), &mitm );
        GAPBondMgr_SetParameter( GAPBOND_IO_CAPABILITIES, sizeof ( uint8 ), &ioCap );
        GAPBondMgr_SetParameter( GAPBOND_BONDING_ENABLED, sizeof ( uint8 ), &bonding );
      } 

    Also you might need to hold off writing the notification until the gap bond manger callback indicates the devices have BONDED.

  • Zach, You will need to discover the handles to the descriptors of the notification source characteristic. You can use the function GATT_DiscAllCharDescs which will provide you with handles. You will write to the handle corresponding to the client characteristic configuration (UUID 0x2902). For the write to work, your device must be bonded/paired to the phone.
  • Thank you Leo and Anthony. Both of your suggestions really helped. 

  • I am trying to write a firmware for a CC2540 DK-MINI Board based on SimpleBLEPeripheral to connect to an Iphone 5 and once connected subscribe to the ANCS and get notification send directly to the CC2540 DK-MINI from the Iphone.
    I understand that I have to use 128 Bit UUID and I have to bond my cc2540 to the Iphone...
    Also I added the following define symbol to the preprocessor options of the compiler: USE_128_BIT_UUID.
    So far I have this code : ( snippets ):
    To deal with the advertise of a 128 bit uuid :
    // GAP - Advertisement data (max size = 31 bytes, though this is
    // best kept short to conserve power while advertisting)
    static uint8 advertData[] =
    {
      // Flags; this sets the device to use limited discoverable
      // mode (advertises for 30 seconds at a time) instead of general
      // discoverable mode (advertises indefinitely)
      0x02,   // length of this data
      GAP_ADTYPE_FLAGS,
      DEFAULT_DISCOVERABLE_MODE | GAP_ADTYPE_FLAGS_BREDR_NOT_SUPPORTED,
      // service UUID, to notify central devices what services are included
      // in this peripheral
      0x11,   // length of this data
      GAP_ADTYPE_128BIT_MORE,      // some of the UUID's, but not all 
      0xD0, 0x00, 0x2D, 0x12, 0x1E, 0x4B,0x0F, 0xA4, 0x99, 0x4E, 0xCE, 0xB5,0, 0, 0x05,0x79 // ANSC Primary Service UUID
    };
    To deal with the bonding part :
    // Setup the GAP Bond Manager
      {
        uint32 passkey = 0; // passkey "000000"
        uint8 pairMode = GAPBOND_PAIRING_MODE_INITIATE;//uint8 pairMode = GAPBOND_PAIRING_MODE_WAIT_FOR_REQ;
        uint8 mitm = TRUE;
        uint8 ioCap = GAPBOND_IO_CAP_DISPLAY_ONLY;
        uint8 bonding = TRUE;
        GAPBondMgr_SetParameter( GAPBOND_DEFAULT_PASSCODE, sizeof ( uint32 ), &passkey );
        GAPBondMgr_SetParameter( GAPBOND_PAIRING_MODE, sizeof ( uint8 ), &pairMode );
        GAPBondMgr_SetParameter( GAPBOND_MITM_PROTECTION, sizeof ( uint8 ), &mitm );
        GAPBondMgr_SetParameter( GAPBOND_IO_CAPABILITIES, sizeof ( uint8 ), &ioCap );
        GAPBondMgr_SetParameter( GAPBOND_BONDING_ENABLED, sizeof ( uint8 ), &bonding );
      }
    But After I compile and flash the cc2540 DK-MINI and run the board the Iphone 5 is not able to pair/bonding just does not show any BLE device when you go to setting->Bluetooh
    Can somebody give me some insight about what is missing or what need to be done?
    Thanks in advance.
  • Hi Ricardo,

    I'm still not able to get ANCS working however chaging GAP_ADTYPE_128BIT_MORE to GAP_ADTYPE_SERVICES_LIST_128BIT in adData.

    and UUID to 

    0xD0, 0x00, 0x2D, 0x12, 0x1E, 0x4B,0x0F, 0xA4, 0x99, 0x4E, 0xCE, 0xB5, 0x31, 0xF4, 0x05,0x79 // ANSC Primary Service UUID

    Shows device in Settings -> Bluetooth

    I hope this info is helpful.

    Thanks.

  • Thank you Ravi

    I am now able to connect and bond to the iPhone.

    Does anybody knows the steps to follow in order to get the handle for the Notification Service characteristic of the ANCS ?

    code snippets will be very helpful.

    Thanks

  • Is there going to be a post , link, or Appllication Note on how to do this in the near future.

    We are working on the ANCS protocol and also need information.

    Thank you.

  • Hi All,

           i'm working on ANCS client application using TI timeapp sample project and i did changes in the timeapp_discovery.c file according to following link

     http://mbientlab.com/blog/ancs-on-ti2541-in-an-afternoon/

    I connected the client device(keyfob) with iphone 4s using pairing process and it was successfully paired with iphone, after that client device discovered the ANCS using timeAppDiscStart() function.

    i got timeApp_ProcessOSALMsg() callback for enabling notifications and after that i am not getting any notifications for text messages.

    please help me to resolve this issue.

    thanks

    prabakaran

  • I looked at this article.. I had some issues which I finally resolved.. few more hints..

    Value of

    ANCS_SVC_UUID -- { 0xD0, 0x00, 0x2D, 0x12, 0x1E, 0x4B, 0x0F, 0xA4, 0x99, 0x4E, 0xCE, 0xB5, 0x31, 0xF4, 0x05, 0x79 };

    CHAR_DESC_HDL_UUID128_LEN -- 21

     

  • Hi Leo,


    Can you please send me the source of your project? How were you able to do this?

    Thanks so much.

  • Hi Prabakaran,

    Can you please share source with us ? How were you able to get this to work?

    Thanks much!
  • Can you please post the source for this?

    That would be really helpful for all of us trying to get ANCS working on our dev boards.

    Thanks much!

  • Dear Zach Marsen,

    Nice to your post~

    Hope, you have done well regarding ANCS notifications subscription from iOS..

    well, I am facing the same issue bonding and getting notification alert (for msg, phone call....etc) on my CC2540 device through iOS via ANCS.

    so far I followed this post~   

    but didn't work out. 

    Please help me by sharing some solution or sample code, which needed to be changes.

    I'd be highly thankful to you~

    Regards,

  • I have try, but do you success?  

    which version of Bstack  do you using?

    it was fail  when i using Ble stack 1.40

  • Hi Ash

    which version of BLE stack do you use ?

    i am failed too!!