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.

CC2541DK-MINI: Battery value cc2541

Part Number: CC2541DK-MINI

Hi all,

i want to advertise in the periodic task of simplebleperipheral.c the battery value. I used the Batt_GetParameter function and  i visualize the '64' value at every packet advertised, as if the battery does not discharge.

if ( events & SBP_PERIODIC_EVT )
{
// Restart timer
if ( SBP_PERIODIC_EVT_PERIOD )
{
osal_start_timerEx( simpleBLEPeripheral_TaskID, SBP_PERIODIC_EVT, SBP_PERIODIC_EVT_PERIOD );
}

uint8 newBattLevel;
Batt_GetParameter( BATT_PARAM_LEVEL, &newBattLevel );
advertData [5] = newBattLevel;

GAPRole_SetParameter( GAPROLE_ADVERT_DATA, sizeof( advertData ), advertData );
// Perform periodic application task
performPeriodicTask();

return (events ^ SBP_PERIODIC_EVT);
}

Actually i'd like to visualize the adc value of the battery, to see the littles variation during the calculation, so i've replaced that Batt_GetParameter function with the static uint8 battMeasure( void ) function, but the compiler gives me the warning 

Warning[Pe223]: function "battMeasure" declared implicitly C:\Texas Instruments\BLE-CC254x-1.4.2.2\Projects\ble\SimpleBLEPeripheral_1\Source\simpleBLEPeripheral.c 902

and when i try to build the project i have this error

Error[e46]: Undefined external "battMeasure::?relay" referred in simpleBLEPeripheral ( C:\Texas Instruments\BLE-CC254x-1.4.2.2\Projects\ble\SimpleBLEPeripheral_1\CC2541DB\CC2541DK-MINI Keyfob\Obj\simpleBLEPeripheral.r51 )

Any help?

  • Where do you claim and get battMeasure in your application code?
  • Hi Yikai.

    There's a screenshot of workspace and code. I added in battservice.h the declaration extern uint8 battMeasure( void ); the function is defined in battservice.c. Doing so the warning disappear, but  the linking error remains.

    Error[e27]: Entry "Batt_AddService::?relay" in module battservice ( E:\BLE-CC254x-1.4.2.2\Projects\ble\SimpleBLEPeripheral_1\CC2541DB\CC2541DK-MINI Keyfob\Obj\battservice.r51 ) redefined in module simpleBLEPeripheral ( E:\
    BLE-CC254x-1.4.2.2\Projects\ble\SimpleBLEPeripheral_1\CC2541DB\CC2541DK-MINI Keyfob\Obj\simpleBLEPeripheral.r51 )
    Error while running Linker

  • Do you implement function "uint8 battMeasure(void){...}"  in battservice.c?

  • yes, it was already implemented there (static uint8 battMeasure (void) {....}
    I reuse the batteryservice implemented in the keyfob demo app. Added in profile folder battservice.h e battservice.c and in preprocessor settings included the 2 path
    $PROJ_DIR$\..\..\Profiles\HidDev\CC254x
    $PROJ_DIR$\..\..\Profiles\Batt\CC254x
    included "#include battservice.h" in simplebleperipheral.c
  • Can you specify you implement battMeasure in which C file?