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.

KeyFob in Central Mode - No keypress callbacks

Other Parts Discussed in Thread: CC2540, CC2541

Hi,

I'm receiving only one callback for button press event on KeyFob when it is running SimpleBLECentral application. I'm not receiving any callbacks after the first one when KeyFob keys are pressed. (For my project I need to set the KeyFob in Scanning Mode - GAP Master and act like a GATT Client)

I've added CC2540_MINIDK to the pre-processor macros but it didn't fix my problem. Can you please tell me if there are any other tweaks needed in "hal_key.c". I need help for this very badly and any help in this regard is highly appreciated.

NOTE: I've the following section in "SimpleBLECentral_Init()"

#if defined( CC2540_MINIDK )

// For keyfob board set GPIO pins into a power-optimized state
// Note that there is still some leakage current from the buzzer,
// accelerometer, LEDs, and buttons on the PCB.

P0SEL = 0; // Configure Port 0 as GPIO
P1SEL = 0; // Configure Port 1 as GPIO
P2SEL = 0; // Configure Port 2 as GPIO

P0DIR = 0xFC; // Port 0 pins P0.0 and P0.1 as input (buttons),
// all others (P0.2-P0.7) as output
P1DIR = 0xFF; // All port 1 pins (P1.0-P1.7) as output
P2DIR = 0x1F; // All port 1 pins (P2.0-P2.4) as output

P0 = 0x03; // All pins on port 0 to low except for P0.0 and P0.1 (buttons)
P1 = 0; // All pins on port 1 to low
P2 = 0; // All pins on port 2 to low

#endif // #if defined( CC2540_MINIDK )

Thanks, Arjun

  • It looks like the problem is with "StartDiscovery" function. I was using the following code in  function 

    uint8 gStatus;
    static void simpleBLECentral_HandleKeys( uint8 shift, uint8 keys )

    if ( keys & HAL_KEY_SW_1 )
    {
    // Start or stop discovery
    if ( simpleBLEState != BLE_STATE_CONNECTED )
    {
    if ( !simpleBLEScanning )
    {
    simpleBLEScanning = TRUE;
    simpleBLEScanRes = 0;

    #if (defined HAL_LCD) && (HAL_LCD == TRUE)
    LCD_WRITE_STRING( "Discovering...", HAL_LCD_LINE_1 );
    LCD_WRITE_STRING( "", HAL_LCD_LINE_2 );
    #endif // (defined HAL_LCD) && (HAL_LCD == TRUE)

    GAPCentralRole_StartDiscovery( DEFAULT_DISCOVERY_MODE,
     DEFAULT_DISCOVERY_ACTIVE_SCAN,
     DEFAULT_DISCOVERY_WHITE_LIST );
    }
    else
    {
    GAPCentralRole_CancelDiscovery();
    }
    }

    And this is preventing me to get anymore key press callbacks after the first Left Key press event and by commenting the function call I get callbacks on every button press.

    // GAPCentralRole_StartDiscovery( DEFAULT_DISCOVERY_MODE,
    // DEFAULT_DISCOVERY_ACTIVE_SCAN,
    // DEFAULT_DISCOVERY_WHITE_LIST );

     Now, I'm not sure what that problem is with this discovery function calling from Keypress callback function. If anyone has any inputs please let me know. I'm fighting with this issue from long time and any help is highly appreciated.

    Thanks, Arjun

  • Hi Arjun,

    You could have a look at RC Car Demo on the wiki. The downloadable code includes a Keyfob implemented as a Central device. It might give you a clue or two. 

    Best Regards

  • Thanks Joakim,

    I've downloaded the application and looking into it. Thank you very much with the right pointer. I'll update you if I'm successful or not.

    Arjun

  • Hi Joakim,

    I'm still facing the same problem that I faced earlier with this RC Car Demo code too... If I comment the ScanDiscovery function as I mentioned earlier then I get callback events for KeyPresses every time I press the Key but I do not get the callback events if GAPCentralRole_StartDiscovery() is not commented. I do not know how to Start Discovery on Keyfob!!

    I do not have this problem on CC2541 SmartRF EB hardware but only on KeyFob. Please help me.

    Thanks, Arjun