그런데 저는 이런 기능이 1개 있으면 좋겠다는 생각에 BLE가 연결되고 끊어지는 부분을 여기저기 찾아봐서 알아 냈습니다.
동작은 잘 되더군요.
먼저 연결되는 부분은 다음과 같습니다.
app_sps_device_project.c 의 
void app_connection_func(struct gapc_connection_req_ind const *param)
{ 
    /*--------------------------------------------------------------
    * ENABLE REQUIRED PROFILES
    *-------------------------------------------------------------*/
    //enable SPS device role or SPS host and set the proper values
    app_sps_enable(); 
    gattc_exc_mtu_cmd();
  GPIO_SetActive(BLE_CON_PORT,BLE_CON_PIN);     // LED ON
  GPIO_SetInactive(BLE_CON1_PORT,BLE_CON1_PIN);  // CON PORT LOW
}
그 담으로 끊어지는 부분은 다음과 같습니다.
app_sps_device_project.c 의 
void app_disconnect_func(ke_task_id_t task_id, struct gapc_disconnect_ind const *param)
{
    uint8_t state = ke_state_get(task_id);
   GPIO_SetInactive(BLE_CON_PORT,BLE_CON_PIN);   // LED OFF
   GPIO_SetActive(BLE_CON1_PORT,BLE_CON1_PIN);  // CON PORT HIGH
   if ((state == APP_SECURITY) || (state == APP_CONNECTED)  || (state == APP_PARAM_UPD))
    { 
        // Restart Advertising
        app_adv_start();
    }
    else
    {
        // We are not in a Connected State
        ASSERT_ERR(0);
    }
}
이렇게 하면 연결되면 CON Port가 High가 되고, 끊어지면 Con Port가 LOW 가 되서 외부 MCU에서 확인을 하고 BLE로 송수신을 할 수 있습니다.
댓글 없음:
댓글 쓰기