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.

about the key press activation

Hi,

 I currently use the keyfodemo application for my project. I need to know how I can activate the key pressing event automatically. Currently, I need to use the UUID FFE1 to identify the corresponding characteristic  handle and set the value (01) to the keyfob before the key press event is triggered. I need to set this value in the code so that I do not need to set this handle again from the BTool.  I have done some research in the codes (mainly in simplekey.c).  I found that the SK_KEYPRESSED_UUID is assigned wih the FFE1 in the simplekey.h.  However, I  cannot track further down about how I cam implement the function I want (i.e., the key pressing event is activated without setting it in BTool).

Please advise how. Thanks.

  • I've just successfully accomplished this with the SimpleBLEPeripheral application, but the technique should work with any of the applications which use the simple key service.

    Make these changes to your project to turn the simple key service on automatically after connection:

    simplekeys.h
    ============
    -->add this line:

    #define SK_AUTOSTART                  1


    simplekeys.c
    ============
    -->add this case section to the SK_SetParameter routine:

    case SK_AUTOSTART:
      // get the characteristic value handle of the simple key service
      gattAttribute_t *pAttr = GATTServApp_FindAttr(simplekeysAttrTbl,
                                                    GATT_NUM_ATTRS(simplekeysAttrTbl),
                                                    (uint8 *)&skConfig);
      if (pAttr != NULL)
      {
        // turn on the simple key service
        uint16 value = BUILD_UINT16(1, 0); // 01:00 turns on key service
        sk_WriteAttrCB(*((uint16*)pValue),
                       pAttr,
                       (uint8 *)&value,
                       sizeof(value),
                       0);
      }
      break;
        

    simpleBLEPeripheral.c
    =====================
    -->add these statements to the end of the "case GAPROLE_CONNECTED" section of the peripheralStateNotificationCB routine (just prior to the break statement):

    uint16 connHandle = 0;
    GAPRole_GetParameter(GAPROLE_CONNHANDLE, &connHandle);         
    SK_SetParameter(SK_AUTOSTART, sizeof(connHandle), &connHandle);

    That's it! I hope this helps.