Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: mbed_TANK_Kinect ftusbClass
Diff: sdp.h
- Revision:
- 1:70ee392bcfd4
- Parent:
- 0:7493bf6bb1b9
- Child:
- 2:d5a27b2d2e08
--- a/sdp.h Mon Apr 04 16:45:20 2011 +0000
+++ b/sdp.h Wed Apr 06 18:09:20 2011 +0000
@@ -1,6 +1,6 @@
#ifndef SDP_H
#define SDP_H
-
+#include "AvailableMemory.h"
#include <map>
#define OFFSET 8
@@ -17,6 +17,10 @@
unsigned char l2cap_buf[100+OFFSET];
unsigned char* buf;
unsigned txid;
+ unsigned char contState[17];//maximum size, in practive it is 3
+ unsigned char *contBuf;
+ unsigned byteCount;
+ int _state;
sdp_data *tree;//root of the entire service tree
map<unsigned, serv_rec*> services;//the set of supported services <handle, service>
map<unsigned, serv_rec*>::iterator index;
@@ -27,6 +31,10 @@
ServiceAttributeResponse=attribHandler;
ServiceSearchAttributeResponse=0;
buf = l2cap_buf+OFFSET;
+ contBuf = 0;
+ byteCount = 0;
+ contState[0] = 0;
+ _state = 0;
}
//Called as: Socket_Open(SOCKET_SDP, addr, callback, userdata(this))
@@ -35,7 +43,7 @@
if (_l2cap) {
printf("This SDP supports only one connection at a time\n");
return 0;
- }
+ }
//BD_ADDR* a = &ad->bdaddr;
sdp_socket = sock->ID;
for (index = services.begin(); index != services.end(); index++)
@@ -65,8 +73,19 @@
return "SDPManager SocketHandler";
}
+ void OnSdpRsp(const u8* data, int len);
//this function is called when the L2CAP layer receives SDP packets (see SDPManager::Open), userdata is the sdpmanager instance
- static void OnSdpRsp(int socket, SocketState state, const u8* data, int len, void* userData) ;
+ static void OnSdpRsp(int socket, SocketState state, const u8* data, int len, void* userData) {
+ printf("\x1B[%dm", 35);
+ printf("OnSdpRsp(socket=%d, state=%d, len=%d)\n", socket, state, len);
+// printf("OnSdpRsp(socket=%d, state=%d, len=%d, freemem=%d)\n", socket, state, len, AvailableMemory(1));
+ SDPManager *self = (SDPManager*)userData;
+ if (state == SocketState_Open){
+ self->OnSdpRsp(data, len);
+ }
+ printf("\x1B[%dm", 0);
+ }
+
//this function is called when the SDP sockets receives data (see HCICallback in TestShell),
//currently does not happen because not forwarded from OnSdpRsp, can be used to handle multiple connections
static void OnSockCallback(int socket, SocketState state, const u8* data, int len, void* userData) ;
@@ -83,7 +102,10 @@
unsigned length(const unsigned char *el, unsigned &p);
unsigned getval(const unsigned char *p, int n) ;
unsigned parse (const unsigned char *el, unsigned count, sdp_data* &result, serv_rec* &record) ;
+ unsigned parseLight (const unsigned char *el, unsigned count, sdp_data* &result, serv_rec* &record) ;
int parseRsp(const unsigned char*rsp, int len) ;
+ void append(const unsigned char*rsp, int len) ;
+ void freeBuf();
};
#endif
\ No newline at end of file