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.

Send Value of ADC to Central Device and go to sleep

Other Parts Discussed in Thread: CC2541, CC2540

 Hello, 

 I'm new to BTLE and I'm trying to send a Value from the ADC of the CC2541 Slave to CC2541 Master. As a basis I'm using the examples from the Bluetooth Stack "Simple BLE Peripheral" and "Host Test App". I did not make any changes to the Host Test App. At the moment I'm able to get the value of the ADC and transport it to the Simpleprofile_CHAR1_UUID. Afterwards forming a connection with BTool I can read the Value by sending the UUID command F1:FF.

My question is: How can this procedure be programmed that the value is automatically send to the Master Device? Means Reset of the Slave puts it into Advertising Mode, If I form the connection with with BTool to the master, the value should be send and after sending the Slave should go to Sleep Mode. Without sending the Slave any special command!

Can anybody help me please? Thanks!

Michael

 

  • Hi Michael,

    You can automate the process from the peripheral point of view, like sending a notification as soon as it's connected. The Btool side however, cannot be automated as it's designed to be handled manually. You could write your own PC Tool based on code examples available on the wiki, which automates the connecting process.

    Best Regards

  • Hi Michael,

    Whilst I'm no expert at this I believe you need to establish a Call Back Function to deal with changes in value of attribute by way of a notification to the connected device.

    The Simple Peripheral (implemented in SmartRF05 Evaluation Kit) uses this to 'relay' key press notifications between Central and Peripheral devices.

    The concept of call back functions are used throughout the sample codes including the following snippet of code from keyfobdemo.c

    I hope this helps but I would strongly advise you study sample codes and in particular read swru271.pdf (BTLE_CC2540_SoftwareDeveloper'sGuidev1.2)

    Regards;

    Tamer.

    /*********************************************************************
    * @fn proximityAttrCB
    *
    * @brief Notification from the profile of an atrribute change by
    * a connected device.
    *
    * @param attrParamID - Profile's Attribute Parameter ID
    * PP_LINK_LOSS_ALERT_LEVEL - The link loss alert level value
    * PP_IM_ALERT_LEVEL - The immediate alert level value
    *
    * @return none
    */
    static void proximityAttrCB( uint8 attrParamID )
    {
    switch( attrParamID )
    {

    case PP_LINK_LOSS_ALERT_LEVEL:
    ProxReporter_GetParameter( PP_LINK_LOSS_ALERT_LEVEL, &keyfobProxLLAlertLevel );
    break;

    case PP_IM_ALERT_LEVEL:
    {
    ProxReporter_GetParameter( PP_IM_ALERT_LEVEL, &keyfobProxIMAlertLevel );

    // if proximity monitor set the immediate alert level to low or high, then
    // the monitor calculated that the path loss to the keyfob (proximity observer)
    // has exceeded the threshold
    if( keyfobProxIMAlertLevel != PP_ALERT_LEVEL_NO )
    {
    keyfobProximityState = KEYFOB_PROXSTATE_PATH_LOSS;
    keyfobapp_PerformAlert();
    buzzer_beep_count = 0;
    }
    else // proximity monitor turned off alert because the path loss is below threshold
    {
    keyfobProximityState = KEYFOB_PROXSTATE_CONNECTED_IN_RANGE;
    keyfobapp_StopAlert();
    }
    }
    break;

    default:
    // should not reach here!
    break;
    }

    }

  • Thanks for your answers! I will study the Examples on Wiki and read about this Call Back Functions. But maybe I have some questions later! Thanks a lot!!