Affix in a Nutshell: Affix - Open Source Bluetooth Protocol Stack for Linux | ||
---|---|---|
Prev | Chapter 3. Application Programming Interface | Next |
The SDP API is divided into two pars: service client API and service provider API.
Each service attribute describes a single characteristic of a service.
DocumentationURL location of additional service documentation.
IconURL location of an icon that can be used to represent the service.
Table 3-9. UUID API
Function | Purpose |
---|---|
void makeUUIDFrom16Bits(UUID *pUUID, UUID16Bit value16Bit); | Creates UUID object from 16 bit value. |
void makeUUIDFrom32Bits(UUID *pUUID, UUID32Bit value32Bit); | Creates UUID object from 32 bit value. |
void makeUUIDFrom128Bits(UUID *pUUID, UUID128Bit *value128Bit); | Creates UUID object from 128 bit value. |
UUID *convertTo128Bits(UUID *pUUID); | Converts any type UUID to 128 bits UUID. It allocates memory to store new object. |
Table 3-10. Attribute API
Function | Purpose |
---|---|
SDPData *createSDPData(DataTypeDescriptor dtd, void *pValue); | Creates SDP attribute object of certain type. |
int addToAttributeList(ServiceRecord *svcRec, ServiceAttributeIdentifier attrId, SDPData *pSDPData, int replaceFlag); | Adds attribute object to the attribute list of ServiceRecord object. |
void freeSDPData(SDPData *pData); | Destroys entire attribute object. |
Table 3-11. Service client SDP API
Function | Purpose |
---|---|
int SDPInit(0); | Initializes the SDP infrastructure. |
SDPServerHandle SDPOpenServerConnection(struct sockaddr_affix *saddr); | Opens a connection to the SDP server. |
void SDPCloseServerConnection(SDPServerHandle srvHandle); | Closes a connection to the SDP server. |
int SDPServiceSearchRequest(SDPServerHandle srvHandle, slist_t *svcSearchList, uint16_t maxSvcRecordCount, slist_t **svcResponseList, uint16_t *handleCountInResponse); | Makes a service search request to the SDP server and returns service handle list of the services that match to search pattern. Search pattern - list of service class identifiers. |
int SDPServiceAttributeRequest(SDPServerHandle srvHandle, ServiceRecordHandle svcHandle, AttributeRequestType attrReqType, slist_t *attrIDList, uint16_t maxAttrIDByteCount, ServiceRecord **_svcRec, uint16_t *maxAttrResponseByteCount); | Makes an attribute request of a service with a handle "svcHandle" and returns requested attribute list. "attrIDList" list defines attributes to return. |
int SDPServiceSearchAttributeRequest(SDPServerHandle srvHandle, slist_t *svcSearchList, AttributeRequestType attrReqType, slist_t *attrIDList, uint16_t maxAttrByteCount, slist_t **svcResponseList, uint16_t *maxAttrResponseByteCount); | Makes a service search request which returns attributes of all found services. Combines previous two functions. |
int __SDPServiceXXX(struct sockaddr_affix *saddr, ...); | These are variations of former three functions that take address to send request instead of ServerHandle. They open/close connection internally. |
int getXXX(ServiceRecord *svcRec, ....) | Template of functions: extracts individual attributes (XXX) from service record, e.g.: service name, access port, profile id, ... |
The SDP infrastructure must be initialized before any activity using SDPInit(int mode).
SDPServerHandle SDPOpenServerConnection(struct sockaddr_affix *saddr)
To close a connection, call [void SDPCloseServerConnection(SDPServerHandle srvHandle);].
The ServerHandle is provided as a first argument to SDPServiceXXX() functions.
First a service class match is done and for matching service, requested attributes are extracted.
Table 3-12. Service provider SDP API
Function | Purpose |
---|---|
int SDPInit(SDP_SVC_PROVIDER); | Initializes SDP infrastructure. |
SDPServerHandle SDPOpenServerConnection(struct sockaddr_affix *saddr); | Opens a connection to local SDP server. |
void SDPCloseServerConnection(SDPServerHandle srvHandle); | Closes a connection to SDP server. |
ServiceRecord *createServiceRecord(void); | Creates a basic Service Record object w/o attributes. |
void freeServiceRecord(ServiceRecord *svcRec); | Destroys Service Record object and free all used resources. |
ServiceRecord *createRFCOMMServiceRecord(int port, int flags); | Creates a Service Record object and set common RFCOMM attributes. |
int registerServiceRecord(SDPServerHandle srvHandle, ServiceRecord *svcRec); | Registers a Service Record object with the SDP server. |
int updateServiceRecord(SDPServerHandle srvHandle, ServiceRecord *svcRec); | Updates a Service Record object on the SDP server. |
int deleteServiceRecord(SDPServerHandle srvHandle, ServiceRecord *svcRec); | Deletes a Service Record object from SDP server. |
int setXXX(ServiceRecord *svcRec, ....) | Template of functions: set individual attributes (XXX) to service record, e.g.: service name, access port, profile id, ... |