Example #1
0
void app_push(struct ke_msg *msg)
{
    // Push the message into the list of messages pending for transmission
    co_list_push_back(&com_env.queue_rx, &msg->hdr);
    QPRINTF("\r\n@@@app_push:");
    for (uint8_t i = 0; i<msg->param_len; i++)
        QPRINTF("%c",((uint8_t *)&msg->param)[i]);
    QPRINTF("\r\n");
	
		//only send in the first push.
		uint8_t *p_data = (uint8_t *)msg->param;
		uint8_t pack_nb = msg->param_len/QPP_DATA_MAX_LEN + 1;
		uint8_t pack_divide_len =  msg->param_len%QPP_DATA_MAX_LEN;
		for (uint8_t char_idx = 0,i = 0;((app_qpps_env->char_status & (~(QPPS_VALUE_NTF_CFG << (char_idx - 1) ))) && (char_idx < QPPS_VAL_CHAR_NUM ));char_idx++)
		{
			if (i < (pack_nb - 1))
			{
				app_qpps_env->char_status &= ~(QPPS_VALUE_NTF_CFG << char_idx);
				app_qpps_data_send(app_qpps_env->conhdl,char_idx,QPP_DATA_MAX_LEN,(uint8_t *)p_data);
				p_data += QPP_DATA_MAX_LEN;
			}
			else
			{
				if ((pack_divide_len != 0) && (i == (pack_nb - 1)))
				{
					app_qpps_env->char_status &= ~(QPPS_VALUE_NTF_CFG << char_idx);
					app_qpps_data_send(app_qpps_env->conhdl,char_idx,pack_divide_len,(uint8_t *)p_data);
					p_data += pack_divide_len;
				}
			}
			i++;
		}
}
/*
 ****************************************************************************************
 * @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);
}
Example #3
0
/*
 ****************************************************************************************
 * @brief Received Current Time value sent to APP (Read Response or Notification). *//**
 *
 * @param[in] msgid     TIPC_CT_IND
 * @param[in] param     Pointer to struct tipc_ct_ind
 * @param[in] dest_id   TASK_APP
 * @param[in] src_id    TASK_TIPC
 * @return If the message was consumed or not.
 * @description
 *
 *  This API is used by the Client role to inform the Application of a received current time 
 *  value. The ind_type parameter informs the application if the value has been notified by the 
 *  Time Client or if it has been received as a read response. 
 *
 ****************************************************************************************
 */
int app_tipc_ct_ind_handler(ke_msg_id_t const msgid,
                      struct tipc_ct_ind *param,
                      ke_task_id_t const dest_id,
                      ke_task_id_t const src_id)
{
    QPRINTF("TIPC Current Time indication(%d): Adjust Reason: %d, Fraction: %d, Day/Week: %d.\r\n", 
        param->ind_type,
        param->ct_val.adjust_reason,
        param->ct_val.exact_time_256.fraction_256,    ///n * (1/256th) of a second
        param->ct_val.exact_time_256.day_date_time.day_of_week
        );

#if QN_DBG_TRACE_MORE
    QPRINTF("Date: %04d:%02d:%02d Time: %02d:%02d:%02d\r\n", 
        param->ct_val.exact_time_256.day_date_time.date_time.year,
        param->ct_val.exact_time_256.day_date_time.date_time.month,
        param->ct_val.exact_time_256.day_date_time.date_time.day,
        param->ct_val.exact_time_256.day_date_time.date_time.hour,
        param->ct_val.exact_time_256.day_date_time.date_time.min,
        param->ct_val.exact_time_256.day_date_time.date_time.sec
        );
#endif
    app_task_msg_hdl(msgid, param);

    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);
}
Example #5
0
/*
 ****************************************************************************************
 * @brief Handles the complete event from TASK_RSCPC. *//**
 *
 * @param[in] msgid     RSCPC_CMP_EVT
 * @param[in] param     Pointer to struct rscpc_cmp_evt
 * @param[in] dest_id   TASK_APP
 * @param[in] src_id    TASK_RSCPC
 * @return If the message was consumed or not.
 * @description
 *
 * This handler is used to inform the sender of a command that the procedure is over and 
 * contains the status of the procedure.
 *
 ****************************************************************************************
 */
int app_rscpc_cmp_evt_handler(ke_msg_id_t const msgid,
                              struct rscpc_cmp_evt *param,
                              ke_task_id_t const dest_id,
                              ke_task_id_t const src_id)
{
    switch (param->operation)
    {
        case RSCPC_ENABLE_OP_CODE:
            if (param->status == PRF_ERR_OK)
            {
                QPRINTF("Enable complete\r\n");
            }
            else
            {
                QPRINTF("Enable failed %d\r\n", param->status);
            }
            break;
        case RSCPC_READ_OP_CODE:
            QPRINTF("Read procedure complete, result is %d\r\n", param->status);
            break;
        case RSCPC_CFG_NTF_IND_OP_CODE:
            QPRINTF("Configure procedure complete, result is %d\r\n", param->status);
            break;
        case RSCPC_CTNL_PT_CFG_WR_OP_CODE:
            QPRINTF("Ctrl procedure complete, result is %d\r\n", param->status);
            break;
        default:
            break;
    }
    app_task_msg_hdl(msgid, param);

    return (KE_MSG_CONSUMED);
}
Example #6
0
void free_notic_info_timer(unsigned short const msgid)
{
	unsigned int start_time=0,end_time=0;
	unsigned int current_time=0;

	QPRINTF("==free notice count\r\n");
	if((++free_notic_info.count_time) >= free_notic_info.time)
	{
		/*1.clear count time */
		free_notic_info.count_time = 0;
		/*2.motor open */
		if(free_notic_info.free_enable)
		{
			s_tm ltime = {0};
			system_time_get(&ltime);
			current_time = 60*ltime.hour + ltime.minute;
			start_time = free_notic_info.start_time_hour*60 +
						 free_notic_info.start_time_minute;
			end_time   = free_notic_info.end_time_hour*60 + 
						 free_notic_info.end_time_minute;
			
			if((start_time <= current_time) && (current_time < end_time))
			{
				QPRINTF(" free notic : motor turn on \r\n");
			}
		}
	}
	ke_timer_set(USR_FREE_NOTICE_INFO_TIMER, 60*100);

}
Example #7
0
/*
 ****************************************************************************************
 * @brief Handles Indicate that an attribute value has been received either upon notification
 *        or read response. *//**
 *
 * @param[in] msgid     PASPC_VALUE_IND
 * @param[in] param     Pointer to struct paspc_value_ind
 * @param[in] dest_id   TASK_APP
 * @param[in] src_id    TASK_PASPC
 * @return If the message was consumed or not.
 * @description
 *
 * This handler is sent to the application once an attribute value has been received from
 * the peer device upon a notification or a read response message. The content of the value
 * parameter depends of the attribute code value which defines the attribute that has been
 * updated
 *
 ****************************************************************************************
 */
int app_paspc_val_ind_handler(ke_msg_id_t const msgid,
                              struct paspc_value_ind *param,
                              ke_task_id_t const dest_id,
                              ke_task_id_t const src_id)
{
    uint8_t att_code = param->att_code;
    switch (att_code)
    {
        case PASPC_RD_ALERT_STATUS:
            QPRINTF("Alert Status characteristic value: %d%.\r\n",
                     param->value.alert_status);
            break;

        case PASPC_RD_RINGER_SETTING:
            QPRINTF("PAS Ringer Setting: %d%.\r\n",
                     param->value.ringer_setting);
            break;

        case PASPC_RD_WR_ALERT_STATUS_CFG:
            QPRINTF("PAS Alert Status Client Characteristic Configuration Descriptor: %d%.\r\n",
                     param->value.alert_status_ntf_cfg);
            break;

        case PASPC_RD_WR_RINGER_SETTING_CFG:
            QPRINTF("PAS Ringer Setting Client Characteristic Configuration Descriptor: %d%.\r\n",
                     param->value.ringer_setting_ntf_cfg);
            break;

        default:
            break;
    }
    app_task_msg_hdl(msgid, param);
    
    return (KE_MSG_CONSUMED);
}
/*
 ****************************************************************************************
 * @brief Handles the generic message for read responses for APP. *//**
 *
 * @param[in] msgid     HTPC_RD_CHAR_RSP
 * @param[in] param     Pointer to struct htpc_rd_char_rsp
 * @param[in] dest_id   TASK_APP
 * @param[in] src_id    TASK_HTPC
 * @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_htpc_rd_char_rsp_handler(ke_msg_id_t const msgid,
                      struct htpc_rd_char_rsp *param,
                      ke_task_id_t const dest_id,
                      ke_task_id_t const src_id)
{
    QPRINTF("HTPC read char response status: 0x%x code: 0x%X.\r\n",
        param->status,
        param->att_code);

    if (param->att_code == HTPC_CHAR_HTS_MEAS_INTV)
    {
        QPRINTF("MEAS INTV: ");
        if (param->data.len == 0)
        {
            QPRINTF("NULL");
        }
        else
        {
            for (uint8_t i = 0; i < param->data.len; i++)
                QPRINTF("%x", param->data.data[param->data.len-i-1]);
        }
        QPRINTF("s\r\n");
    }
    app_task_msg_hdl(msgid, param);

    return (KE_MSG_CONSUMED);
}
Example #9
0
void dev_send_to_app(struct app_uart_data_ind *param)
{
    uint8_t *buf_20;
    int16_t len = param->len;
    int16_t send_len = 0;
	
		uint8_t packet_len = get_bit_num(app_qpps_env->char_status)*20;
#ifdef	CATCH_LOG
    QPRINTF("\r\n@@@len %d\r\n@@@data\r\n",len);

    for(uint8_t j = 0; j<len; j++)
        QPRINTF("%c",param->data[j]);
    QPRINTF("\r\n");
#endif
    if(app_qpps_env->char_status)
    {
        for(uint8_t i =0; send_len < len; i++)
        {
            if (len > packet_len) //Split data into package when len longger than 20
            {
                if (len - send_len > packet_len)	
                {
                    buf_20 = (uint8_t*)ke_msg_alloc(0, 0, 0, packet_len);
                    if(buf_20 != NULL)
                    {
                        memcpy(buf_20,param->data+send_len,packet_len);
                        send_len+=packet_len;
                    }
                }
                else
                {
                    buf_20 = (uint8_t *)ke_msg_alloc(0,0,0,len-send_len);
                    if (buf_20 != NULL)
                    {
                        memcpy(buf_20,param->data+send_len,len-send_len);
                        send_len = len;
                    }
                }
            }
            else	//not longger ther 20 send data directely
            {
								buf_20 = (uint8_t *)ke_msg_alloc(0,0,0,len);
								if (buf_20 != NULL)
								{
										memcpy(buf_20,param->data,len);
										send_len = len;
								}
                //app_qpps_data_send(app_qpps_env->conhdl,0,len,param->data);
            }
						//push the package to kernel queue.
						app_push(ke_param2msg(buf_20));
				}
    }
}
Example #10
0
/*
 ****************************************************************************************
 * @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);
}
Example #11
0
/*
 ****************************************************************************************
 * @brief Accept and process of the Data Source notification. *//**
 *
 * @param[in] msgid     ANCSC_DATA_SOURCE_IND
 * @param[in] param     Pointer to struct ancsc_data_source_ind
 * @param[in] dest_id   TASK_APP
 * @param[in] src_id    TASK_ANCSC
 * @return If the message was consumed or not.
 * @description
 *
 * This handler is called once a Data Source value has been received from the peer device 
 * upon a notification operation. If the value is larger than the 20 bytes, it is split into 
 * multiple fragments by the NP. The NC must recompose the value by splicing each fragment.
 * The value is complete when the complete tuples for each requested attribute has been received.
 *
 ****************************************************************************************
 */
int app_ancsc_data_source_ind_handler(ke_msg_id_t const msgid,
                                      struct ancsc_data_source_ind *param,
                                      ke_task_id_t const dest_id,
                                      ke_task_id_t const src_id)
{
    QPRINTF("Data Size: %d\r\n", param->data_size);

    for (uint8_t i = 0; i < param->data_size; i++)
        QPRINTF("%02x", param->data_source[i]);
    QPRINTF("\r\n");

    return (KE_MSG_CONSUMED);
}
Example #12
0
void show_com_mode(uint8_t com_mode)
{
	QPRINTF("\r\n/*******************************");
	QPRINTF("\r\n *                             *");
	switch(com_mode)
	{
		case	COM_MODE_IDLE	:
		{
			QPRINTF("\r\n *       COM_MODE_IDLE         *");
			break;
		}
		case	COM_MODE_TRAN	:
		{
			QPRINTF("\r\n *       COM_MODE_TRAN         *");
			break;
		}
		case	COM_MODE_AT	:
		{
			QPRINTF("\r\n *        COM_MODE_AT          *");
			break;
		}
		default	:
			QPRINTF("\r\n *      COM_MODE_UNKNOWN        *");
			break;
	}
	QPRINTF("\r\n *                             *");
	QPRINTF("\r\n********************************/\r\n");
}
Example #13
0
int
wstsc_dma_xfer_out(struct sci_softc *dev, int len, register u_char *buf,
                   int phase)
{
	int wait = sci_data_wait;
	volatile register u_char *sci_dma = dev->sci_data;
	volatile register u_char *sci_csr = dev->sci_csr;

	QPRINTF(("supradma_out %d, csr=%02x\n", len, *dev->sci_bus_csr));

	QPRINTF(("supradma_out {%d} %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
  	 len, buf[0], buf[1], buf[2], buf[3], buf[4], buf[5],
	 buf[6], buf[7], buf[8], buf[9]));

	*dev->sci_tcmd = phase;
	*dev->sci_mode = SCI_MODE_DMA;
	*dev->sci_icmd = SCI_ICMD_DATA;
	*dev->sci_dma_send = 0;
	while (len > 0) {
		wait = sci_data_wait;
		while ((*sci_csr & (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) !=
		  (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) {
			if (!(*sci_csr & SCI_CSR_PHASE_MATCH)
			  || !(*dev->sci_bus_csr & SCI_BUS_BSY)
			  || --wait < 0) {
#ifdef DEBUG
				if (sci_debug)
					printf("supradma_out fail: l%d i%x w%d\n",
					len, *dev->sci_bus_csr, wait);
#endif
				*dev->sci_mode = 0;
				return 0;
			}
		}

		*sci_dma = *buf++;
		len--;
	}

	wait = sci_data_wait;
	while ((*sci_csr & (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) ==
	  SCI_CSR_PHASE_MATCH && --wait);


	*dev->sci_mode = 0;
	*dev->sci_icmd = 0;
	return 0;
}
Example #14
0
/**
 ****************************************************************************************
 * @brief   whether intermediate temperature is stable.
 * User may overwrite this function to ensure the temperature is stable.
 ****************************************************************************************
 */
bool app_is_interm_temp_stable(int32_t itemp_x10)
{
    int32_t diff;

    if(itemp_x10 > usr_env.imeas.max)
    {
        usr_env.imeas.max = itemp_x10;
    }
    else if(itemp_x10 < usr_env.imeas.min)
    {
        usr_env.imeas.min = itemp_x10;
    }

    diff = usr_env.imeas.max - usr_env.imeas.min;

    if(diff > 0 && diff < HTPT_INTERM_MEAS_STABLE_TOLERABLE_LIMIT)
    {
        ++usr_env.imeas.stable_counter;
    }
    else
    {
        usr_env.imeas.stable_counter = 0;
    }

    if(usr_env.imeas.stable_counter > HTPT_INTERM_MEAS_STABLE_COUNTER_MAX)
    {
        QPRINTF("intermediate temperature is stable\r\n");
        return true;
    }
    else
        return false;
}
Example #15
0
/*
 ****************************************************************************************
 * @brief Accept and process of the Notification Source notification. *//**
 *
 * @param[in] msgid     ANCSC_NTF_SOURCE_IND
 * @param[in] param     Pointer to struct ancsc_ntf_source_ind
 * @param[in] dest_id   TASK_APP
 * @param[in] src_id    TASK_ANCSC
 * @return If the message was consumed or not.
 * @description
 *
 * This handler is called once a Notification Source value has been received from the peer device 
 * upon a notification operation.
 *
 ****************************************************************************************
 */
int app_ancsc_ntf_source_ind_handler(ke_msg_id_t const msgid,
                                     struct ancsc_ntf_source_ind *param,
                                     ke_task_id_t const dest_id,
                                     ke_task_id_t const src_id)
{
    //uint8_t idx = KE_IDX_GET(src_id);

    QPRINTF("EventID: %d, EventFlags: %d, CategoryID: %d, count: %d, NotificationUID: %d\r\n", 
                    param->ntf_source.event_id, 
                    param->ntf_source.event_flags,
                    param->ntf_source.category_id, 
                    param->ntf_source.category_count,
                    param->ntf_source.ntf_uid);

    if (param->ntf_source.event_id == NOTIFICATION_ADDED)
    {
        app_ancsc_env->ntf_uid = param->ntf_source.ntf_uid;

        uint8_t cmd[] = {0x00/* AttributeIDAppIdentifier */,
                         0x01/* AttributeIDTitle */, 0x20, 0x00,
                         0x03/* AttributeIDMessage */, 0x20, 0x00};
        app_ancsc_get_ntf_attribute_req(param->ntf_source.ntf_uid, sizeof(cmd), cmd, param->conhdl);
    }

    return (KE_MSG_CONSUMED);
}
Example #16
0
/*
 * select the bus, return when selected or error.
 */
int
sciselectbus(struct sci_softc *dev, u_char target, u_char our_addr)
{
	register int timeo = 2500;

	QPRINTF (("sciselectbus %d\n", target));

	/* if we're already selected, return */
	if (dev->sc_flags & SCI_SELECTED)	/* XXXX */
		return 1;

	if ((*dev->sci_bus_csr & (SCI_BUS_BSY|SCI_BUS_SEL)) &&
	    (*dev->sci_bus_csr & (SCI_BUS_BSY|SCI_BUS_SEL)) &&
	    (*dev->sci_bus_csr & (SCI_BUS_BSY|SCI_BUS_SEL)))
		return 1;

	*dev->sci_tcmd = 0;
	*dev->sci_odata = 0x80 + (1 << target);
	*dev->sci_icmd = SCI_ICMD_DATA|SCI_ICMD_SEL;
	while ((*dev->sci_bus_csr & SCI_BUS_BSY) == 0) {
		if (--timeo > 0) {
			delay(100);
		} else {
			break;
		}
	}
	if (timeo) {
		*dev->sci_icmd = 0;
		dev->sc_flags |= SCI_SELECTED;
		return (0);
	}
	*dev->sci_icmd = 0;
	return (1);
}
Example #17
0
void
sci_scsidone(struct sci_softc *dev, int stat)
{
	struct scsipi_xfer *xs;

	xs = dev->sc_xs;
#ifdef DIAGNOSTIC
	if (xs == NULL)
		panic("sci_scsidone");
#endif
	xs->status = stat;
	if (stat == 0)
		xs->resid = 0;
	else {
		switch(stat) {
		case SCSI_CHECK:
			xs->resid = 0;
			/* FALLTHROUGH */
		case SCSI_BUSY:
			xs->error = XS_BUSY;
			break;
		default:
			xs->error = XS_DRIVER_STUFFUP;
			QPRINTF(("sci_scsicmd() bad %x\n", stat));
			break;
		}
	}

	scsipi_done(xs);

}
Example #18
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);
}
Example #19
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);
            }
        }
    }
}
Example #20
0
void
sci_ixfer_in(struct sci_softc *dev, int len, register u_char *buf, int phase)
{
	int wait = sci_data_wait;
	u_char csr;
	volatile register u_char *sci_bus_csr = dev->sci_bus_csr;
	volatile register u_char *sci_data = dev->sci_data;
	volatile register u_char *sci_icmd = dev->sci_icmd;
#ifdef DEBUG
	u_char *obp = buf;
#endif

	csr = *sci_bus_csr;

	QPRINTF(("sci_ixfer_in %d, csr=%02x\n", len, csr));

	*dev->sci_tcmd = phase;
	*sci_icmd = 0;
	for (;len > 0; len--) {
		csr = *sci_bus_csr;
		while (!(csr & SCI_BUS_REQ)) {
			if (!(csr & SCI_BUS_BSY) || --wait < 0) {
#ifdef DEBUG
				if (sci_debug)
					printf("sci_ixfer_in fail: l%d i%x w%d\n",
					len, csr, wait);
#endif
				return;
			}

			delay(1);
			csr = *sci_bus_csr;
		}

		if (!(*dev->sci_csr & SCI_CSR_PHASE_MATCH))
			break;
		*buf = *sci_data;
		*sci_icmd = SCI_ICMD_ACK;
		buf++;
		while (*sci_bus_csr & SCI_BUS_REQ);
		*sci_icmd = 0;
	}

	QPRINTF(("sci_ixfer_in {%d} %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
	  len, obp[0], obp[1], obp[2], obp[3], obp[4], obp[5],
	  obp[6], obp[7], obp[8], obp[9]));
}
Example #21
0
void app_com_at_command_handler(void)
{
#ifdef CATCH_LOG
		QPRINTF("\r\n at_process_command:\r\n");

		for(uint8_t i = 0;i < com_env.com_at_len+1;i++)
			QPRINTF("0x%02x ",com_env.com_at_buf[i]);
#endif
	
    //AT Comand length is more than 3
    if(com_env.com_at_len >= 3)
    {
        // if it's start with "AT"
        if(com_env.com_at_buf[0] == 'A' && com_env.com_at_buf[1] == 'T')
        {
            //Test if Enter the AT mode
            if(com_env.com_at_len == 3)
            {
                com_pdu_send(sprintf((char *)at_command_return,"OK\r\n"),at_command_return);
            }
            else
            {
                //if it's a AT Command ,send it to at_process_command process.
                if(com_env.com_at_buf[2] == '+')
                {
                    com_env.com_at_buf[com_env.com_at_len-1] = '\0';
                    com_pdu_send(at_process_command(com_env.com_at_buf + 2,at_command_return),at_command_return);
                }
                else
                {
                    com_pdu_send(sprintf((char *)at_command_return,"AT ERR\r\n"),at_command_return);
                }
            }
        }
        else
        {
            com_pdu_send(sprintf((char *)at_command_return,"AT ERR\r\n"),at_command_return);
        }
    }
    else
    {
        com_pdu_send(sprintf((char *)at_command_return,"AT ERR\r\n"),at_command_return);
    }
    //receive continue
    com_uart_at_rx_start();
    ke_evt_clear(1UL << EVENT_AT_COMMAND_PROC_ID);
}
Example #22
0
/*
 ****************************************************************************************
 * @brief Handles the error indication from the HTPT.       *//**
 *
 * @param[in] msgid     HTPT_ERROR_IND
 * @param[in] param     Pointer to the struct prf_server_error_ind
 * @param[in] dest_id   TASK_APP
 * @param[in] src_id    TASK_HTPT
 *
 * @return If the message was consumed or not.
 * @description
 * This handler is to inform the Application of an occurred error.
 ****************************************************************************************
 */
int app_htpt_error_ind_handler(ke_msg_id_t const msgid,
                               struct prf_server_error_ind *param,
                               ke_task_id_t const dest_id,
                               ke_task_id_t const src_id)
{
    QPRINTF("HTPT error indication.\r\n");
    return (KE_MSG_CONSUMED);
}
Example #23
0
/*
 ****************************************************************************************
 * @brief Handles the control point indication message      *//**
 *
 * @param[in] msgid     HOGPD_CTNL_PT_IND
 * @param[in] param     Pointer to the struct hogpd_ctnl_pt_ind
 * @param[in] dest_id   TASK_APP
 * @param[in] src_id    TASK_HOGPD
 *
 * @return If the message was consumed or not.
 * @description
 * This handler will be called each time the host enables or disables sending of notifications 
 * for characteristic.
 ****************************************************************************************
 */
int app_hogpd_ctnl_pt_ind_handler(ke_msg_id_t const msgid,
                                  struct hogpd_ctnl_pt_ind *param,
                                  ke_task_id_t const dest_id,
                                  ke_task_id_t const src_id)
{
    QPRINTF("HOGPD receive instance(%d) control point %d.\r\n", param->hids_nb, param->hid_ctnl_pt);
    return (KE_MSG_CONSUMED);
}
Example #24
0
/*
 ****************************************************************************************
 * @brief Handles read request response message from the HOGPBH. *//**
 *
 * @param[in] msgid     HOGPBH_RD_CHAR_ERR_RSP 
 * @param[in] param     Pointer to the struct hogpbh_char_req_rsp
 * @param[in] dest_id   TASK_APP
 * @param[in] src_id    TASK_HOGPBH
 *
 * @return If the message was consumed or not.
 * @description
 *
 *  This handler is called when application sent a read request is not complient with the 
 *  specification or the implementation limitations.
 *
 ****************************************************************************************
 */
int app_hogpbh_char_req_rsp_handler(ke_msg_id_t const msgid,
                                    struct hogpbh_char_req_rsp *param,
                                    ke_task_id_t const dest_id,
                                    ke_task_id_t const src_id)
{
    QPRINTF("HOGPBH read char error response\r\n");
    return (KE_MSG_CONSUMED);
}
Example #25
0
/*
 ****************************************************************************************
 * @brief Handles the disable indication to APP. *//*
 *
 * @param[in] msgid     HOGPBH_DISABLE_IND
 * @param[in] param     Pointer to struct prf_client_disable_ind
 * @param[in] dest_id   TASK_APP
 * @param[in] src_id    TASK_HOGPBH
 * @return If the message was consumed or not.
 * @description
 *
 * This handler is used to inform the application that the HID Over GATT Profile Boot Host 
 * Role task has been correctly disabled or if an error has occurred during this process.
 *
 ****************************************************************************************
 */
int app_hogpbh_disable_ind_handler(ke_msg_id_t const msgid,
                                   struct prf_client_disable_ind *param,
                                   ke_task_id_t const dest_id,
                                   ke_task_id_t const src_id)
{
    QPRINTF("HOGPBH disable ind\r\n");
    return (KE_MSG_CONSUMED);
}
Example #26
0
/*
 ****************************************************************************************
 * @brief Handles the generic message for send read notification configuration value to APP. *//**
 *
 * @param[in] msgid     HOGPBH_CFG_NTF_RD_RSP 
 * @param[in] param     Pointer to the struct hogpbh_cfg_ntf_rd_rsp
 * @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 Client Characteristic Configuration 
 *  Descriptor value. 
 *
 ****************************************************************************************
 */
int app_hogpbh_cfg_ntf_rd_rsp_handler(ke_msg_id_t const msgid,
                      struct hogpbh_cfg_ntf_rd_rsp *param,
                      ke_task_id_t const dest_id,
                      ke_task_id_t const src_id)
{
    QPRINTF("HOGPBH read configuration response(%d).\r\n", param->hids_nb);
   
    return (KE_MSG_CONSUMED);
}
Example #27
0
/*
 ****************************************************************************************
 * @brief Handles the generic message for write characteristic response status to APP. *//**
 *
 * @param[in] msgid     PROXM_WR_CHAR_RSP
 * @param[in] param     Pointer to struct proxm_wr_char_rsp
 * @param[in] dest_id   TASK_APP
 * @param[in] src_id    TASK_PROXM
 * @return If the message was consumed or not.
 * @description
 *
 *  This API is used by the Monitor role to send the Application the status
 *  of a characteristic write request, received in a response from TASK_GATT. The application will
 *  decide what to do if an error is received.
 *
 ****************************************************************************************
 */
int app_proxm_wr_char_rsp_handler(ke_msg_id_t const msgid,
                                  struct proxm_wr_char_rsp *param,
                                  ke_task_id_t const dest_id,
                                  ke_task_id_t const src_id)
{
    QPRINTF("PROXM write char response status: 0x%X.\r\n", param->status);

    return (KE_MSG_CONSUMED);
}
Example #28
0
/*
 ****************************************************************************************
 * @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);
}
Example #29
0
/*
 ****************************************************************************************
 * @brief Handles the enable confirmation from the HOGPBH. *//**
 *
 * @param[in] msgid     HOGPBH_ENABLE_CFM
 * @param[in] param     Pointer to the struct hogpbh_enable_cfm
 * @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 by the Boot Host to either send the discovery results of HIDS on the HID device 
 *  and confirm enabling of the Boot Host role, or to simply confirm enabling of Boot Host role if it is a normal connection 
 *  and the attribute details are already known. 
 *
 ****************************************************************************************
 */
int app_hogpbh_enable_cfm_handler(ke_msg_id_t const msgid,
                      struct hogpbh_enable_cfm *param,
                      ke_task_id_t const dest_id,
                      ke_task_id_t const src_id)
{
    QPRINTF("HOGPBH enable confirmation status: 0x%X.\r\n", param->status);
    if (param->status == CO_ERROR_NO_ERROR)
    {
        uint8_t idx = KE_IDX_GET(src_id);
        app_hogpbh_env[idx].conhdl = param->conhdl;
        app_hogpbh_env[idx].enabled = true;
        app_hogpbh_env[idx].cur_code = 0;

        // Get keyboard instance number here
        if (param->hids[0].descs[HOGPBH_DESC_BOOT_KB_IN_REPORT_CFG].desc_hdl != 0)
            app_hogpbh_env[idx].hids_kb = 0;
        else if (param->hids[1].descs[HOGPBH_DESC_BOOT_KB_IN_REPORT_CFG].desc_hdl != 0)
            app_hogpbh_env[idx].hids_kb = 1;
        else
            app_hogpbh_env[idx].hids_kb = 0xFF;

        // Get mouse instance number here
        if (param->hids[0].descs[HOGPBH_DESC_BOOT_MOUSE_IN_REPORT_CFG].desc_hdl != 0)
            app_hogpbh_env[idx].hids_mouse = 0;
        else if (param->hids[1].descs[HOGPBH_DESC_BOOT_MOUSE_IN_REPORT_CFG].desc_hdl != 0)
            app_hogpbh_env[idx].hids_mouse = 1;
        else
            app_hogpbh_env[idx].hids_mouse = 0xFF;

        if (app_hogpbh_env[idx].hids_kb < HOGPBH_NB_HIDS_INST_MAX)
        {
            // Set Keyboard to Boot report mode
            app_hogpbh_set_boot_proto_mode_req(app_hogpbh_env[idx].hids_kb, param->conhdl);
            // Start Keybaord Notify here
            app_hogpbh_cfg_ntf_req(HOGPBH_DESC_BOOT_KB_IN_REPORT_CFG, PRF_CLI_START_NTF, 
                                    app_hogpbh_env[idx].hids_kb, param->conhdl);
            app_hogpbh_env[idx].cur_code = 1;
        }
        
        if (app_hogpbh_env[idx].hids_mouse != app_hogpbh_env[idx].hids_kb
         && app_hogpbh_env[idx].hids_mouse  < HOGPBH_NB_HIDS_INST_MAX)
        {
            // Set Mouse to Boot protocol mode
            app_hogpbh_set_boot_proto_mode_req(app_hogpbh_env[idx].hids_mouse, param->conhdl);
            if (!app_hogpbh_env[idx].cur_code) {
                // 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);
            }
            else {
                app_hogpbh_env[idx].cur_code = 2;
            }
        }
    }
    
    return (KE_MSG_CONSUMED);
}
Example #30
0
/*
 ****************************************************************************************
 * @brief Handles the generic error message from the TIPC. *//**
 *
 * @param[in] msgid     TIPC_ERROR_IND
 * @param[in] param     Pointer to struct tipc_error_ind
 * @param[in] dest_id   TASK_APP
 * @param[in] src_id    TASK_TIPC
 * @return If the message was consumed or not.
 * @description
 *
 *  This API is used by the Client role to inform the Application of an error occurred in 
 *  different situations. The error codes are proprietary and defined in prf_types.h. An error may 
 *  occur during attribute discovery or due to application request parameters. Following reception 
 *  of this message, the application will decide the necessary action.
 *
 ****************************************************************************************
 */
int app_tipc_error_ind_handler(ke_msg_id_t const msgid,
                      struct tipc_error_ind *param,
                      ke_task_id_t const dest_id,
                      ke_task_id_t const src_id)
{
    QPRINTF("TIPC error indication status: 0x%X.\r\n", param->status);

    return (KE_MSG_CONSUMED);
}