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.

Big problem pairing remote with CC2541

Other Parts Discussed in Thread: CC2541, CC2540

Dear all,

I have a big problem to start pairing on my remote by using CC2541.

I need to press a key during 4 secondes to start pairing, here the code that i use :


uint16 Pairing_ProcessEvent( uint8 task_id, uint16 events ){
    if ( events & EVENT_START_PAIRING )
    {    
              if(  softCmdGapState != GAPROLE_CONNECTED )
              {
              uint8 current_adv_enabled_status;
              uint8 new_adv_enabled_status;
              
              //démarrer l'appairage
              VOID GAPRole_StartDevice( &softCmdPeripheralCBs );
              //Find the current GAP advertisement status
              GAPRole_GetParameter( GAPROLE_ADVERT_ENABLED, &current_adv_enabled_status );
              
              if( current_adv_enabled_status == FALSE )
                new_adv_enabled_status = TRUE;
              else
                new_adv_enabled_status = FALSE;
              
              //change the GAP advertisement status to opposite of current status
              GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &new_adv_enabled_status );  
              }
              
           return ( events ^ EVENT_START_PAIRING);
    }
       
          if ( events & EVENT_STOP_PAIRING ){
            GAPRole_TerminateConnection();
       
            uint8 test = FALSE;
            GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &test );
          
          // Clear event and return.
        return ( events ^ EVENT_STOP_PAIRING);
        }

    // Return unrecognized events.
    return (0);   
}

The problem is, if i want to start a pairing nothing append because my stack pointer is out of bound. See the picture to understand :

So i reset my chip and i test to EVENT_STOP_PAIRING and it works perfectly, after execute this code :

if ( events & EVENT_STOP_PAIRING ){
            GAPRole_TerminateConnection();
       
            uint8 test = FALSE;
            GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &test );
          
          // Clear event and return.
        return ( events ^ EVENT_STOP_PAIRING);

My chip goes back in low power mode.

I don't understand why the code after EVENT_START_PAIRING doesn't work.

Thanks to help me.

Anthony

  • I want to clarify  that this code is running on a remote control with CC2540. I wanted to change to a CC2541.

  • One more thing :

    I have this warning when my stack pointer is outside the stack range : 

    Wed Sep 26 15:13:12 2012: Breakpoint hit: Code @ softcmd.c:463.22
    Wed Sep 26 15:13:33 2012: The stack 'IdataStack' is filled to 100% (192 bytes used out of 192). The warning threshold is set to 90.%
    Wed Sep 26 15:13:33 2012: The stack 'XdataStack' is filled to 100% (640 bytes used out of 640). The warning threshold is set to 90.%
    Wed Sep 26 15:13:33 2012: The stack pointer for stack 'XdataStack' (currently XData:0xFFFF) is outside the stack range (XData:0x0001 to XData:0x0281)

  • The problem occurs when i call this function :

    GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &new_adv_enabled_status );

    else, the chip goes back in low power mode

  • Dear All,

    I really need your help. Now i'm using software provided by TI : SimpleBLECentral on a CC2541. I have juste interrupts on PORT1 and modify the Keyread and KeyPoll to read keys on my remote when i press a key. But the problem is always here ! I cant start a discovery request !

    Someone has the same problem ?

    Please help me, i don't understand what's happend.

    Thansk a lot,

    Anthony

  • Hi Anthony,

    I'm sorry if this question is a bit basic, but did you open the CC2541 project? CC2540 and 41 use different stack libraries, as they are different hardware.

    I didn't have any problem running simpleBLECentral on a keyfob with a 2541.

    Maybe the problem is with your interrupt handling, or the key setup. You can try to start the discovery request automatically with a timer.

    To do so, add an event to simpleBLECentral.h, add processing of the event to SimpleBLECentral_ProcessEvent in which you start a discovery request, and inside for example if ( events & START_DEVICE_EVT ) { .. here .. } you can add either osal_set_event(simpleBLETaskId, <your_event>) or osal_start_timerEx( uint8 taskID, uint16 event_id, uint32 timeout_value ).

    Aslak

  • Hi Aslak,

    Thanks for your response.

    I resolved my problem. In my code i have make a little bug mistake : IEN2 = 0x10; to validate interrupt on P1 but i should write : IEN2 |= 0x10;

    so now my chip goes back in low power after calling :

     if ( events & EVENT_START_PAIRING )
        {    
                  if(  softCmdGapState != GAPROLE_CONNECTED )
                  {
                  uint8 current_adv_enabled_status;
                  uint8 new_adv_enabled_status;
                  
                  //démarrer l'appairage
                  VOID GAPRole_StartDevice( &softCmdPeripheralCBs );
                  //Find the current GAP advertisement status
                  GAPRole_GetParameter( GAPROLE_ADVERT_ENABLED, &current_adv_enabled_status );
                  
                  if( current_adv_enabled_status == FALSE )
                    new_adv_enabled_status = TRUE;
                  else
                    new_adv_enabled_status = FALSE;
                  
                  //change the GAP advertisement status to opposite of current status
                  GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &new_adv_enabled_status );  
                  }
                  
               return ( events ^ EVENT_START_PAIRING);
        }

    But, i have another problem. I'm using a sniffer to see all the frame and i see nothing on the sniffer. I also tried to use TI SW SimpleBLECentral but it is the same problem. I think that my chip send nothing but how to confirm that ?

    Thanks for your help.

    Anthony

  • Hi,

    I've just tested CC2541_SmartRF_SimpleBLEPeripheral.hex programmed with RF Flash programmer and it works on my remote, but if i use the SimpleBLEPeripheral project, build it and download to the remote : it doesn't work.

    I don't uderstand why because i think that CC2541_SmartRF_SimpleBLEPeripheral.hex is the same program as SimpleBLEPeripheral project right ??

    Thanks a lot,

    Anthony

  • Hi Anthony,

    You can refer to http://processors.wiki.ti.com/index.php/BLE_sniffer_guide for some info on how to use the sniffer. Note that you have to follow the connection from advertising packets until connection so the sniffer knows what's what. Sometimes it can't follow the connection, maybe it was established on another channel. Trying again often works.

    Yes, it should work. Whether it's the same project, I can't really say, but as I mentioned in the last post, it's important that you choose the 2541-project when you open it in IAR. Projects\ble\SimpleBLEPeripheral\CC2541DB.

    Best regards,
    Aslak 

  • Hi,

    Finally i'm using simpleBLEPeripheral but i have some problems.

    I'm using this projet because i can start advertising and connect to a dongle.

    I modified the code to start advertising when i press a key and I can also use this funciton : GAPRole_TerminateConnection when i press another key.

    But i can't use this function  : GAP_EstablishLinkReq because i think it is not implemented on the librairy.

    So i change the CC2541_ble_single_chip_peri.lib library with : CC2541_ble_single_chip_all.lib

    and the function : GAP_EstablishLinkReq is recognized but when i start advertising i can see only 3 RF packet on my sniffer.

    I don't uderstand why.

    Any idea ??

    Thanks a lot,

    Anthony

  • Hi Anthony,

    Yes, GAP_EstablishLinkReq is not included in the _peri.lib which is the peripheral device role library. And there is a good reason. Peripheral devices cannot establish connections per the spec. As a peripheral/slave you just have to hope that someone wants to connect to you.

    If you want to establish connections, you will have to either use the _all.lib and then copy a lot of code from the Central example, or you could switch to using a central example as basis.

    Best regards,
    Aslak 

  • Yes i have tried to use central but there no advertising packet on my sniffer.

    It's why I'm using peripheral project. The problem is when i want to start advertising there is only 3 packets sended.

    I don't understand why.

  • Hi,

    I'm still here with my problem.

    I have a remote with a CC2541 and i would try to use simpleBLECentral. 

    I use this function to start advertising : 

    GAPCentralRole_StartDiscovery( DEFAULT_DISCOVERY_MODE,
    DEFAULT_DISCOVERY_ACTIVE_SCAN,
    DEFAULT_DISCOVERY_WHITE_LIST );

    but on my sniffer i didn't see anything.

    Howerver when i'm using simpleBLEPeripheral, i can see advertising frame.

    I have also tried to use CC2540 with simpleBLECentral but no advertising frame on my sniffer but it works on simpleBLEPeripheral.

    I have check is the library selected is ok and it is.

    So i don't understand why it doesn't work.

    Thanks to help me,

    Anthony

  • Hi Anthony,

    GAPCentralRole_StartDiscovery is a function for a GAP Central Role device to start scanning (not advertising), essentially doing the same thing as the sniffer. To advertise from a simpleBLECentral you'd have to use functionality in peripheral.c (I am not sure how straight forward that should be).

    Best Regards.

  • OOOHH okay...

    thansks for your response.

    So if would like to use BLE for a remote to communicate with a dongle, the remote is the slave (with simpleBLEPeripheral) and the dongle is the master (with simpleBLECentral). It is a great configuration ?

    Because in this ocnfiguration, it's the dongle that can initiate the communication.

    In my case, i want that the remote initiate the communication.

    I'm explain :

    To deal with power saving on my remote, i think about this configuration :

    My remote (Central) go to scan mode and the dongle (peripheral) start advertising... (it's like a pairing process in RF4CE right ?? )

    So, in this case when i press a key on my remote, i want that the remote establish the link,send the key, keep the link until the user release the key, terminate the link.

    It is possible ?

    Because if i put my remote such as a peripheral and my dongle as Central, only the dongle can initiate the communication right ??

  • Hi Anthony,

    I just want to know if you have used your Keyfob as Central device or not. I'm facing hard time with my Keyfob in Central mode (SimpleBLECentral running on CC2540 Keyfob). The Scanning doesn't happen at all on my Keyfob. 

    Thanks,

    Arjun

  • Scanning was not working because of battery's low voltage. It is working now.