Wednesday, September 18, 2019

How to read TX power from CC2640R2 BLE Stack

The following steps show you how to read TX power from CC2640R2 BLE Stack. I use simple_central example for testing.

1. Call "HCI_ReadTransmitPowerLevelCmd(0, HCI_READ_CURRENT_TX_POWER_LEVEL);" in the end of SimpleCentral_init().

2. In SimpleCentral_processCmdCompleteEvt, add the following red codes to receive current TX power.

static void SimpleCentral_processCmdCompleteEvt(hciEvt_CmdComplete_t *pMsg)
{
  switch (pMsg->cmdOpcode)
  {
    case HCI_READ_TRANSMIT_POWER:
    {
        int8 get_tx_pwr = (int8)pMsg->pReturnParam[3];

        Display_print1(dispHandle, SC_ROW_SEPARATOR, 0, "TX power is %d db",get_tx_pwr);
        break;
    }

    case HCI_READ_RSSI:
    {
#ifndef Display_DISABLE_ALL
      uint16_t connHandle = BUILD_UINT16(pMsg->pReturnParam[1],
                                         pMsg->pReturnParam[2]);
      int8 rssi = (int8)pMsg->pReturnParam[3];
     
      Display_printf(dispHandle, SC_ROW_ANY_CONN, 0, "%s: RSSI %d dBm",
                   SimpleCentral_getConnAddrStr(connHandle), rssi);

#endif
      break;
    }

    default:
      break;
  }
}

Wednesday, August 14, 2019

How to detect two buttons pressed at the same time on EFR32 EmberZnet

The following code show you how to detect two buttons pressed at the same time on EFR32 EmberZnet.

void emberAfHalButtonIsrCallback(uint8_t button, uint8_t state)
{
  if (state == BUTTON_RELEASED) {
    emberEventControlSetActive(findingAndBindingEventControl);
  }
  if( (halButtonPinState(BSP_BUTTON0_PIN)==BUTTON_PRESSED) && (halButtonPinState(BSP_BUTTON1_PIN)==BUTTON_PRESSED) )
    emberAfCorePrintln("Both btn pressed!!!");

}

How to enable hex and float value output from System_printf in TI CC13xx/CC26xxx SDK.

The following steps show you how to enable hex and float value output from System_printf in TI CC13xx/CC26xxx SDK.

1. Add "System.extendedFormats = '%x%f%$L%$S%$F';" in your application ccfg such as app.cfg
2. Add "#include " in the beginning of C file.
3. You can use System_printf and %x/%f to print hex or float value now.

Tuesday, August 13, 2019

How to use usleep/sleep function in CC1310 TI 15.4 Stack

The following steps show you how to use usleep/sleep function in CC1310 TI 15.4 Stack:

1. Add "var Settings = xdc.useModule('ti.sysbios.posix.Settings');" into app.cfg
2. Add "#include " in your C file.
3. You can use usleep or sleep function in your C file now.