/* **************************************************************************************** * @brief Handles the generic message Boot Report value send to APP. (after Read Request or Notification) *//** * * @param[in] msgid HOGPBH_BOOT_REPORT_IND * @param[in] param Pointer to the struct hogpbh_boot_report_ind * @param[in] dest_id TASK_APP * @param[in] src_id TASK_HOGPBH * * @return If the message was consumed or not. * @description * * This API is used to inform the application about the read Boot Keyboard Input Report * Characteristic value. * **************************************************************************************** */ int app_hogpbh_boot_report_ind_handler(ke_msg_id_t const msgid, struct hogpbh_boot_report_ind *param, ke_task_id_t const dest_id, ke_task_id_t const src_id) { uint8_t idx = KE_IDX_GET(src_id); switch (param->ind_type) { case HOGPBH_IND_RD_RSP: break; case HOGPBH_IND_NTF: if (param->char_code == HOGPBH_CHAR_BOOT_KB_IN_REPORT) { QPRINTF("HOGPBH Keyboard in report notification(%d):\r\n", param->hids_nb); QTRACE(param->report, param->report_length, 0, 2); QPRINTF("\r\n"); if (app_hogpbh_env[idx].cur_code == 2) { // Start Mouse Notify here app_hogpbh_cfg_ntf_req(HOGPBH_DESC_BOOT_MOUSE_IN_REPORT_CFG, PRF_CLI_START_NTF, app_hogpbh_env[idx].hids_mouse, param->conhdl); app_hogpbh_env[idx].cur_code = 0; } } else if (param->char_code == HOGPBH_CHAR_BOOT_MOUSE_IN_REPORT) { QPRINTF("HOGPBH Mouse in report notification(%d):\r\n", param->hids_nb); QTRACE(param->report, param->report_length, 0, 2); QPRINTF("\r\n"); } break; default: break; } return (KE_MSG_CONSUMED); }
/* **************************************************************************************** * @brief Handles the generic message Boot Mouse Input Report value send to APP * (after Read Request or Notification) . *//** * * @param[in] msgid HOGPRH_REPORT_IND * @param[in] param Pointer to the struct hogprh_report_ind * @param[in] dest_id TASK_APP * @param[in] src_id TASK_HOGPRH * * @return If the message was consumed or not. * @description * * This API is used to inform the application about the read Client Characteristic Configuration * Descriptor value. * * The following table present all the possible values for the ind_type parameter: * - HOGPRH_IND_NTF (0x00): The Report Characteristic value has been received has a * notification and the value is complete. * - HOGPRH_IND_RD_RSP (0x01): The Report Characteristic value has been received has a read * response. * - HOGPRH_IND_INCOMPLETE_NTF (0x02): The Report Characteristic value has been received has a * notification and the value is not complete. See the note below. * * @note * * Here is an extract of the BLE HIDS specification, * "Notification of characteristic values can contain at most [ATT_MTU-3] bytes of data by definition. Data beyond * [ATT_MTU-3] bytes long is not included in a notification, and must instead be read using the GATT Read Long * Characteristic Value sub-procedure. The possibility that data to be notified in a Report characteristic value could * change before the HID Host completed an outstanding Read Long Characteristic Value sub-procedure, and therefore be * lost, exists. For this reason it is strongly recommended that HID Devices support an ATT_MTU large enough to transfer * their largest possible Report characteristic value in a single transaction." * * Thus when an indication in received with an indication type set to HOGPRH_IND_INCOMPLETE_NTF, the application * can begin to parse this incomplete Report value. Then it must wait for another indication whose the indication type * will be set to HOGPRH_IND_RD_RSP and which will contain the whole Report Characteristic value (the first indication * can be discarded if needed). * **************************************************************************************** */ int app_hogprh_report_ind_handler(ke_msg_id_t const msgid, struct hogprh_report_ind *param, ke_task_id_t const dest_id, ke_task_id_t const src_id) { uint8_t idx = KE_IDX_GET(src_id); switch (param->ind_type) { case HOGPRH_IND_RD_RSP: QPRINTF("HOGPRH Read HIDS Report(%d).\r\n", param->hids_nb); QTRACE(param->report, param->report_length, 0, 2); QPRINTF("\r\n"); break; case HOGPRH_IND_NTF: QPRINTF("HOGPRH Notification(%d).\r\n", param->hids_nb); QTRACE(param->report, param->report_length, 0, 2); QPRINTF("\r\n"); if ((!app_hogprh_env[idx].cur_code) && (param->hids_nb+1 < app_hogprh_env[idx].hids_nb)) { // start notification app_hogprh_cfg_ntf_req(0, PRF_CLI_START_NTF, param->hids_nb+1, param->conhdl); /* 0 is our demo input report */ app_hogprh_env[idx].cur_code = 1; } break; default: break; } return (KE_MSG_CONSUMED); }
/* **************************************************************************************** * @brief Handles the generic message for read responses for APP. *//** * * @param[in] msgid BLPC_RD_CHAR_RSP * @param[in] param Pointer to struct blpc_rd_char_rsp * @param[in] dest_id TASK_APP * @param[in] src_id TASK_BLPC * @return If the message was consumed or not. * @description * * This API is used by the Collector role to inform the Application of a received read response. The * status and the data from the read response are passed directly to Application, which must interpret them based on * the request it made. **************************************************************************************** */ int app_blpc_rd_char_rsp_handler(ke_msg_id_t const msgid, struct blpc_rd_char_rsp *param, ke_task_id_t const dest_id, ke_task_id_t const src_id) { QPRINTF("BLPC read char response status: 0x%x.\r\n", param->status); QTRACE(param->data.data, param->data.len, 1, 2); QPRINTF("\r\n"); app_task_msg_hdl(msgid, param); return (KE_MSG_CONSUMED); }
/* **************************************************************************************** * @brief Handles the generic message for Send Read Report Map value to APP. *//** * * @param[in] msgid HOGPRH_REPORT_MAP_RD_RSP * @param[in] param Pointer to the struct hogprh_report_map_rd_rsp * @param[in] dest_id TASK_APP * @param[in] src_id TASK_HOGPRH * * @return If the message was consumed or not. * @description * * This API is used to inform the application about the read Report Map Characteristic value. * **************************************************************************************** */ int app_hogprh_report_map_rd_rsp_handler(ke_msg_id_t const msgid, struct hogprh_report_map_rd_rsp *param, ke_task_id_t const dest_id, ke_task_id_t const src_id) { QPRINTF("HOGPRH report map read response(%d):\r\n", param->hids_nb); QTRACE(param->report_map, param->report_map_length, 0, 2); QPRINTF("\r\n"); uint8_t idx = KE_IDX_GET(src_id); if (param->hids_nb+1 < app_hogprh_env[idx].hids_nb) { app_hogprh_rd_char_req(HOGPRH_RD_HIDS_REPORT_MAP, 0, param->hids_nb+1, param->conhdl); } else { app_hogprh_rd_char_req(HOGPRH_RD_HIDS_HID_INFO, 0, 0, param->conhdl); } return (KE_MSG_CONSUMED); }
/* **************************************************************************************** * @brief Handles the generic message for read responses for APP. *//** * * @param[in] msgid DISC_RD_CHAR_RSP * @param[in] param Pointer to struct disc_rd_char_rsp * @param[in] dest_id TASK_APP * @param[in] src_id TASK_DISC * @return If the message was consumed or not. * @description * * This API is used by the Client role to inform the Application of a * received read response. The status and the data from the read response are passed directly to * Application, which must interpret them based on the request it made. * **************************************************************************************** */ int app_disc_rd_char_rsp_handler(ke_msg_id_t const msgid, struct disc_rd_char_rsp *param, ke_task_id_t const dest_id, ke_task_id_t const src_id) { #if QN_DBG_TRACE_MORE QPRINTF("DISC read char response status: 0x%x code: 0x%x.\r\n", param->status, param->char_code); #endif switch (param->char_code) { case DISC_MANUFACTURER_NAME_CHAR: QPRINTF("MANUFACTURER NAME: "); QTRACE(param->val, param->val_length, 0, 0); break; case DISC_MODEL_NB_STR_CHAR: QPRINTF("MODEL NB: "); QTRACE(param->val, param->val_length, 0, 0); break; case DISC_SERIAL_NB_STR_CHAR: QPRINTF("SERIAL NB: "); QTRACE(param->val, param->val_length, 0, 0); break; case DISC_HARD_REV_STR_CHAR: QPRINTF("HARD REV: "); QTRACE(param->val, param->val_length, 0, 0); break; case DISC_FIRM_REV_STR_CHAR: QPRINTF("FIRM REV: "); QTRACE(param->val, param->val_length, 0, 0); break; case DISC_SW_REV_STR_CHAR: QPRINTF("SW REV: "); QTRACE(param->val, param->val_length, 0, 0); break; case DISC_SYSTEM_ID_CHAR: QPRINTF("SYSTEM ID: "); if (param->val_length) { for (uint8_t i = 0; i < param->val_length; i++) QPRINTF("%02x", param->val[i]); } break; case DISC_IEEE_CHAR: QPRINTF("IEEE CHAR: "); if (param->val_length) { for (uint8_t i = 0; i < param->val_length; i++) QPRINTF("%02x", param->val[i]); } break; case DISC_PNP_ID_CHAR: QPRINTF("PNP ID: "); if (param->val_length) { for (uint8_t i = 0; i < param->val_length; i++) QPRINTF("%02x", param->val[i]); } break; default: break; } QPRINTF("\r\n"); app_task_msg_hdl(msgid, param); return (KE_MSG_CONSUMED); }