Esempio n. 1
0
/*---------------------------------------------------------------------------
 *            hdp_deinit()
 *---------------------------------------------------------------------------
 *
 * TODO: before reseting contex, check and deregister instance
 *---------------------------------------------------------------------------
 */
BtStatus hdp_deinit(void)
{
	BtStatus status; 
	U8 index = 0;
	
	OS_Report("[HDP]hdp_deinit");
	if (!hdp_cntx.initialized)
	{
		OS_Report("[HDP]hdp has been deinitiated");
		return BT_STATUS_SUCCESS;
	}
	hdp_cntx.initialized = FALSE;

	hdp_deregister_all();
	
	status = MCAP_DeRegister(HDP_PROFILE);
	MCAP_DeInit();

	status = HdpSdpDB_DeRegistration();
	hdp_pool_deinit();
	hdp_data_packat_list_deint();
	
//	OS_MemSet(hdp_cntx, 0x0, sizeof(HdpContext));
	OS_Report("[HDP]the result is %d to deinit HDP", status);
	return status;
}
Esempio n. 2
0
/*---------------------------------------------------------------------------
 *            hdp_close_channel_all()
 *---------------------------------------------------------------------------
 *  
 *close all the data channels based on remote device specified by instance.
 *
 *---------------------------------------------------------------------------
 * MdepId:  (in)indication to specific instance
 * BtStatus: (out)   result
 *---------------------------------------------------------------------------
 */
BtStatus hdp_close_channel_all(MdepId id)
{

	BtStatus ret = BT_STATUS_SUCCESS;
	HdpChannel *channel = NULL;
	ListEntry* nextNode = NULL;
	
	OS_Report("[HDP] hdp_close_channel_all: id %d", id);

	if(IsListEmpty(&hdp_cntx.channel))
	{
		OS_Report("[HDP] channel list is empty");
		goto exit;
	}
	
	nextNode = GetHeadList(&hdp_cntx.channel);
	do {
		channel = (HdpChannel *) nextNode;
		nextNode = GetNextNode(nextNode);
		if (channel->instance->feature.mdepId == id)
   		{
			BtStatus iRet = hdp_mdl_disconnect(channel, FALSE);
			OS_Report("[HDP] ret %d", iRet);

			//if any result is pending, no need to update ret
			if (ret != BT_STATUS_PENDING)
			{
				ret = iRet;
			}			
		}
	} while ((ListEntry *)nextNode != &hdp_cntx.channel);
exit:	
	return ret;
}
Esempio n. 3
0
U8 time_att_db_cttime_config_callback(U8 type, BtRemoteDevice *link, U16 *len, U8 **raw) {
	TimeSTransport *pChnl;

	OS_Report("[Time] %s(), type: %d, len: %d", __FUNCTION__, type, *len);

	pChnl = times_find_server_tp(link->bdAddr.addr);
	if (pChnl == NULL) {
		return BT_STATUS_FAILED;
	}

	if (type == ATT_OP_READ ||
           type == ATT_OP_READ_LONG ||
           type == ATT_OP_READ_MULTIPLE ||
           type == ATT_OP_READ_BY_TYPE) {
		*raw = (U8 *) &pChnl->cttime_notify_config;
		*len = sizeof(pChnl->cttime_notify_config);
		return BT_STATUS_SUCCESS;

	} else if (type == ATT_OP_WRITE || type == ATT_OP_EXECUTE_WRITE) {
		if (*len != 2) {
			return BT_STATUS_FAILED;
		} else {
			pChnl->cttime_notify_config = ((0x00ff & *(*raw)) | (0xff00 & (*(*raw+1) << 8)));
			OS_Report("[Time] Current Time notify config updated: 0x%04x", pChnl->cttime_notify_config);
			return BT_STATUS_SUCCESS;
		}
	}
	return BT_STATUS_FAILED;
}
Esempio n. 4
0
void bt_l2captester_handler_help(){
    OS_Report("l2cap: bt_l2captester_handler_help");
    OS_Report("l2 config <cid> - reconfig (config_req) the channel");    
    OS_Report("l2 dump - dump the channel");
    OS_Report("l2 disc <cid> - disc the channel");
    OS_Report("l2 disc <cid> - disc the channel");
}
Esempio n. 5
0
BtStatus hdp_remove_connection(BD_ADDR *bdaddr)
{
	BtStatus ret = BT_STATUS_FAILED;
	OS_Report("[HDP]hdp_remove_connection: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x",
				bdaddr->addr[0], bdaddr->addr[1], bdaddr->addr[2], bdaddr->addr[3], bdaddr->addr[4], bdaddr->addr[5]);
	if (NULL == bdaddr)
	{
		ret = BT_STATUS_INVALID_PARM;
		goto exit;
	}
	HdpMcl *mcl = hdp_find_mcl(bdaddr);
	if (NULL == mcl)
	{
		ret = BT_STATUS_SUCCESS;
		OS_Report("No mcl is found for the device, which indicate success");
		goto exit;
	}
	if (NULL == mcl->mcapMcl)
	{
		OS_Report("MCAP mcl record is null, maybe previous operation is abnormal");
		hdp_mcl_delete(mcl);
		ret = BT_STATUS_SUCCESS;
		goto exit;
	}
	mcl->state = HDP_CHANNEL_STATE_DISCONNECTING;
	ret = MCAP_CloseMcl(mcl->mcapMcl);
	if (BT_STATUS_PENDING != ret)
	{
		hdp_mcl_delete(mcl);
	}	
	
exit:
	return ret;
}
Esempio n. 6
0
void btadp_jsr82_session_disconnected(BT_ADP_JSR82_SESSION *session)
{
	int length = 0;
	BOOL closesession = FALSE;
	BT_ADP_JSR82_SESSION *server_session = NULL;
	ASSERT(session);

	OS_Report("[JSR82]btadp_jsr82_session_disconnected :id[%4x], conn_id[%d], identify[%d]",
				session->sessionid, session->index, session->identify);

	session->conn_state = BT_ADP_JSR82_STATE_DISCONNECTING;	

	if(!BTCoreVerifySysInitState() || BTCoreIsDeinitializing())
	{
		closesession = TRUE;
		goto exit;
	}
	server_session = btadp_jsr82_find_session_by_role_index(JSR82_SESSION_ROLE_SERVER, session->index);
	if(server_session)
	{
		server_session->active_conn--;
		btadp_jsr82_server_disconnected(server_session);
	}
	else
	{
		OS_Report("[JSR]no matching for this session:index[%d]");
	}
	
exit:
	bt_session_destroy(session->sessionid);
	btadp_jsr82_session_deinit(session);
}
Esempio n. 7
0
BtStatus hdp_mcl_connect(HdpChannel *channel)
{
	HdpMcl* mcl = hdp_find_mcl(&channel->bdAddr);
	BtStatus ret;
	
	OS_Report("[HDP]hdp_mcl_connect:");

	Assert (channel != NULL && channel->cmgrHdlr.remDev != NULL);
	if (NULL == mcl)
	{
		mcl = hdp_mcl_new(&channel->bdAddr);
		if (NULL == mcl)
		{			
			ret = BT_STATUS_FAILED;
			goto exit;		
		}
	}

	ret = MCAP_OpenMcl(channel->cmgrHdlr.remDev, channel->rmSdpRecord.ctrChnPsm);		
	if (BT_STATUS_SUCCESS == ret)
	{
		//even result is success, MCAP still will callback
		ret = BT_STATUS_PENDING;
	}
	
exit:
	OS_Report("[HDP]hdp_mcl_connect result:%d", ret); 
	return ret;
}
Esempio n. 8
0
/*2.  update SDP record*/
MdepId hdp_register(HdpConfig *config)
{
	BtStatus ret;
	HdpInstance * instance = NULL;
	MdepId id = HDP_INVALID_MDEP_ID;
	OS_Report("[HDP]hdp_register, role is %d, datatype %d, channel type %d, desc %s",
				config->role, config->datatype, config->channelType, config->description);
	if (NULL == config || id <= 0) 
	{
		OS_Report("[HDP]Err, config is null? %d, id is %d",
					(NULL == config), id);
		id = HDP_INVALID_MDEP_ID;
		goto exit;
	}	

	if(FALSE == hdp_check_config_valid(config->role, config->channelType))
	{
		goto exit;
	}

	instance = hdp_find_registered_instance(config);
	if (NULL != instance)
	{
		id = instance->feature.mdepId;
		goto exit;
	}
		
	instance = hdp_find_available_instance();
	if (NULL == instance)
	{
		goto exit;
	}	

	id = hdp_assign_mdep_id();

	/*Update SDP*/
	ret = HdpSdpDB_AddFeature(id, config->role, config->datatype, config->description);
	if (BT_STATUS_SUCCESS != ret)
	{
		OS_Report("[HDP]it fails to add instance to SDP");
		id = HDP_INVALID_MDEP_ID;
		goto exit;
	}
	OS_MemSet(instance, 0x0, sizeof(HdpInstance));	
	instance->state = HDP_INSTANCE_STATE_REGISTERED;
	instance->channelType = config->channelType;
	instance->feature.mdepId = id;
	instance->feature.role = config->role;
	instance->feature.dataType = config->datatype;
	strncpy(instance->feature.descriotion, config->description, HDP_INSTNACE_DESC_MAX_LEN);
	
exit:
	OS_Report("[HDP]instance id is %d", id);
	return id;
}
Esempio n. 9
0
static void _time_gatt_discovery_characteristic_descriptors_cb(BtGattEvent *event) {
	BtStatus status = BT_STATUS_FAILED;
	BtGattDiscoveryAllCharacteristicDescriptorsResultEvent *ptr;
	TimePacket *pkt;
	TimeCTransport *pChnl;
	U16 uuid = 0;

	ptr = (BtGattDiscoveryAllCharacteristicDescriptorsResultEvent *) event->parms;
	pkt = ContainingRecord(event->pGattOp, TimePacket, gatt_op);
	pChnl = (TimeCTransport *) pkt->chnl;

	switch (ptr->flag) {
		case BT_GATT_EVENT_RESULT_CONTINUE_DATA:
			OS_Report("[Time] Characteristic Descriptor found. type: %d, uuid: 0x%04x", ptr->type, ptr->uuid16);
			OS_Report("[Time] Char desc value handle: 0x%04x", ptr->attributeHandle);
			pkt->start_handle = ptr->attributeHandle;
			pkt->success_flag = 1;
			break;

		case BT_GATT_EVENT_RESULT_DONE_COMPLETED:
			OS_Report("[Time] Discovery Characteristic Descriptor with result DONE_COMPLETED");
			if (pkt->success_flag != 1) {
				_time_gatt_notify_query_result(pkt, 0, 0, BT_STATUS_FAILED);
				return;
			}

			_time_access_value_handle_cache(pChnl, pkt->value_id, 1, &pkt->start_handle);
			if (pkt->value_id == GATT_TIME_CTTIME_NOTIFY) {
				switch (pkt->type) {
					case TIME_PKT_READ:
						status = _time_gatt_read_characteristic_descriptor(pkt, pkt->start_handle);
						break;
					case TIME_PKT_WRITE:
						status = _time_gatt_write_characteristic_descriptor(pkt, pkt->start_handle);
						break;
				}

				if (status != BT_STATUS_SUCCESS && status != BT_STATUS_PENDING) {
					_time_gatt_notify_query_result(pkt, 0, 0, BT_STATUS_FAILED);
				}
			} else {
				_time_gatt_notify_query_result(pkt, 0, 0, BT_STATUS_FAILED);
			}
			break;

		case BT_GATT_EVENT_RESULT_ERROR:
			_time_gatt_notify_query_result(pkt, 0, 0, BT_STATUS_FAILED);
			break;
		case BT_GATT_EVENT_RESULT_DISCONNECT:
			_time_gatt_notify_query_result(pkt, 0, 0, BT_STATUS_FAILED);
			break;
	}
}
Esempio n. 10
0
/*---------------------------------------------------------------------------
 *            AvrcpRegisterSdp()
 *---------------------------------------------------------------------------
 *
 * Synopsis:  Registers an SDP entry.
 *
 * Return:    BT_STATUS_FAILED
 *            (Also see SDP_AddRecord)
 */
BtStatus AvrcpRegisterSdp(AvrcpChannel *Chnl, U8 version)
{
    BtStatus    status;
    SdpRecord  *sdpRecord;
    U8 local_service_id = version; /* for temportary used. */
    
    /* Configure the attributes */
    kal_trace( BT_TRACE_G8_AVRCP, BT_AVRCP_SDP_REGISTER , Chnl->role);

    switch (Chnl->role) {
    case AVRCP_TG: // register the target role
        if (AVRCP(tgChannelCount)++ > 0) 
            return BT_STATUS_SUCCESS;

        AVRCP(tgSdpRecord).num = SDPDB_GetLocalServiceAttribute(
                                                                SC_AV_REMOTE_CONTROL_TARGET,
                                                                &AVRCP(tgSdpRecord).attribs,
                                                                &local_service_id
                                                                );  
        
        sdpRecord = &AVRCP(tgSdpRecord);
		status = SDP_AddRecord(sdpRecord);
		OS_Report("[AVRCP] register TG status:%d", status);
        break;
    case AVRCP_CT:
        if (AVRCP(ctChannelCount)++ > 0) 
            return BT_STATUS_SUCCESS;

        /* Copy the SDP attributes to RAM */
        AVRCP(tgSdpRecord).num = SDPDB_GetLocalServiceAttribute(
                                                                SC_AV_REMOTE_CONTROL,
                                                                &AVRCP(ctSdpRecord).attribs,
                                                                &local_service_id
                                                                );  
        sdpRecord = &AVRCP(ctSdpRecord);
#if 0
		sdpRecord->classOfDevice = 0;
#endif
	    status = SDP_AddRecord(sdpRecord);
		OS_Report("[AVRCP] register CT status:%d", status);

        break;

    default:
        status = BT_STATUS_FAILED;
        goto fail;
    }


fail:
    return status;
}
Esempio n. 11
0
// In Time Profile, the largest value size is 2-byte.
BtStatus time_gatt_write_remote_value(TimePacket *pkt, U8 seq_num, U32 value_id, U16 value) {
	BtStatus status = BT_STATUS_FAILED;
	TimeCTransport *pChnl = pkt->chnl;
	U16 value_handle = 0x0000, start_handle = 0x0000, end_handle = 0x0000;
	U16 value_uuid = 0, service_uuid = 0;

	pkt->seq_num = seq_num;
	pkt->value_id = value_id;
	pkt->type = TIME_PKT_WRITE;
	pkt->value = value;

	_time_access_value_handle_cache(pChnl, value_id, 0, &value_handle);
	_time_access_service_handle_cache(pChnl, value_id, 0, &start_handle, &end_handle);

	OS_Report("[Time] %s(), value_id: %d, value_handle: %d, service range: %d to %d",
			__FUNCTION__, value_id, value_handle, start_handle, end_handle);

	switch (value_id) {
		case GATT_TIME_SERVER_UPDATE_CTRL:
			if (value_handle != 0x0000) {
				status = _time_gatt_write_without_response(pkt, value_handle);
				return status;
			} else {
				value_uuid = BT_UUID_TIME_UPDATE_CONTROL_POINT;
				service_uuid = BT_UUID_GATT_SERVICE_TIMEUPDATE;
			}
			break;

		case GATT_TIME_CTTIME_NOTIFY:
			if (value_handle != 0x0000) {
				status = _time_gatt_write_characteristic_descriptor(pkt, value_handle);
				return status;
			} else {	
				value_uuid = BT_UUID_CT_TIME;
				service_uuid = BT_UUID_GATT_SERVICE_TIME;
			}
			break;;

		default:
			return BT_STATUS_FAILED;
	}

	if (start_handle != 0x0000 && end_handle != 0x0000) {
		status = _time_gatt_discovery_characteristic_by_uuid(pkt, value_uuid, start_handle, end_handle);
	} else {
		status = _time_gatt_discovery_primary_service_by_uuid(pkt, service_uuid, 0x0001, 0xffff);
	}

	OS_Report("[Time] %s(), result: %d", __FUNCTION__, status);
	return status;
}
Esempio n. 12
0
BtStatus hdp_tp_connect(HdpChannel *channel)
{
	BtStatus ret;
	OS_Report("[HDP]hdp_tp_connect");

	ret = CMGR_RegisterHandler(&channel->cmgrHdlr, hdp_cmgr_callback);
	if (BT_STATUS_SUCCESS == ret || BT_STATUS_IN_USE == ret)
	{
		ret = CMGR_CreateDataLink(&channel->cmgrHdlr, &channel->bdAddr);	
	}	
	OS_Report("[HDP]hdp_tp_connect result %d", ret);
	
	return ret;
}
Esempio n. 13
0
void bt_session_upper_buffer_writable(U32 id)
{
	BT_ADP_JSR82_SESSION *session = NULL;
	
	OS_Report("[JSR82]bt_session_upper_buffer_writable: id[%8x]",id);
	session = btadp_jsr82_find_session_by_id(id);
	if (NULL != session)
	{	
		btadp_jsr82_session_notify_to_receive(session);
	}
	else
	{		
		OS_Report("[JSR82]no session contenxt is found");	
	}
}
Esempio n. 14
0
void bt_session_detached(U32 id)
{
	BT_ADP_JSR82_SESSION *session = NULL;
	
	OS_Report("[JSR82]bt_session_detached: session id[%8x]",id);
	session = btadp_jsr82_find_session_by_id(id);
	if (NULL == session )
	{
		OS_Report("[JSR82]no session is found");
	}
	else
	{
		btadp_jsr82_session_notify_to_disconnect(session);
	}
}
Esempio n. 15
0
void bt_session_upper_data_incoming(U32 id)
{
	BT_ADP_JSR82_SESSION *session = NULL;

	OS_Report("[JSR82]bt_session_upper_data_incoming: session id[%8x]",id);
	session = btadp_jsr82_find_session_by_id(id);
	if (NULL == session)
	{
		OS_Report("[JSR82]no session is found");
	}
	else
	{
		btadp_jsr82_session_notify_to_send(session);
	}
}
Esempio n. 16
0
void time_gatt_ap_callback(void *user_data, BtGattEvent *event) {
	OS_Report("[Time] time_gatt_ap_callback(), event: %d", event->eType);
	event->pGattOp = user_data;

	switch (event->eType) {
		case BT_GATT_OPERATOR_DISCOVERY_PRIMARY_SERVICE_BY_UUID:
			_time_gatt_discovery_primary_service_by_uuid_cb(event);
			break;
		case BT_GATT_OPERATOR_DISCOVERY_CHAR_BY_UUID:
			_time_gatt_discovery_characteristic_by_uuid_cb(event);
			break;
		case BT_GATT_OPERATOR_DISCOVERY_ALL_CHAR_DESCRIPTOR:
			_time_gatt_discovery_characteristic_descriptors_cb(event);
			break;
		case BT_GATT_OPERATOR_READ_CHAR_VALUE:
			_time_gatt_read_characteristic_value_cb(event);
			break;
		case BT_GATT_OPERATOR_WRITE_WITHOUT_RESPONSE:
			_time_gatt_write_without_response_cb(event);
			break;
		case BT_GATT_OPERATOR_READ_CHAR_DESCRIPTORS:
			_time_gatt_read_characteristic_descriptor_cb(event);
			break;
		case BT_GATT_OPERATOR_WRITE_CHAR_DESCRIPTORS:
			_time_gatt_write_characteristic_descriptor_cb(event);
			break;
	}
}
Esempio n. 17
0
BtStatus hdp_close_channel(BD_ADDR *bdaddr, U16 mdlId)
{
	HdpChannel* channel;
	HdpMcl* mcl;
	BtStatus ret;
	OS_Report("[HDP]hdp_close_channel");
	channel = hdp_find_channel_by_mdlId(bdaddr, mdlId);
	if (NULL == channel)
	{
		ret = BT_STATUS_FAILED;
		goto exit;
	}

	/*Release pending packet based on l2cap id*/
/*	if (NULL != channel->mcapmdl)
	{
		hdp_data_packat_list_remove_by_channel(channel->mcapmdl->l2ChannelId);
	}
	*/
	
	ret = hdp_mdl_disconnect(channel, FALSE);
		
exit:
	return ret;
}
Esempio n. 18
0
U8 time_att_db_update_ctrl_point_callback(U8 type, BtRemoteDevice *link, U16 *len, U8 **raw) {
	TimeSTransport *pChnl;
	TimeSContext *pCntx;

	pChnl = times_find_server_tp(link->bdAddr.addr);
	if (pChnl == NULL) {
		return BT_STATUS_FAILED;
	}

	OS_Report("[Time] %s(), type: %d", __FUNCTION__, type);
	pCntx = ContainingRecord(pChnl, TimeSContext, chnl);
	if (type == ATT_OP_WRITE || type == ATT_OP_EXECUTE_WRITE) {
		if ((pChnl->update_status.cur_state == TIME_UPDATE_STATE_IDLE) &&
				(*raw[0] == TIME_UPDATE_CTRL_REQUEST)) {
			pChnl->update_status.cur_state = TIME_UPDATE_STATE_UPDATE_PENDING;
			times_notify_request_server_update(pCntx);
			return BT_STATUS_SUCCESS;

		} else if ((pChnl->update_status.cur_state == TIME_UPDATE_STATE_UPDATE_PENDING) &&
				(*raw[0] == TIME_UPDATE_CTRL_CANCEL)) {
			pChnl->update_status.cur_state = TIME_UPDATE_STATE_IDLE;
			pChnl->update_status.result = TIME_UPDATE_RESULT_CANCELED;
			times_notify_cancel_server_update(pCntx);
			return BT_STATUS_SUCCESS;
		}
	}
	return BT_STATUS_FAILED;
}
Esempio n. 19
0
static void _time_gatt_write_characteristic_descriptor_cb(BtGattEvent *event) {
	BtStatus status;
	BtGattWriteCharDescriptorResultEvent *ptr;
	TimePacket *pkt;
	TimeCTransport *pChnl;
	U16 uuid = 0;

	ptr = (BtGattWriteCharDescriptorResultEvent *) event->parms;
	pkt = ContainingRecord(event->pGattOp, TimePacket, gatt_op);
	pChnl = (TimeCTransport *) pkt->chnl;

	switch (ptr->flag) {
		case BT_GATT_EVENT_RESULT_DONE_COMPLETED:
			OS_Report("[Time] Write Characteristic Descriptor with result DONE_COMPLETED");
			_time_gatt_notify_query_result(pkt, 0, 0, BT_STATUS_SUCCESS);
			break;
		case BT_GATT_EVENT_RESULT_ERROR:
			_time_gatt_notify_query_result(pkt, 0, 0, BT_STATUS_FAILED);
			break;
		case BT_GATT_EVENT_RESULT_DISCONNECT:
			_time_gatt_notify_query_result(pkt, 0, 0, BT_STATUS_FAILED);
			break;
	}

}
Esempio n. 20
0
static void _time_gatt_read_characteristic_value_cb(BtGattEvent *event) {
	// To be modified.
	BtStatus status;
	BtGattReadCharacteristicValueResultEvent *ptr;
	TimePacket *pkt;
	TimeCTransport *pChnl;
	U16 uuid = 0;

	ptr = (BtGattReadCharacteristicValueResultEvent *) event->parms;
	pkt = ContainingRecord(event->pGattOp, TimePacket, gatt_op);
	pChnl = (TimeCTransport *) pkt->chnl;

	switch (ptr->flag) {
		case BT_GATT_EVENT_RESULT_DONE_COMPLETED:
			OS_Report("[Time] Read Characteristic Value with result DONE_COMPLETED");
			_time_gatt_notify_query_result(pkt, ptr->data, ptr->length, BT_STATUS_SUCCESS);
			break;
		case BT_GATT_EVENT_RESULT_ERROR:
			_time_gatt_notify_query_result(pkt, 0, 0, BT_STATUS_FAILED);
			break;
		case BT_GATT_EVENT_RESULT_DISCONNECT:
			_time_gatt_notify_query_result(pkt, 0, 0, BT_STATUS_FAILED);
			break;
	}
}
Esempio n. 21
0
/**
 * @brief Push a file to remote ftp server
 * @param ucFilePath the send file's path and filename that will be using by btmtk_goep_open_rstream
 * @see btmtk_goep_open_rstream
 */
BT_BOOL btmtk_ftpc_push_file_ex(const U8 *ucFolderpath, const U8 *ucFilename, U8 srm_enable) {
	if( NULL == act_client_cntx_p ) {
		return FALSE;
	}

#ifdef __BT_GOEP_V2__
	/// if connection type is 1 (l2cap), turn on srm mode
	if( act_client_cntx_p && (1 == act_client_cntx_p->ftpc_conntype) ){
		srm_enable = TRUE;
	}else{
		srm_enable = FALSE;
	}
	OS_Report("[AUTO] turn srm_enable to %d", srm_enable);
#endif

	/// check state and push a push req
	switch (act_client_cntx_p->ftpc_state)
	{
		case BT_FTPC_STATE_CONNECTED:
		return bt_ftpc_start_pushfile_routine( ucFolderpath ,ucFilename, srm_enable );
		break;
		default:
		break;
	}
	return FALSE;
}
Esempio n. 22
0
BtStatus time_gatt_connect_service(TimeCTransport *pChnl) {
	BtStatus status;
	TIMEASSERT(pChnl->check_byte == TIME_CHECK_BYTE);

	if (pChnl->handler.remDev) {
		_cur_timec_chnl = pChnl;
		// Wait for BT_GATT_APP_EVENT_CONNECTED
		status = GattClientConnect(pChnl->handler.remDev);
		OS_Report("[Time] GattClientConnect() returns %d", status);
	} else {
		status = BT_STATUS_INVALID_PARM;
		OS_Report("[Time] Error: pChnl->handler.remDev is NULL");
	}

	return status;
}
Esempio n. 23
0
BOOL btadp_jsr82_session_add_task(BT_ADP_JSR82_SESSION *session, BT_JSR82_TASK_CODE code, void *context)
{
	BT_Jsr82_Task *task = NULL; 

	if (NULL == session ||
		BT_ADP_JSR82_STATE_IDLE == session->conn_state)
	{
		return FALSE;
	}
	if (session->pending_task_num == 0xFF)
	{
		OS_Report("[JSR82] task list is full");
		return FALSE;
	}

	task = (BT_Jsr82_Task *)malloc (sizeof(BT_Jsr82_Task));
	if (NULL == task)
	{
		return FALSE;
	}
	memset(task, 0x0, sizeof(BT_Jsr82_Task));
	task->code = code;
	task->context = context;
	session_mutex_lock(session->mutex);
	InitializeListEntry(&task->node);
	InsertTailList(&session->pending_task, &task->node);
	session->pending_task_num ++;
	session_mutex_unlock(session->mutex);
	return TRUE;
}
Esempio n. 24
0
/*****************************************************************************
 * FUNCTION
 *  translateFileError
 * DESCRIPTION
 *
 * PARAMETERS
 *  err     [IN]
 * RETURNS
 *
 *****************************************************************************/
int translateFileError(int err)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

//20101004 mtk03036
    OS_Report("[FS][ERROR] linux errno[%d]", err);
//20101004 mtk03036 end

    switch (err)
    {
    case EFAULT:
        return BTMTK_FS_ERR_PATH;

    case EACCES:
    case EROFS:
        return BTMTK_FS_ERR_ACCESS;

    default:
        return BTMTK_FS_ERR;
    }
}
Esempio n. 25
0
/********************************************************************************************
 * Entry function for Time server message handlers
 ********************************************************************************************/
void btmtk_adp_timec_handle_message(ilm_struct *ilm_ptr) {
	OS_Report("[Time] %s, msg_id: %d", __FUNCTION__, ilm_ptr->msg_id);

	switch (ilm_ptr->msg_id) {
		case MSG_ID_BT_TIMEC_REGISTER_REQ:
			timec_handle_register_req(ilm_ptr);
			break;
		case MSG_ID_BT_TIMEC_DEREGISTER_REQ:
			timec_handle_deregister_req(ilm_ptr);
			break;
		case MSG_ID_BT_TIMEC_CONNECT_REQ:
			timec_handle_connect_req(ilm_ptr);
			break;
		case MSG_ID_BT_TIMEC_DISCONNECT_REQ:
			timec_handle_disconnect_req(ilm_ptr);
			break;
		case MSG_ID_BT_TIMEC_GET_CTTIME_REQ:
			timec_handle_get_cttime_req(ilm_ptr);
			break;
		case MSG_ID_BT_TIMEC_GET_CTTIME_NOTIFY_REQ:
			timec_handle_get_cttime_notify_req(ilm_ptr);
			break;
		case MSG_ID_BT_TIMEC_SET_CTTIME_NOTIFY_REQ:
			timec_handle_set_cttime_notify_req(ilm_ptr);
			break;
		case MSG_ID_BT_TIMEC_GET_LOCAL_TIME_INFO_REQ:
			timec_handle_get_local_time_info_req(ilm_ptr);
			break;
		case MSG_ID_BT_TIMEC_GET_REF_TIME_INFO_REQ:
			timec_handle_get_ref_time_info_req(ilm_ptr);
			break;
		case MSG_ID_BT_TIMEC_GET_DST_REQ:
			timec_handle_get_dst_req(ilm_ptr);
			break;
		case MSG_ID_BT_TIMEC_REQUEST_SERVER_UPDATE_REQ:
			timec_handle_request_server_update_req(ilm_ptr);
			break;
		case MSG_ID_BT_TIMEC_CANCEL_SERVER_UPDATE_REQ:
			timec_handle_cancel_server_update_req(ilm_ptr);
			break;
		case MSG_ID_BT_TIMEC_GET_SERVER_UPDATE_STATUS_REQ:
			timec_handle_get_server_update_status_req(ilm_ptr);
			break;
		default:
			OS_Report("[Time] Invalid msg_id: %d", ilm_ptr->msg_id);
	}
}
Esempio n. 26
0
U8 time_att_db_cttime_callback(U8 type, BtRemoteDevice *link, U16 *len, U8 **raw) {
	U8 status = BT_STATUS_FAILED;
	time_t rawtime;
	struct tm *timeinfo;

	OS_Report("[Time] %s(), type: %d", __FUNCTION__, type);
	switch (type) {
		case ATT_OP_READ:
              case ATT_OP_READ_LONG:
              case ATT_OP_READ_MULTIPLE:
              case ATT_OP_READ_BY_TYPE:

			time(&rawtime);
			timeinfo = localtime(&rawtime);

			_time_server_info.ct_time.year = timeinfo->tm_year + 1900;
			_time_server_info.ct_time.month = (U8) timeinfo->tm_mon + 1;
			_time_server_info.ct_time.day = (U8) timeinfo->tm_mday;
			_time_server_info.ct_time.hours = (U8) timeinfo->tm_hour;
			_time_server_info.ct_time.minutes = (U8) timeinfo->tm_min;
			_time_server_info.ct_time.seconds = (U8) timeinfo->tm_sec;
			_time_server_info.ct_time.wday = (U8) timeinfo->tm_wday + 1;
			_time_server_info.ct_time.frac = 0;
			_time_server_info.ct_time.adj_reason = 0;

			OS_Report("[Time] %d-%d-%d, %d:%d:%d.%d, day of week: %d",
					_time_server_info.ct_time.year,
					_time_server_info.ct_time.month,
					_time_server_info.ct_time.day,
					_time_server_info.ct_time.hours,
					_time_server_info.ct_time.minutes,
					_time_server_info.ct_time.seconds,
					_time_server_info.ct_time.frac,
					_time_server_info.ct_time.wday);

			*raw = (U8 *) &_time_server_info.ct_time;
			*len = sizeof(_time_server_info.ct_time);
			status = BT_STATUS_SUCCESS;
			break;

		default:
			break;
	}
	
	return status;
}
Esempio n. 27
0
BtStatus hdp_handle_packet()
{	
	BtStatus ret = BT_STATUS_FAILED;
	HdpPkt* pkt;
	HdpDataPacket * txPkt;
	HdpChannel * channel = NULL;

	
	OS_Report("[HDP]hdp_handle_packet:");

	pkt= hdp_pool_pkt_remove();
	if (NULL == pkt)
	{
		ret = BT_STATUS_NO_RESOURCES;
		goto exit;
	}
	while (BT_STATUS_PENDING != ret) {		
		txPkt = hdp_data_packat_list_remove();
		if (NULL == txPkt)
		{
			ret = BT_STATUS_SUCCESS;
			OS_Report("[HDP]No pending packet is in list");
			break;
		}
		channel = hdp_find_channel_by_mdlId(&txPkt->addr, txPkt->mdlId);
		if (NULL == channel)
		{
			//shit, garbage pakcet, remove it forcely
			hdp_data_packat_delete(txPkt, TRUE);
			OS_Report("[HDP]The packet loses its channel info, what a pity");
		}
		else
		{
			ret = hdp_mdl_send_data(channel, pkt, txPkt);	
			hdp_data_packat_delete(txPkt, (BT_STATUS_PENDING != ret));
		}		
	 }

	if (BT_STATUS_PENDING != ret)
	{
		hdp_pool_pkt_add(pkt);
	}

exit:
	return ret;
}
Esempio n. 28
0
BtStatus time_gatt_disconnect_service(TimeCTransport *pChnl) {
	BtStatus status;
	TIMEASSERT(pChnl->check_byte == TIME_CHECK_BYTE);

	status = GattDisconnect(pChnl->handler.remDev);

	OS_Report("[Time] %s(), result: %d", __FUNCTION__, status);
	return status;
}
Esempio n. 29
0
//HdpChannel *hdp_create_channel(MdepId id, BD_ADDR *bdaddr, HdpChannelType type, HdpRole role)
HdpChannel *hdp_create_channel(HdpInstance *instance, BD_ADDR *bdaddr, HdpChannelType type)
{
	HdpChannel *channel = NULL;
	L2capLinkMode mode;
	U16 rmUuid = 0;
	OS_Report("[HDP]hdp_create_channel");

//	instance = hdp_find_instance(id);		
	if (NULL == instance)
	{
		OS_Report("[HDP]instance is NULL");
		goto error;
	}
	channel = (HdpChannel *)hdp_util_malloc(sizeof(HdpChannel));
	Assert(channel != NULL);

	OS_MemSet(channel, 0x0, sizeof(HdpChannel));

	OS_MemCopy(&channel->bdAddr, bdaddr, sizeof(BD_ADDR));

	channel->instance = instance;
	channel->type = type;

	mode = hdp_util_convert_type2mode(instance->channelType);
	if (HDP_INVALID_L2CAP_MODE == mode)
	{
		OS_Report("[HDP] invalid l2cap mode");
		goto error;
	}
	channel->config.inLinkMode = mode;
	rmUuid = hdp_get_target_uuid(instance->feature.role);
	if (0 == rmUuid)
	{
		OS_Report("[HDP] invalid remote device uuid");
		goto error;
	}
	channel->rmUuid = rmUuid;

	InsertTailList(&hdp_cntx.channel, &(channel->node));
	return channel;
error:
	hdp_util_free(channel);
	return NULL;
}
Esempio n. 30
0
/*Notes: we do not reset the related instance contex until mcap return confirmation*/
BtStatus hdp_deregister(MdepId id) 
{
	HdpInstance* instance = NULL;
	BtStatus ret;
	OS_Report("hdp_deregister: %d", id);

	instance = hdp_find_instance(id);
	if (NULL == instance)
	{
		ret = BT_STATUS_INVALID_PARM;
	}
	else if (instance->state == HDP_INSTANCE_STATE_DEREGISTERING)
	{
		ret = BT_STATUS_PENDING;
	}
	else if (instance->state == HDP_INSTANCE_STATE_IDLE)
	{
		ret = BT_STATUS_SUCCESS;
	}
	else
	{		
		if (HDP_MDEP_ID_ECHO_TEST != id)
		{
			ret = HdpSdpDB_RemoveFeature(instance->feature.mdepId);
			OS_Report("[HDP] the result to remove feature from SDP is %d", ret);
		}	

		ret = hdp_close_channel_all(id);
		if (BT_STATUS_PENDING == ret)
		{
			instance->state = HDP_INSTANCE_STATE_DEREGISTERING;
		}
		else
		{
			//Notes: if disconnect cnf has not been received but MMI request to deregister instance, MAYBE no chance to clear channel.
			//		SO leave clearing context to registering instance
			//	OS_MemSet(instance, 0x0, sizeof(HdpInstance));
			instance->state = HDP_INSTANCE_STATE_IDLE;
		}
		
	}
exit:
	return ret;	
}