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.

configuring HM-10 (cc2541) as a master

Other Parts Discussed in Thread: CC2541

Hi

I am a beginner in BLE. 

I want to configure HM-10 (having cc2541) as a master. For this I am referring to SimpleBLECentral. 

I want to have an additional functionality that if the master is connected to the slave an Led on P1_0 should glow.

If the master gets disconnected with the slave or if the master is not connected to the slave , the led on P1_0 should not glow.

Kindly provide me the exact lines of code reg this functionality and let me know where to place it in the existing code . Also, Let me know if any additional header files have to be included.

Let me know if there is any app on playstore (for android) to check the connection between master and slave configurations ( BLE HM-10 having cc2541).

Thanks

Ankur

  • Hello Ankur,

    Welcome to BLE! I would suggest you start with a TI development kit, such as the CC2541 MiniDK. After going through the SW examples in the SDK you can then develop for your HM-10. Details on TI Development kits can be found on the TI BLE Wiki.

    Best wishes
  • Hello

    Thanks for your response!!!

    I have a query regarding simpleBLEPeripheral. I am using it to configure cc2541 as a slave. Please let me know which function in simpleBLEPeripheral is used to check if the pairing from master side is a success or not.

    I want to switch on the buzzer on the slave side after the slave gets paired with master.

    Thanks

    Ankur

  • You should see GAPROLE_CONNECTED state in SimpleBLEPeripheral_processStateChangeEvt() when the connection is formed.
  • Hello

    I am putting my code under GAPROLE_CONNECTED state in "void peripheralStateNotificationCB( gaprole_States_t newState )" present in SimpleBLEPeripheral.c.

    The thing is that BLE goes into "GAPROLE_CONNECTED" when it receives a pairing request. I want to switch on the buzzer after the pairing is done and is successful.

    If the pairing is not successful, the buzzer should not be switched on.

    Thanks

    Ankur

  • You can add your application Pairing / Bonding state Callback in simpleBLEPeripheral_BondMgrCBs and process GAPBOND_PAIRING_STATE_COMPLETE event in it.

  • It would be great if you can provide any reference for this.

    Thanks

  • I don't have any reference for this. I trace into source code to know this. You could try to add callback to process GAPBOND_PAIRING_STATE_COMPLETE event to see if it works.
  • Hello

    I have written the callback function for for the same.

    static void simpleBLEPeripheralPairState(uint16 connHandle, uint8 state,uint8 status)
    {
      int i=0;
      if ( state == GAPBOND_PAIRING_STATE_STARTED )
      {
        //LCD_WRITE_STRING( "Pairing started", HAL_LCD_LINE_1 );
      }
      else if ( state == GAPBOND_PAIRING_STATE_COMPLETE )
      {
        if ( status == SUCCESS )
        {
          P1SEL = 0;
        P1DIR = 0xFF;
        P1 = 0x01;
        for(i=0;i<100;i++);
           

          //LCD_WRITE_STRING( "Pairing success", HAL_LCD_LINE_1 );
        }
        else
        {
          //LCD_WRITE_STRING_VALUE( "Pairing fail", status, 10, HAL_LCD_LINE_1 );
        }
      }
      else if ( state == GAPBOND_PAIRING_STATE_BONDED )
      {
        if ( status == SUCCESS )
        {
          //LCD_WRITE_STRING( "Bonding success", HAL_LCD_LINE_1 );
        }
      }
    }

    When I am in debug mode and I place a breakpoint at " if ( status == SUCCESS ) ", then doing the step by step execution, I can see the LED glowing. But without the breakpoint, I cannot see the LED glowing...... Is it something to do with delays?

    I have disabled the HAL_LED in my code.

    Kindly, help me on this.

  • Hello

    I need a clarification with respect to sensor tag application......

    I want to modify the application such that when ever I wish to read the pressure, a LED should glow irrespective of whether the pressure sensor is connected to the pins or not. 

    Please let me know what modifications have to be done and on which files.

    Thanks

    Ankur

  • Hi Ankur,

    Unfortunately we cannot provide the exact code modifications required for you to realize your end use case. It will be most helpful in the long run for us to help you understand the code ecosystem and then guide you to make the changes that you need.

    Since you are new to BLE, I would recommend reading the Software Developer's Guide. This document can be found in the documents folder of the SDK install and will cover some things that you have already asked about such as GAPBOND_PAIRING_STATE_COMPLETE and the pairing process.
  • 1. If you want to blink LED, I suggest you to use LED blink API in hal_led.c instead a for loop in your code.
    2. To glow a LED, you can use the same API when you start to read Pressure sensor.