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.

CCS/CC2650: simple link ble_app

Part Number: CC2650

Tool/software: Code Composer Studio

Hi team,

I have downloaded simple link peripheral ble stack and I imported into ccs and it is working fine.  I am using nrf connect app in that I have scanned it showing like simpleBLEPeripheral device name in that when notification enables it showing 0x03 is received I don't know from which file it is receiving as 0x03 can you please help me show that It will be very helpful for me.

  • Hi Markel,

    Thank you for the reply, from this link i got some idea

    Characteristic 4 (UUID: FFF4)

    This characteristic has notified property only. It is a single byte, and it is set to whatever value is contained in characteristic 3 (this value can be changed by writing to characteristic 3). Next to “CUSTOM CHARACTERISTIC” there is a circle with an “N”. Pressing this button will enable notifications, and this characteristic will be updated and will display the value contained in characteristic 3(0x03.):

    instead of 0x03 --- I need to send some other data(d1,d2and d3) when I press notification it is possible in this simple_gatt_profile.c can you please help me so that it will be very helpful.

  • Hi,

    Sorry for the late read. What do you mean by sending other data d1, d2, and d3 when you press notification? You can modify the simple profile to whatever you desire. If you only need characteristic 4 with notification, then you can remove characteristics 1, 2, 3 ,5.

    Alternatively you can use the data service from project zero.

    Also you can use BLE Service Code Generator from Simplelink Academy.

    -kel

  • Hi Markel,

    Thank you for your reply, now what I am trying to do is when we press notification in nrf app(client) I should receive d3 instead of (0x03)  from cc2650(server) whether it is posssible.

  • Hi,

    Using nRF Connect Android App go to Characteristics 4 and select the 3 arrows pointing down to enable notifications. Then go to Characteristics 3 select up arrow button to write d3.

    -kel

  • Hi Markel,

    Thank you so much for your reply it is interesting, I have done what you have said but still, I have some doubt now I wrote d3 from the app it is working awesome. But I want to know how to write d3 in the coding( simple_peripheral_cc2650lp_app). can you please help me

  • Hi Santhosh,

    I suggest you go through the Simplelink Academy. It will include writing to characteristics.

    http://software-dl.ti.com/lprf/simplelink_academy/overview.html

    -kel

  • Hi Markel,

    Thank you so much for your reply, I will go through these files what you have given above. Before that I have gone to this linkhttp://dev.ti.com/tirex/content/simplelink_cc2640r2_sdk_1_40_00_45/examples/rtos/CC2640R2_LAUNCHXL/blestack/simple_peripheral/README.html and I got some idea about 5 characteristics in which 4 characteristics will contain(characteristics 3) send a notification to the client. But I went into simple_gatt_profile .c.I find where 0x03 is coming I feel very difficult to find.can you please help me I will also go through simple link academy. if you have some idea from where 0x03 notification is enabled from which file can you share with me.

  • Hi Santhosh,

    The initial values of the characteristics can be found at Simple Peripheral Init

        uint8_t charValue1 = 1;
        uint8_t charValue2 = 2;
        uint8_t charValue3 = 3;
        uint8_t charValue4 = 4;
        uint8_t charValue5[SIMPLEPROFILE_CHAR5_LEN] = { 1, 2, 3, 4, 5 };
    
        SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR1, sizeof(uint8_t),
                                   &charValue1);
        SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR2, sizeof(uint8_t),
                                   &charValue2);
        SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR3, sizeof(uint8_t),
                                   &charValue3);
        SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR4, sizeof(uint8_t),
                                   &charValue4);
        SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR5, SIMPLEPROFILE_CHAR5_LEN,
                                   charValue5);

    As you can see characteristics 3 value is 3 or 0x03. Upon BLE Connection a periodic task will occur every 5 seconds that will copy to value of characteristics 3 to characteristics 4.

    static void SimplePeripheral_performPeriodicTask(void)
    {
      uint8_t valueToCopy;
    
      // Call to retrieve the value of the third characteristic in the profile
      if (SimpleProfile_GetParameter(SIMPLEPROFILE_CHAR3, &valueToCopy) == SUCCESS)
      {
        // Call to set that value of the fourth characteristic in the profile.
        // Note that if notifications of the fourth characteristic have been
        // enabled by a GATT client device, then a notification will be sent
        // every time this function is called.
        SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR4, sizeof(uint8_t),
                                   &valueToCopy);
      }
    }

    -kel

  • Hi Markel,

    Thank so much for the fast reply, it is amazing from your side. finally I got the output if I have any doubt about this I will share with you immediately. once again thank you so much for your patience reply.

  • Hi, Markel,

    I have one doubt in the notification  when we press notify it comes continuously how many times it will come can you help me  

  • Hi santhosh,

    The periodic timer is set to 5000 msec or 5 seconds.

    // How often to perform periodic event (in msec)
    #define SBP_PERIODIC_EVT_PERIOD 5000

    -kel

  • Hi Markel,

    Thank you for your reply, nice to start again. But I need an only one-time display when I press notification whether it is possible

  • Hi santhosh,

    As I have explained the writing of characteristics 3 value to characteristics 4, happens periodically. If you want a one time notification then you need to modify the code. I suggest you go through the simplelink academy.

    -kel

  • Hi Markel,

    Thank you for your reply, ok I will go through simple link academy if I have any doubt i will ask to you.

  • Hi Markel,

    I tried to find from where the notification sends continuously from the simple link academy it is very difficult to find and tried my best but I am still searching from where there allocated. can you please help me to find the continuously after notification it will be very helpful for me

  • Hi Markel,

    I am waiting for your reply regarding continuously notifications.

  • Hi santhosh,

    You need to learn and understand how the code works to know how to modify it. Try these modifications below.

    /*********************************************************************
     * @fn      SimplePeripheral_processCharValueChangeEvt
     *
     * @brief   Process a pending Simple Profile characteristic value change
     *          event.
     *
     * @param   paramID - parameter ID of the value that was changed.
     *
     * @return  None.
     */
    static void SimplePeripheral_processCharValueChangeEvt(uint8_t paramID)
    {
      uint8_t newValue;
    
      switch(paramID)
      {
        case SIMPLEPROFILE_CHAR1:
          SimpleProfile_GetParameter(SIMPLEPROFILE_CHAR1, &newValue);
    
          Display_print1(dispHandle, 4, 0, "Char 1: %d", (uint16_t)newValue);
          break;
    
        case SIMPLEPROFILE_CHAR3:
          SimpleProfile_GetParameter(SIMPLEPROFILE_CHAR3, &newValue);
    	  
    	  SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR4, sizeof(uint8_t),
                                   &newValue);
    
          Display_print1(dispHandle, 4, 0, "Char 3: %d", (uint16_t)newValue);
          break;
    
        default:
          // should not reach here!
          break;
      }
    }
    
    /*********************************************************************
     * @fn      SimplePeripheral_performPeriodicTask
     *
     * @brief   Perform a periodic application task. This function gets called
     *          every five seconds (SBP_PERIODIC_EVT_PERIOD). In this example,
     *          the value of the third characteristic in the SimpleGATTProfile
     *          service is retrieved from the profile, and then copied into the
     *          value of the the fourth characteristic.
     *
     * @param   None.
     *
     * @return  None.
     */
    static void SimplePeripheral_performPeriodicTask(void)
    {
    #if 0
      uint8_t valueToCopy;
    
      // Call to retrieve the value of the third characteristic in the profile
      if (SimpleProfile_GetParameter(SIMPLEPROFILE_CHAR3, &valueToCopy) == SUCCESS)
      {
        // Call to set that value of the fourth characteristic in the profile.
        // Note that if notifications of the fourth characteristic have been
        // enabled by a GATT client device, then a notification will be sent
        // every time this function is called.
        SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR4, sizeof(uint8_t),
                                   &valueToCopy);
      }
    #endif
    }

  • Hi, markel,

    Thank you so much for your reply, I will go through these codes and if any doubt I will say to you.

  • Hi Markel,

    Finally, I got my desired output, once again thank you so much for your support and also I have some doubt in device  discoverable  why because it discovers continuously but I need to off the ble discovering stage after some time whether  it is possible and I also  searched for that in that I got these code link.

    1) 

    / Advertising interval when the device is discoverable (units of 625us, 160=100ms)
    #define DEFAULT_ADVERTISING_INTERVAL 160

    2) 

    // Limited discoverable mode advertises for 30.72s and then stops
    // General discoverable mode advertises indefinitely
    #define DEFAULT_DISCOVERABLE_MODE GAP_ADTYPE_FLAGS_GENERAL

    whether it is correct or which one is correct can you suggest me

  • Hi santhosh,

    If your initial issue has been resolved, mark this post as answered and just create a new post with your new issue.

    After advertising you want it to stop after a period of time, then you can use one shot timer using Util Clock. But you need a way to enable the advertising again such as button press.

    -kel

  • Hi Markel,

    Sorry for the late reply, I just trying to change the util clock setting

    1) Util_constructClock(&periodicClock, SimpleBLEPeripheral_clockHandler,
    SBP_PERIODIC_EVT_PERIOD,0,false,SBP_PERIODIC_EVT);

    2) 

    Clock_Handle Util_constructClock(Clock_Struct *pClock,
    Clock_FuncPtr clockCB,
    uint32_t clockDuration,
    uint32_t clockPeriod,
    uint8_t startFlag,
    UArg arg)
    {
    Clock_Params clockParams;

    // Convert clockDuration in milliseconds to ticks.
    // uint32_t clockTicks = clockDuration * (1000 / Clock_tickPeriod);
    uint32_t clockTicks = clockDuration * (1000 / Clock_tickPeriod);
    // uint32_t clockTicks = clockDuration;
    // Setup parameters.
    Clock_Params_init(&clockParams);

    // Setup argument.
    clockParams.arg = arg;

    // If period is 0, this is a one-shot timer.
    clockParams.period = clockPeriod * (1000 / Clock_tickPeriod);
    // clockParams.period = clockPeriod*(0.001 / Clock_tickPeriod);
    // Starts immediately after construction if true, otherwise wait for a call
    // to start.
    clockParams.startFlag = startFlag;

    // Initialize clock instance.
    Clock_construct(pClock, clockCB, clockTicks, &clockParams);

    return Clock_handle(pClock);
    }

    I need to print 0x03 for one time instead of printing continously so that I am trying to change the util clock construction but I am trying hard to change. for single outcomes 0x03. so in need some help from your side so it will be more helpful

     

  • Hi santhosh,

    Have you tried the code changes I suggested? When you write to characteristics 3 it will only output 1x to characteristics 4.

    -kel

  • Hi, Markel,

    Thank you for your fast reply, yes I have tried what you have said when I change in characteristics 3 it copies to the characteristics 4 the output is fine. But I am to execute 0x03 for one time instead of continuously.As you said I referred with util clock now I am trying with that.

  • santhosh prem said:
    Thank you for your fast reply, yes I have tried what you have said when I change in characteristics 3 it copies to the characteristics 4 the output is fine.

    So, when you write to characteristics 3, it output the same value to characteristics 4 1 time. It works problem solved.

    Why do you need a clock to write to characteristics 4 1 time?

    When I suggested to use the util clock it is for disabling the advertisement after a period of time.

    If you want to output 1 time using the periodic clock. do this modification below.

    if (events & SBP_PERIODIC_EVT)
          {
            //Util_startClock(&periodicClock);
    
            // Perform periodic application task
            SimplePeripheral_performPeriodicTask();
          }

    This will execute the periodic task 1 time only.

    static void SimplePeripheral_performPeriodicTask(void)
    {
      uint8_t valueToCopy;
    
      // Call to retrieve the value of the third characteristic in the profile
      if (SimpleProfile_GetParameter(SIMPLEPROFILE_CHAR3, &valueToCopy) == SUCCESS)
      {
        // Call to set that value of the fourth characteristic in the profile.
        // Note that if notifications of the fourth characteristic have been
        // enabled by a GATT client device, then a notification will be sent
        // every time this function is called.
        SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR4, sizeof(uint8_t),
                                   &valueToCopy);
      }
    }

  • Hi Markel,

    I have tried this method it is producing one-time output(0x03) but when I check with Btool I am not getting a correct response as the value --> 0x03 in the ATT_handle

    --------------------------------------------------------------------

    [28] : <Tx> - 03:18:16.238

    -Type           : 0x01 (Command)

    -OpCode         : 0xFD92 (GATT_WriteCharValue)

    -Data Length    : 0x06 (6) byte(s)

     ConnHandle     : 0x0000 (0)

     Handle         : 0x0028 (40)

     Value          : 01:00

    Dump(Tx):

    0000:01 92 FD 06 00 00 28 00 01 00                   ......(...

    --------------------------------------------------------------------

    [29] : <Rx> - 03:18:16.268

    -Type           : 0x04 (Event)

    -EventCode      : 0x00FF (Event)

    -Data Length    : 0x06 (6) bytes(s)

     Event          : 0x067F (1663) (GAP_HCI_ExtentionCommandStatus)

     Status         : 0x00 (0) (Success)

     OpCode         : 0xFD92 (GATT_WriteCharValue)

     DataLength     : 0x00 (0)

    Dump(Rx):

    0000:04 FF 06 7F 06 00 92 FD 00                      .........

    --------------------------------------------------------------------

    [30] : <Rx> - 03:18:17.939

    -Type           : 0x04 (Event)

    -EventCode      : 0x00FF (Event)

    -Data Length    : 0x06 (6) bytes(s)

     Event          : 0x0513 (1299) (ATT_WriteRsp)

     Status         : 0x00 (0) (Success)

     ConnHandle     : 0x0000 (0)

     PduLen         : 0x00 (0)

    Dump(Rx):

    0000:04 FF 06 13 05 00 00 00 00                      .........

    --------------------------------------------------------------------

    i dont why the value is not printing as 0x03(3)

  • Hi Markel,

    waiting for your reply

  • Hi Santhosh,

    I just tried my 2 suggested modifications at CC2650 LP and works as expected.

    The first code change when you write to characteristics 3 it will write 1 time to characteristics 4. 

    The second code change when there is bluetooth connection it will write 1 time to characteristics 4. However you need to enable notifications before 5 seconds. 

    I am able to test this use smart phone IOS LightBlue App. Using BTool I do not know how to set it to enable notifications for characteristics 4.

    Anyway, if your initial issue has been answered mark this post as resolved. Then just create a new post with your BTool problem.

    -kel

  • Hi Markel,

    Thank you so much for the reply, once again thank you for your patience reply, I have one doubt why you said However you need to enable notifications before 5 seconds. can you explain 

  • Hi,

    For the second code change after bluetooth connection the util clock will start with a timeout of 5 seconds. So if you press enable notifications for characteristics 4 after 5 seconds, the value 0x03 will not appear. You can just change the 5000 msecs higher for this not happen.

    #define SBP_PERIODIC_EVT_PERIOD               5000

    // Create one-shot clocks for internal periodic events.
    Util_constructClock(&periodicClock, SimpleBLEPeripheral_clockHandler,
    SBP_PERIODIC_EVT_PERIOD, 0, false, SBP_PERIODIC_EVT);

    Actually the 2nd code change suggestion is not the best. For testing the first code change suggestion is the best.

    But you should remember whenever you call this code below, It will write to characteristics 4.

    SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR4, sizeof(uint8_t),
    &charValue4);

    -kel

  • Hi, Markel,

    Thank so much, I also have another doubt discoverable #define DEFAULT_DISCOVERABLE_MODE                    GAP_ADTYPE_FLAGS_LIMITED

    in this line it discovers (3minutes) --> 180 second how to reduce to low seconds it is possible or any other option is there?

  • Hi,

    From the comment description below. I have not tested this at GAP_ADTYPE_FLAGS_LIMITED, so I do not know if it exactly advertises only at 30.72 seconds and then stops. 

    // Limited discoverable mode advertises for 30.72s, and then stops
    // General discoverable mode advertises indefinitely
    #define DEFAULT_DISCOVERABLE_MODE GAP_ADTYPE_FLAGS_GENERAL

    If you want the advertisement to stop at a specific time period then a code implementation is needed. I have done this before if there is no event or activity after example 1 minute I put the device in low power mode.

    Anyway just create a new post for your new question. Also do a search in the forum.

    -kel

  • Hi Markel,

    Thank you for your response, how you put the device in low power mode when there no event can you explain to me

    ok I will create a new question

  • Hi, Markel

    waiting for your reply