Пример #1
0
/**
 ****************************************************************************************
 * @brief Send stored measure value, if no data to send, will disconnect
 ****************************************************************************************
 */
void app_send_stored_meas(void)
{
    if(usr_env.is_temp_meas_config)
    {
        struct htp_temp_meas temp_meas;

        // if not empty, send the indication
        if(app_store_meas_fifo_out(&temp_meas))
        {
            usr_env.is_meas_send_busy = true;
            app_htpt_temp_send(app_htpt_env->conhdl, &temp_meas, TEMPERATURE_MEASUREMENT);
        }
        else
        {
            // there are two place to disconnect, one is idle connection timeout,
            // the other is temperature measure send complete
            usr_env.is_meas_send_busy = false; // set measure send complete
            if(usr_env.is_idle_connection_overtime && !usr_env.is_imeas_send_busy) // idle connection timeout
            {
                QPRINTF("Force disconnect\r\n");
                app_gap_discon_req(app_htpt_env->conhdl);
            }
        }
    }
}
Пример #2
0
/**
 ****************************************************************************************
 * @brief idle connection timeout timer event.
 *
 * @param[in] msgid     APP_HTPT_IDLE_CONNECTION_TIMEOUT_TIMER
 * @param[in] param     None
 * @param[in] dest_id   TASK_APP
 * @param[in] src_id    TASK_APP
 *
 * @return If the message was consumed or not.
 * @description
 ****************************************************************************************
 */
int app_htpt_idle_connection_timeout_timer_handler(ke_msg_id_t const msgid, void const *param, ke_task_id_t
                                                   const dest_id, ke_task_id_t const src_id)
{
    // there are two place to disconnect, one is idle connection timeout,
    // the other is temperature measure send complete
    usr_env.is_idle_connection_overtime = true;

    QPRINTF("idle connection timeout\r\n");

    if(!usr_env.is_meas_send_busy && !usr_env.is_imeas_send_busy)
    {
        QPRINTF("Force disconnect\r\n");
        app_gap_discon_req(app_htpt_env->conhdl);
    }
    return (KE_MSG_CONSUMED);
}
Пример #3
0
/*
****************************************************************************************
* @brief             ble_discon
* @param[in]         pcCommandString            ÃüÁîºÍ²ÎÊý´æ·ÅµØÖ·
* @param[in]         pcWriteBuffer              дÈë´ËÊý×éµÄÃüÁ±»·¢Ë͵½´®¿Ú
* @param[in]         commpare_length            ÃüÁîËùÕ¼³¤¶È
* @return            None
* @description       ¶Ï¿ªµ±Ç°Á¬½Ó£¬ÃüÁî¸ñʽ£ºAT+DISCON
*****************************************************************************************/
int ble_discon( const uint8_t * const pcCommandString,uint8_t* pcWriteBuffer,uint32_t commpare_length)
{
	app_gap_discon_req(0);
	return sprintf((char*)pcWriteBuffer,"OK\r\n");
}