on 2021-12-20 12:43 AM
app_conf.h |
/** * Define IO Authentication */ #define CFG_BONDING_MODE (1) #define CFG_FIXED_PIN (111111) #define CFG_USED_FIXED_PIN (0) #define CFG_ENCRYPTION_KEY_SIZE_MAX (16) #define CFG_ENCRYPTION_KEY_SIZE_MIN (8) /** |
/* Define IO capabilities */ #define CFG_IO_CAPABILITY_DISPLAY_ONLY (0x00) #define CFG_IO_CAPABILITY_DISPLAY_YES_NO (0x01) #define CFG_IO_CAPABILITY_KEYBOARD_ONLY (0x02) #define CFG_IO_CAPABILITY_NO_INPUT_NO_OUTPUT (0x03) #define CFG_IO_CAPABILITY_KEYBOARD_DISPLAY (0x04) #define CFG_IO_CAPABILITY CFG_IO_CAPABILITY_DISPLAY_YES_NO |
/** * Define MITM modes */ #define CFG_MITM_PROTECTION_NOT_REQUIRED (0x00) #define CFG_MITM_PROTECTION_REQUIRED (0x01) #define CFG_MITM_PROTECTION CFG_MITM_PROTECTION_REQUIRED |
/** * Define Keypress Notification Support */ #define CFG_KEYPRESS_NOT_SUPPORTED (0x00) #define CFG_KEYPRESS_SUPPORTED (0x01) #define CFG_KEYPRESS_NOTIFICATION_SUPPORT CFG_KEYPRESS_NOT_SUPPORTED /** * Numeric Comparison Answers */ #define YES (0x01) #define NO (0x00) |
app_entry.c | app_ble.c |
/* USER CODE BEGIN FD_WRAP_FUNCTIONS */ void HAL_GPIO_EXTI_Callback( uint16_t GPIO_Pin ) { switch (GPIO_Pin) { case BUTTON_SW1_PIN: APP_BLE_Key_Button1_Action(); /* SW1 begins connection process */ break; case BUTTON_SW2_PIN: APP_BLE_Key_Button2_Action(); break; case BUTTON_SW3_PIN: APP_BLE_Key_Button3_Action(); /*SW3 initiates pairing process */ break; default: break; } return; } | /* USER CODE BEGIN FD*/ void APP_BLE_Key_Button1_Action(void) { P2PS_APP_SW1_Button_Action(); } void APP_BLE_Key_Button2_Action(void) { #if (L2CAP_REQUEST_NEW_CONN_PARAM != 0 ) UTIL_SEQ_SetTask( 1<<CFG_TASK_CONN_UPDATE_REG_ID, CFG_SCH_PRIO_0); #endif return; } void APP_BLE_Key_Button3_Action(void) { /* Request Pairing */ aci_gap_slave_security_req(BleApplicationContext.BleApplicationContext_legacy.connectionHandle); } /* USER CODE END FD*/ |
/* USER CODE BEGIN APP_BLE_Init_2 */ (void) aci_gap_clear_security_db(); /* clear all existing security settings each new reset */ /* USER CODE END APP_BLE_Init_2 */ |
app_ble.c |
case EVT_LE_CONN_COMPLETE: |
case (EVT_BLUE_GAP_NUMERIC_COMPARISON_VALUE): |
case (EVT_BLUE_GAP_PAIRING_CMPLT): |
app_ble.c | comment |
case EVT_DISCONN_COMPLETE: { hci_disconnection_complete_event_rp0 *disconnection_complete_event; disconnection_complete_event = (hci_disconnection_complete_event_rp0 *) event_pckt->data; if (disconnection_complete_event->Connection_Handle == BleApplicationContext.BleApplicationContext_legacy.connectionHandle) { BleApplicationContext.BleApplicationContext_legacy.connectionHandle = 0; BleApplicationContext.Device_Connection_Status = APP_BLE_IDLE; APP_DBG_MSG("\r\n\r** DISCONNECTION EVENT WITH CLIENT \n"); } /* restart advertising */ /* Adv_Request(APP_BLE_FAST_ADV);*/ /*ST Do not restart advertising*/ /** * SPECIFIC to P2P Server APP */ handleNotification.P2P_Evt_Opcode = PEER_DISCON_HANDLE_EVT; handleNotification.ConnectionHandle = BleApplicationContext.BleApplicationContext_legacy.connectionHandle; P2PS_APP_Notification(&handleNotification); /* USER CODE BEGIN EVT_DISCONN_COMPLETE */ aci_gap_configure_whitelist(); /* ST store the whitelist on disconnect */ /*Allow Scan Request from White List Only, Allow Connect Request from */ /* */ /*White List Only*/ APP_DBG_MSG("\r\n\r** WHITELIST Executed \n"); aci_gap_set_undirected_connectable(CFG_FAST_CONN_ADV_INTERVAL_MIN, CFG_FAST_CONN_ADV_INTERVAL_MAX, PUBLIC_ADDR, 0x03); APP_DBG_MSG("\r\n\r** NEW ADVERTISING STARTED AFTER WHITELIST \n"); /* 0x03 is the white list filter value */ /* Adv_Request(APP_BLE_FAST_ADV);*/ | Disconnect A B C D |