\r
\r
/**\r
- * pointery na funkce, ktere se vykonavaji v zavislosti na parametru\r
+ * pointers to functions, which are executed depending on a parameter\r
*/\r
typedef int (*l2cap_code_fce_def)(uint8_t *bth_p, uint16_t size, int dev_num, int pos_chan);\r
l2cap_code_fce_def l2cap_code_fce[]={\r
#define L2CAP_SUM_FC (sizeof(l2cap_code_fce)/sizeof(l2cap_code_fce[0]))\r
\r
\r
-/*----------------------- funkce zavisle na code -----------------------------------*/\r
+/*----------------------- function depending on code -----------------------------------*/\r
\r
/**\r
-* funkce prohledava kanaly pripoj. zazizeni dev_num a hleda zadany kanal\r
+* Search the cannels of the connected device dev_num and search the channel dcid\r
*/\r
inline int l2cap_find_dcid(int dcid, int dev_num )\r
{\r
};\r
\r
\r
-/*------------------------------ pomocne funkce --------------------------------*/\r
+/*------------------------------ auxiliary functions --------------------------------*/\r
\r
int l2cap_add_to_send_buffer(uint8_t *bth_p)\r
{\r
{return 1;};\r
bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]=bth_p;\r
\r
- /*nastaveni pozice v poli command prikazu pro pristi prikaz. Moznost zapisu (adresa v poli = NULL)\r
+ /*set the position in command array for the next command. If it is possible to write there (if the pointer = NULL) is checked by the writer. .\r
+\r
+ nastaveni pozice v poli command prikazu pro pristi prikaz. Moznost zapisu (adresa v poli = NULL)\r
se overuje, az pri samotnem ukladani */\r
if(bth_com_buf_info.aktual<(LENCOMMAND-2)){bth_com_buf_info.aktual++;}\r
else{ bth_com_buf_info.aktual=0;};\r
\r
};\r
/**\r
-* neexistujici funkce - nemeli by nikdy nastat \r
+* Nonexisting function - should never happend \r
*/\r
int l2cap_none(uint8_t *bth_p, uint16_t size, int dev_num, int pos_chan)\r
{\r
\r
\r
/**\r
- * dekodovani signaling paketu a volani vyse napsanych fci (pointery na fce)\r
+ * decoding of the signaling packet and calling of the above functions\r
*/\r
int l2cap_signaling(uint8_t *bth_p, uint16_t size,int dev_num)\r
{\r
__bthtomc16((uint8_t*)&(bth_q.len),((uint8_t*)bth_p+L2CAP_CMD_HDR____len));\r
\r
if(bth_q.code<L2CAP_SUM_FC)\r
- { /*odskok na obsluznou fci*/\r
+ { /*jump to the handling functions*/\r
l2cap_code_fce[bth_q.code]((uint8_t*)bth_p+L2CAP_CMD_HDR_SIZE, bth_q.len,dev_num, 0);\r
return 0;\r
}\r
else {return -1;};\r
};\r
\r
-/*----------------------- funkce zavisle na code -----------------------------------*/\r
+/*----------------------- functions depending on code -----------------------------------*/\r
\r
/**\r
* Command reject\r
l2cap_conn_req bth_q;\r
if(bth_p==NULL)\r
{\r
+ /*the packet is built here - ie. this is the device that wants to create a new channel*/\r
/*zde se paket sestavuje - tj. jedna se o zarizeni, ktere chce vytvorit novy kanal*/\r
\r
}\r
else \r
{\r
- /*lokalni zarizeni obdrzelo paket 0x02*/\r
+ /*local device receives packet 0x02*/\r
__bthtomc16((uint8_t*)&(bth_q.psm),((uint8_t*)bth_p+L2CAP_CONN_REQ____psm));\r
__bthtomc16((uint8_t*)&(bth_q.scid),((uint8_t*)bth_p+L2CAP_CONN_REQ____scid));\r
+ /*SCID is in this case DCID, because sending side choosed thich channel as SCID. This is viewed from the point of view of \r
+ receiving device, so this is DCID. */\r
/*SCID je v tomto pripade DCID, protoze vysilajici strana si tento kanal zvolila jako SCID. Uloha je brana z\r
pohledu daneho zarizeni (ktere paket prijalo) tudiz se jedna o DCID*/\r
\r
- pos_chan=bth_add_chanal_dcid(dev_num, bth_q.scid); //pridam DCID vzdaleneho zarizeni\r
+ pos_chan=bth_add_chanal_dcid(dev_num, bth_q.scid); //add DCID of the remote device\r
\r
- /*sestavim paket, kterym odpovidam*/\r
+ /*build the response packet*/\r
l2cap_cod_conn_rsp(NULL,0,dev_num,pos_chan);\r
bth_local_info.busy=0;\r
};\r
l2cap_conn_rsp *l2cap_conn_response;\r
if(bth_p==NULL)\r
{\r
- /*zarizeni obdrzelo od vzdaleneho zarizeni paket 0x03*/\r
+ /*the device received packet 0x03 from the remote device*/\r
int hp_size=(HCI_PKT_SIZE+HCI_ACL_HDR_SIZE+L2CAP_HDR_SIZE+L2CAP_CMD_HDR_SIZE+L2CAP_CONN_RSP_SIZE);\r
bth_r=malloc(hp_size);\r
\r
typ_hci_paket=(uint8_t*)bth_r;\r
- hci_headr=(hci_acl_hdr *)(((uint8_t*)typ_hci_paket)+HCI_PKT_SIZE); //pointer on head\r
- l2cap_headr=(l2cap_hdr *)(((uint8_t*)hci_headr)+HCI_ACL_HDR_SIZE); //pointer on parametrs\r
+ hci_headr=(hci_acl_hdr *)(((uint8_t*)typ_hci_paket)+HCI_PKT_SIZE); //pointer to head\r
+ l2cap_headr=(l2cap_hdr *)(((uint8_t*)hci_headr)+HCI_ACL_HDR_SIZE); //pointer to parametrs\r
l2cap_cmd_headr=(l2cap_cmd_hdr *)(((uint8_t*)l2cap_headr)+L2CAP_HDR_SIZE);\r
l2cap_conn_response=(l2cap_conn_rsp *)(((uint8_t*)l2cap_cmd_headr)+L2CAP_CMD_HDR_SIZE);\r
/*------*/\r
store16(*((uint8_t*)l2cap_cmd_headr+L2CAP_CMD_HDR____code), L2CAP_CONN_RSP);\r
\r
\r
- if(pos_chan>-1) //kanal daneho zarizeni, jeste neexistuje, tj. zalozim ho\r
+ if(pos_chan>-1) //the channel of that device don't exists. We will create it\r
{\r
(bth_connected[dev_num])->scid[pos_chan]=(0x0040+pos_chan+1);\r
- /*dcin - vzdal. zarizeni, ktere */\r
+ /*dcin - remote device, which */\r
store_le16((uint16_t*)((uint8_t*)l2cap_conn_response+L2CAP_CONN_RSP____dcid),(0x0040+pos_chan+1));\r
}\r
else{\r
store_le16((uint16_t*)((uint8_t*)l2cap_cmd_headr+L2CAP_CMD_HDR____len),L2CAP_CONN_RSP_SIZE);\r
store_le16((uint16_t*)((uint8_t*)l2cap_conn_response+L2CAP_CONN_RSP____scid),((bths_connect_bluet*)bth_connected[dev_num])->dcid[pos_chan]);\r
\r
- if(l2cap_find_dcid(bth_q.scid, dev_num)>=0) //prohledam vsechna DCID (SCID vzdaleneho zarizeni, jeslti uz ho nepouziva)\r
+ if(l2cap_find_dcid(bth_q.scid, dev_num)>=0) //search all the DCID (SCID of remote device, if it is not used)\r
{\r
store_le16((uint16_t*)((uint8_t*)l2cap_conn_response+L2CAP_CONN_RSP____result),htobs(L2CAP_CR_SUCCESS));\r
store_le16((uint16_t*)((uint8_t*)l2cap_conn_response+L2CAP_CONN_RSP____status),htobs(L2CAP_CS_NO_INFO));\r
}\r
- else//zarizeni uz kanal pouziva, tj. odrekni spojeni s prislusnzym chyb. kodem\r
+ else//the device uses the channel, se reply with an apropriate error code\r
{\r
store_le16((uint16_t*)((uint8_t*)l2cap_conn_response+L2CAP_CONN_RSP____result),result);\r
store_le16((uint16_t*)((uint8_t*)l2cap_conn_response+L2CAP_CONN_RSP____status),status);\r
};\r
- /*pripravim data do vysilaciho bufferu*/\r
+ /*prepare data to sending buffer*/\r
return(l2cap_add_to_send_buffer(bth_r));\r
}\r
else\r
{\r
- /*lok. zarizeni vysila vzdalenemu zarizeni paket 0x03 - zada o kanal*/\r
+ /*local device sends to the remote device paket 0x03 - apply for a channel*/\r
};\r
return (-1);\r
};\r
{\r
__bthtomc16((uint8_t*)&(bth_q.dcid),((uint8_t*)bth_p+L2CAP_CONF_REQ____dcid));\r
__bthtomc16((uint8_t*)&(bth_q.flags),((uint8_t*)bth_p+L2CAP_CONF_REQ____flags));\r
- //jeste nejaka data .... - v nasem pripade se zadna nezpracovavaji\r
+ //yet some data .... - in our case, nothing is processed\r
/*------*/\r
pos_chan=bth_find_chanal_scid(dev_num, bth_q.dcid);\r
l2cap_cod_conf_rsp(NULL, 0, dev_num, pos_chan); //0x05\r
\r
- /***************sestavim paket, kterym posilam responce kod = 0x04 masterovi*************/\r
- /*nastaveni adres pro casti paketu + naplneni jednotlivych polozek*/\r
+ /***************build the packet, by which we send response code = 0x04 to the master*************/\r
+ /*setting of addresses for the parts of the packet + filling of inidividual fields*/\r
int hp_size=(HCI_PKT_SIZE+HCI_ACL_HDR_SIZE+L2CAP_HDR_SIZE+L2CAP_CMD_HDR_SIZE+L2CAP_CONF_REQ_SIZE);\r
bth_r=malloc(hp_size);\r
\r
typ_hci_paket=(uint8_t*)bth_r;\r
- hci_headr=(hci_acl_hdr *)(((uint8_t*)typ_hci_paket)+HCI_PKT_SIZE); //pointer on head\r
- l2cap_headr=(l2cap_hdr *)(((uint8_t*)hci_headr)+HCI_ACL_HDR_SIZE); //pointer on parametrs\r
+ hci_headr=(hci_acl_hdr *)(((uint8_t*)typ_hci_paket)+HCI_PKT_SIZE); //pointer to head\r
+ l2cap_headr=(l2cap_hdr *)(((uint8_t*)hci_headr)+HCI_ACL_HDR_SIZE); //pointer to parametrs\r
l2cap_cmd_headr=(l2cap_cmd_hdr *)(((uint8_t*)l2cap_headr)+L2CAP_HDR_SIZE);\r
l2cap_conf_request=(l2cap_conf_req *)(((uint8_t*)l2cap_cmd_headr)+L2CAP_CMD_HDR_SIZE);\r
/*------*/\r
\r
store_le16((uint16_t*)((uint8_t*)l2cap_conf_request+L2CAP_CONF_REQ____dcid),(bth_connected[dev_num])->dcid[pos_chan]);\r
store_le16((uint16_t*)((uint8_t*)l2cap_conf_request+L2CAP_CONF_REQ____flags),0);\r
- //posledni polozka jsou data - nebubu posilat v tomto paketu\r
+ //the last item are data - they are not sent in this packet\r
\r
- /******************* umisteni do vysilaciho bufferu **************************/\r
+ /******************* put it to send buffer **************************/\r
l2cap_add_to_send_buffer(bth_r);\r
return 0;\r
};\r
\r
if(bth_p==NULL)\r
{\r
- /*sestavim paket, kterym odpovidam*/\r
- /*nastaveni adres pro casti paketu + naplneni jednotlivych polozek*/\r
+ /*build the response packet*/\r
+ /*setup the adresses for parts of the packet + filling of individual fields*/\r
int hp_size=(HCI_PKT_SIZE+HCI_ACL_HDR_SIZE+L2CAP_HDR_SIZE+L2CAP_CMD_HDR_SIZE+L2CAP_CONF_RSP_SIZE);\r
bth_r=malloc(hp_size);\r
\r
store_le16((uint16_t*)((uint8_t*)l2cap_conf_response+L2CAP_CONF_RSP____scid),(bth_connected[dev_num])->dcid[pos_chan]);\r
store_le16((uint16_t*)((uint8_t*)l2cap_conf_response+L2CAP_CONF_RSP____flags),0);\r
store_le16((uint16_t*)((uint8_t*)l2cap_conf_response+L2CAP_CONF_RSP____result),0);\r
- //posledni polozka jsou data - nebubu posilat v tomto paketu\r
+ //posledni polozka jsou data - nebubu posilat v tomto paketu //same as in previous func\r
\r
\r
/******************* umisteni do vysilaciho bufferu **************************/\r
if(bth_connected[inx_handle]==NULL) return (-1);\r
if((bth_connected[inx_handle])->dcid[inx_chanal]==0) return (-1);\r
\r
- /*cteni z vysilaciho zasobniku, skusmo 1 znak*/\r
+ /*reading from sending buffer, try 1 character*/\r
zn=bth_inface_t_isr(0);\r
if(zn>=0)\r
{\r
handle=(handle | htobs(0x2000));\r
chanal = (bth_connected[inx_handle])->dcid[inx_chanal];\r
\r
- /*vytvoreni prostoru pro paket + prideleni adres pro jednotlive casti L2CAP paketu*/\r
+ /*make space for the packer + assign adresses for individual parts of L2CAP packet*/\r
hp_size=(HCI_PKT_SIZE+HCI_ACL_HDR_SIZE+L2CAP_HDR_SIZE+BTH_INFACE_BUF_LEN);\r
bth_r=malloc(hp_size);\r
\r
/*-----------------------------DATA FOR SENDING TO PC --------------------------*/\r
*((uint8_t*)data+size)=(uint8_t)zn;\r
size++;\r
- /*cyklicke cteni dalsich znaku a skladani do paketu*/\r
+ /*cyclic reading of the folowing characters and building of the packet*/\r
while ((zn=bth_inface_t_isr(0))>=0)\r
{\r
*((uint8_t*)data+size)=(uint8_t)zn;\r
size++;\r
};\r
}\r
- else {return (0);}; //data nejsou v zasobniku\r
+ else {return (0);}; //data are not in the queue\r
\r
-/*sestavim zbytek paketu, kterym odpovidam tj. naplneni jednotlivych polozek*/\r
+/*build the rest of the response packet ie. fill the fields*/\r
store16(*typ_hci_paket, HCI_ACLDATA_PKT);\r
store_le16((uint8_t*)hci_headr+HCI_ACL_HDR____handle,handle);\r
store_le16((uint8_t*)hci_headr+HCI_ACL_HDR____dlen,(htobs(L2CAP_CMD_HDR_SIZE)+size));\r