?? ag_sdpextra.c
字號:
#include "ag_private.h"
#include <message.h>
#include <print.h>
#include <stdlib.h>
#include <string.h>
/* request to retrieve the headset support for remote volume control */
static const uint8 headsetAttributeRequest [] =
{
0x35, /* 0b00110 101 type=DataElSeq size=SeeBelow*/
0x03, /* ...3 bytes in DataElSeq */
0x09, 0x03, 0x02 /* 2 byte UINT attrID RemoteAudioVolCtrl */
};
/* request to retrieve the hands free supported features data */
static const uint8 handsfreeAttributeRequest [] =
{
0x35, /* 0b00110 101 type=DataElSeq size=SeeBelow*/
0x03, /* ...3 bytes in DataElSeq */
0x09, 0x03, 0x11 /* 2 byte UINT attrID SupportedFeatures */
};
/*
agGetExtraSdpInfo
Request extra information stored in the remote device's SDP record.
*/
void agGetExtraSdpInfo(void)
{
if (agIsCurrentlyHandsFree())
{
MAKE_MSG(CM_SDP_SUPPORTED_FEATURES_REQ);
msg->target = HANDSFREE_TARGET;
msg->attr_req_length = sizeof(handsfreeAttributeRequest);
msg->attr_req = (uint8 *) agAlloc(msg->attr_req_length);
memcpy(msg->attr_req, handsfreeAttributeRequest, msg->attr_req_length);
agPutCmMsg(msg);
}
else if (agIsCurrentlyHeadset())
{
MAKE_MSG(CM_SDP_SUPPORTED_FEATURES_REQ);
msg->target = HEADSET_TARGET;
msg->attr_req_length = sizeof(headsetAttributeRequest);
msg->attr_req = (uint8 *) agAlloc(msg->attr_req_length);
memcpy(msg->attr_req, headsetAttributeRequest, msg->attr_req_length);
agPutCmMsg(msg);
}
else
{
PRINT(("Unknown device type\n"));
}
}
/*
agSdpFeaturesCfm
Returns the extra SDP info (if any) obtained from the remote device
*/
void agSdpFeaturesCfm(const CM_SDP_SUPPORTED_FEATURES_CFM_T *cfm)
{
uint16 count = 0;
uint16 data_fields = cfm->num_fields;
/* TODO don't retry forever */
if (!cfm->result)
{
/* try search again */
/* agGetExtraSdpInfo(); */
AGState.hfSupportedFeatures = 0;
/* just in case any memory was allocated */
if (cfm->num_fields > 0)
free(cfm->sdp_data);
return;
}
/*
TODO if the supported features field is not present in the sdp record
you must assume default values for the supported features
*/
while(data_fields > 0)
{
switch(cfm->sdp_data[count].data_type)
{
case CmHeadsetRemoteAudioVolCtrl:
PRINT(("Headset remote audio vol support 0x%x\n",
cfm->sdp_data[count].data_value));
break;
case CmHandsFreeSupportedFeatures:
PRINT(("Handsfree Supported Features 0x%x\n",
cfm->sdp_data[count].data_value));
/* Only five LSBs valid so mask the rest off */
AGState.hfSupportedFeatures = cfm->sdp_data[count].data_value & 0x1f;
break;
case CmHandsfreeAgNetwork:
case CmHandsfreeAgSuportedFeatues:
default:
PRINT(("ag_sdpExtra: Unknown data type 0x%x value 0x%x\n",
cfm->sdp_data[count].data_type, cfm->sdp_data[count].data_value));
}
count++;
data_fields--;
}
/* Free the data */
if (cfm->num_fields > 0)
free(cfm->sdp_data);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -