From BTnodes - A Distributed Environment for Prototyping Ad Hoc Networks

Documentation: BluetoothL2CAP

Using L2CAP connection-less together with regular L2CAP connection-oriented.


Requirements: CVS HEAD from 2007-02-15. All you need to do is initialize both l2cap and mhop/l2cap-cl/connection_mgr as you would if using only one of them. You need to specify the same packet types for both L2CAP variants as they both use ACL packets.

Initialization

Usage

Every Service has a PSM and a data callback function:

data callback function

 acl_pkt_buf_t* _data_cb(acl_pkt_buf_t* pkt_buf, 
                                   u_char* data,
                               u_short data_len, 
                             u_short service_nr, 
                                   void* cb_arg){
     // process pkt
     ...
     // free packet buffer
     return pkt_buf;
 }

service registration

 bt_psm_service_register(psmux, PSM, _data_cb, NULL);

send packets

 // alloc payload (individual length or max. L2CAP_CL_PKT_MAX_PAYLOAD
 u_char data[L2CAP_CL_PKT_MAX_PAYLOAD];

 // fill payload
 ...

 // send packet
 res = l2cap_cl_send_pkt(l2cap_cl_stack,
        		         handle, 
                                    psm, 
                                   data, 
                                 length);

Further reading


A more color-full introduction is here: jaws-introduction.pdf

Additional comments:

psmux The L2CAP connection-less specific packet dispatcher mhop/mhop_cl.c

Retrieved from http://www.btnode.ethz.ch/Documentation/BluetoothL2CAP
Page last modified on June 04, 2008, at 11:59 AM