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.

CC2541 ANCS Subscribing to Notification and Data Sources



I have been modifying the TimeApp sample to read ANCS on an iphone using the blog post http://mbientlab.com/blog/ancs-on-ti2541-in-an-afternoon/ .   

I have the notification source working and I can receive call backs and view the notification source data.  

However I have not been able to subscribe to the data source notification to get more data.  

I think the issue is in how the TimeAppDiscAlertNtf switch statement handles the discovery.  

From the other forum post: http://e2e.ti.com/support/wireless_connectivity/f/538/t/337594.aspx I have gotten to halfway through the DISC_ANCS_CHAR step and stored the UUID of interest for notification, data, and control point. 

I am unsure how to proceed with the next step with is GATT_DiscAllCharDescs.  Should this be two steps where I do GATT_DiscAllCharDescs twice?  Once for notification and once for data?  Or do I just need to send for notification?

Then for finding the CCCD do I need to do twice to find notification and data CCCD or just the one CCCD like it does now? 

// CCCD found
timeAppHdlCache[HDL_ANCS_NTF_CCCD] =
pMsg->msg.findInfoRsp.info.btPair[i].handle;

My last question is about enabling notifications.  For the notification source I write a 0x0001 to the timeAppHdlCache[HDL_ANCS_NTF_CCCD] to enable callbacks.  Do I need to do a similar process for data source so that when I write to control point I can receive a callback from data source?

So, can anyone share more detail on how to subscribe to data point? 

  • It looks like you go farther than I did.  I've used the timeapp demo with the timeapp_discovery.c file replaced with the one found here: http://mbientlab.com/blog/ancs-on-ti2541-in-an-afternoon. Similar to what you have done

    I am able to discover the primary service uuid and the timeAppSvcStartHdl = 10 and the timeAppSvcEndHdl = 19. 

    However in "case DISC_ANCS_CHAR:"  the pMsg->msg.readByTypeRsp.numPairs is always 1.  and this case in not 0x9FBF.  Since it only goes through the loop once it never finds the notification characteristic.  I've tired repairing the iphone many times, even rebooting.

    Is there a trick to finding the correct notification characteristic?  Any help would be greatly appreciated.

     

  • Stephen, i checked my code and pMsg->msg.readByTypeRsp.numPairs seems to be 1 for me also.  Yet I can find the notification characteristic and subscribe to it.  

    After some more work though I think my problem is in notifying both the notification source and the data source that I want to set up notification call backs.  

    Does anyone have any code examples on how to set that up?

  • David,

    I finally was able to subscribe to the notification source and now when I get email, texts, phone calls, etc. I am able to light up an Led on the keyfob demo board. 

    If you can't get this far let me know and I can send you the files I have.

    The next item is to get the data source working.  Hopefully I can figure that out in the next few days.

  • Stephen, 

    You are now as far as me. I can only get the notification working. I have not been able to subscribe and talk to the data source. 

    If I get it working I'll post files. If anyone else has it working any help would be appreciated. 

  • Hey Stephen,

    Did you ever get the discovery loop to work for all the sources? (notification, data, and control)  

    I think that is where I am stuck.  I am also not sure if I send the notification request for data source correctly.

    Please let me know if you make any progress.  

    Also if anyone from TI would like to chime in that would be great.  I heard that there is an official ANCS solution in the works so if anyone has any hints for us I am sure we are not alone in this. 

  • Hi David,

    Sorry for the late response, I've been on travel the past week.  I was able to get all sources to work, although probably not coded the best. I had to make changes to a number of the files.

    Were you able to get any farther?  Do you still need help? 

  • Hey Stephen,

    Late response is still a response and I am thankful someone is helping.  

    I have not made any progress.  I am trying to debug a separate issue with large power consumption in sleep mode and that is more pressing.  

    I would really like to have some help.  If you can share your functions that perform the discovery and subscription to the services that would be amazingly helpful.  

  • I am new to the ti forum, I've added all the files I've changed to my folder.  Can you see them?

  • I am new to these forums as well.  I did find the files in your profile.  Thank you for your help. 

  • Stephen,

    I can't seem to get it working.  

    It gets up to the timeAppSendGattMsg function but after that I do not think I get a data response.  

    Maybe I am not understanding the code correctly but shouldn't after a data response is received a breakpoint at "HalLedSet( HAL_LED_2 , HAL_LED_MODE_ON );" of the following snippet be hit? 

      switch ( i )
      {
        case HDL_ANCS_DS_NOTIF_START:
           uint8 *n = pMsg->msg.handleValueNoti.value;
           HalLedSet( HAL_LED_2 , HAL_LED_MODE_ON );
        case HDL_ANCS_NTF_NOTIF_START:
           uint8 *p = pMsg->msg.handleValueNoti.value;
           if (p[0] == 0){
            if (p[2] == 4){ //Social
              timeAppSendGattMsg( pMsg );

    
    

    Also for timeAppSendGattMsg how did you find what to send to the control point?  I can not find much info on format of that.  What is the data you request?

    Thanks for your continued help 

  • Have this been resolved, I have the exactly same question as David, and I want to know how I can discover the data source handle and store it, where should I put these code?

    Chris

  • Chris,

    I got it working with the files I got from Stephen above.  The only thing I needed to change was the following function.

    void timeAppSendGattMsg( gattMsgEvent_t *pMsg )
    {
      attWriteReq_t writeReq1;
      uint8 *p = pMsg->msg.handleValueNoti.value;
      writeReq1.len = 15;
      writeReq1.value[0] = 0; //p[0];
      writeReq1.value[1] = pMsg->msg.handleValueNoti.value[4];
      writeReq1.value[2] = pMsg->msg.handleValueNoti.value[5];
      writeReq1.value[3] = pMsg->msg.handleValueNoti.value[6];
      writeReq1.value[4] = pMsg->msg.handleValueNoti.value[7];
      writeReq1.value[5] = 0x01; 
      writeReq1.value[6] = 0xFF;
      writeReq1.value[7] = 0xFF; 
      writeReq1.value[8] = 0x02; 
      writeReq1.value[9] = 0xFF; 
      writeReq1.value[10] = 0xFF; 
      writeReq1.value[11] = 0x03; 
      writeReq1.value[12] = 0xFF; 
      writeReq1.value[13] = 0xFF; 
      writeReq1.value[14] = 0x05; 
      writeReq1.sig = 0;
      writeReq1.cmd = 0;
      writeReq1.handle = timeAppHdlCache[HDL_ANCS_CP_NOTIF_START];
      HalLedSet( HAL_LED_2 , HAL_LED_MODE_OFF );
      GATT_WriteCharValue( timeAppConnHandle, &writeReq1, timeAppTaskId );
      YesNot = 1;
    }

    I may also have had issues with the timeAppConfigNext function.  So look at the following statements.

    switch ( timeAppConfigList[state] )
      {
        // Read these characteristics
      case HDL_ANCS_NTF_CCCD:
          read = FALSE;
          writeReq.len = 2;
          writeReq.value[0] = LO_UINT16(GATT_CLIENT_CFG_NOTIFY);
          writeReq.value[1] = HI_UINT16(GATT_CLIENT_CFG_NOTIFY);
          writeReq.sig = 0;
          writeReq.handle = timeAppHdlCache[HDL_ANCS_DS_CCCD];  //19 
          writeReq.cmd = 0;
          
          break;
      case HDL_ANCS_DS_CCCD:
          read = FALSE;
          writeReq.len = 2;
          writeReq.value[0] = LO_UINT16(GATT_CLIENT_CFG_NOTIFY);
          writeReq.value[1] = HI_UINT16(GATT_CLIENT_CFG_NOTIFY);
          writeReq.sig = 0;
          writeReq.handle = timeAppHdlCache[HDL_ANCS_NTF_CCCD];  //16
          writeReq.cmd = 0;
          
          break;

    Both code segments are my fixed versions.  To test I set a breakpoint after the data case in the timeAppIndGattMsg function and looked at what pmsg returned. 

    Hope this helps. 

  • Hi,David,

        Thanks for your reply.I've tested and it is Ok now, Thanks again.

    Chris

  • Hi David & Stephen,

    I cant find the code in you guys profile -> files, probably you guys already remove it, can you guys upload once again for me? My process is I can receive the data from NS, then I write to CP but nothing receive from DS, I believe I cant enable and notify the DS's CCCD successfully.

    If you guys can upload once again the working ANCS source code would be greatly appreciated.

    Jim

  • Stephen,

    I am trying to do some testing on ANCS, could you send your files to me for reference.

    Thanks.