#include <sys/types.h>
#include <bt/bt_defs.h>
#include <mhop/tp.h>
#include <mhop/ppp.h>
Transport initialization functions | |
#define | VCP_DATA_CB void (*data_cb) (u_char vc_handle, u_char* data, u_short len, u_char port_nr); |
Registration function for connection less data callback. The registered funciton is called on arrival of cl data. | |
#define | VCP_VC_CHANGE_CB void (*vc_change_cb) (u_char vc_handle, u_char type, u_char reason); |
Registration function for vc connection changes. The registered function is called if a new vc opens or an existing vc was closed. | |
void | tp_init (struct btstack *bt_stack, void(*rel_con_change_registration)(void(*cb)(u_char type, u_char detail, bt_con_handle_t con_handle))) |
Initializes the transport layer. | |
void | tp_register_vc_data_cb (void(*cb)(u_char vc_handle, u_char *data, u_short len)) |
Registration function for vc data callback. The registered function is called on arrival of vc data. | |
short | vcp_register_service (u_char port, VCP_DATA_CB, VCP_VC_CHANGE_CB, u_char pkt_processors) |
Defines | |
#define | VCP_NR_PORTS 10 |
#define | VCP_PPP_PORT 3 |
VC connection callback types and reasons | |
#define | VCP_CLOSE_LINK 2 |
VC close reason: normal close (by other side). | |
#define | VCP_CLOSE_NORMAL 1 |
VC close reason: link failure. | |
#define | VCP_CON_CLOSE 2 |
VC type: close. | |
#define | VCP_CON_OPEN 1 |
VC type: open. | |
TP error codes | |
Returned by tp_send_*_data() functions on failure. | |
#define | VCP_ERR_DEST 3 |
Destination invalid. | |
#define | VCP_ERR_PKT_LEN 2 |
Packet size too large. | |
#define | VCP_ERR_SEND 1 |
Send error. | |
VC Packets | |
#define | VCP_HEADER_LEN (2+2) |
virtual connection data packet header length | |
#define | VCP_MAX_PAYLOAD PPP_MAX_PAYLOAD - VCP_HEADER_LEN |
Functions | |
VCP API functions | |
void | vcp_close_vc (u_char vc_handle) |
Closes the virtual connection with handle vc_handle. | |
u_char * | vcp_get_data_pointer (vcp_pkt_t *pkt) |
Returns a pointer to the begin of payload data in a VC data packet. | |
void | vcp_open_vc (bt_addr_t target, u_char ttl) |
Opens a virtual connection to the target with address target. | |
u_char | vcp_send_data (vcp_pkt_t *pkt, u_char vc_handle, u_short len) |
Sends a VC data packet over the virtual connection with handle vc_handle. |
Registration function for connection less data callback. The registered funciton is called on arrival of cl data.
cb | Callback function to register. Fallowing arguments are passed to this function:
|
void tp_init | ( | struct btstack * | bt_stack, | |
void(*)(void(*cb)(u_char type, u_char detail, bt_con_handle_t con_handle)) | rel_con_change_registration | |||
) |
Initializes the transport layer.
bt_stack | Pointer to the btstack. | |
acl_com_stack | Pointer to the acl com stack. | |
rel_con_change_registration | Registration function for reliable connection changes. |
void vcp_close_vc | ( | u_char | vc_handle | ) |
Closes the virtual connection with handle vc_handle.
vc_handle | VC handle of the virtual connection to close |
u_char* vcp_get_data_pointer | ( | vcp_pkt_t * | pkt | ) |
Returns a pointer to the begin of payload data in a VC data packet.
pkt | Pointer to the bt_l2cap_pkt_t packet |
pkt
Opens a virtual connection to the target with address target.
target | Address of the target | |
ttl | Time to live |
Sends a VC data packet over the virtual connection with handle vc_handle.
To send a VC data packet, first use tp_get_vc_data_pointer(), fill in the data and then use this function.
pkt | Pointer to the bt_l2cap_pkt_t packet to send | |
vc_handle | VC handle of the virtual connection to use | |
len | Length of the data to send in bytes |