}\r
else\r
{\r
- /*status neni OK */\r
+ /*status is not OK */\r
free(bth_pole_adrr_check_packet[index]);\r
bth_pole_adrr_check_packet[index]=NULL;\r
- return((int)*((uint8_t*)bth_p+READ_BD_ADDR_RP____status)); //NOTE asi jsem tam pripisoval hvezdicku, uz nevim jiste, bylo to vcera >-]\r
+ return((int)*((uint8_t*)bth_p+READ_BD_ADDR_RP____status)); //NOTE probably I put * here, but I don't remember it. It was yesterday >-]\r
};\r
};\r
};\r
/*******************************************************************\r
bluetooth library\r
\r
- bth_command.c - command fce (bth specification) - build command\r
+ bth_command.c - command functions (bth specification) - build command\r
packet\r
\r
Copyright (C) 2006 by Petr Kovacik petr_kovacik@gmail.com\r
\r
bths_check_command *bth_find_end(bths_check_command *dyn_chan)\r
{\r
- bths_check_command *Pomocna;\r
+ bths_check_command *temp;\r
if(dyn_chan!=NULL)\r
{\r
- Pomocna=dyn_chan;\r
- while (Pomocna->next!=NULL)\r
+ temp=dyn_chan;\r
+ while (temp->next!=NULL)\r
{\r
- Pomocna=Pomocna->next; /*dam command prikaz do fronty*/\r
+ temp=temp->next; /*put the command to the queue*/\r
};\r
- return Pomocna;\r
+ return temp;\r
}\r
else\r
{\r
uint8_t *typ_hci_paket;\r
hci_command_hdr *hci_headr;\r
inquiry_cp *bth_cmd_packet;\r
- uint16_t i; //pocitani v cyklu\r
+ uint16_t i; //used in loops\r
/*-------------------------------------------------------------------------------*/\r
-/*-- urceni potreb. velikostipro command prikaz v buff. a zjisteni zda se vejde--*/\r
+/*-- determine the size of memory needed for command in buff and determine if it fit there */\r
+\r
\r
if(bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)\r
{return 1;};\r
-/*nastaveni adres pro casti paketu + naplneni jednotlivych polozek*/\r
+/*setup adresses for packet parts + filling of inidividual fields*/\r
int hp_size=(sizeof(uint8_t)+HCI_COMMAND_HDR_SIZE+INQUIRY_CP_SIZE);\r
\r
bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);\r
- typ_hci_paket=(uint8_t*)bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]; //pozice v buff, ktera je prirazena paketu\r
- hci_headr=(hci_command_hdr *)(((uint8_t*)typ_hci_paket)+HCI_PKT_SIZE); //pointer on head\r
- bth_cmd_packet=(inquiry_cp *)(((uint8_t*)hci_headr)+HCI_COMMAND_HDR_SIZE); //pointer on parametrs\r
+ typ_hci_paket=(uint8_t*)bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]; //possition in buff, which is assigned to the packet\r
+ hci_headr=(hci_command_hdr *)(((uint8_t*)typ_hci_paket)+HCI_PKT_SIZE); //pointer to head\r
+ bth_cmd_packet=(inquiry_cp *)(((uint8_t*)hci_headr)+HCI_COMMAND_HDR_SIZE); //pointer to parametrs\r
\r
store16(*typ_hci_paket, HCI_COMMAND_PKT);\r
store_le16((uint8_t*)hci_headr+HCI_COMMAND_HDR____opcode,htobs(cmd_opcode_pack(OGF_LINK_CTL, OCF_INQUIRY)));\r
store16(*((uint8_t*)hci_headr+HCI_COMMAND_HDR____plen),INQUIRY_CP_SIZE);\r
\r
/*pokud neni uvedeno lap zvoli se univerzlni*/\r
+ /*if lap is not specified, the universal one is chosen*/\r
store_le16((uint8_t*)bth_cmd_packet+INQUIRY_CP____length,length);\r
store_le16((uint8_t*)bth_cmd_packet+INQUIRY_CP____num_rsp,rsp);\r
\r
for(i=0; i<3; i++) {store_le16((uint8_t*)bth_cmd_packet+INQUIRY_CP____lap+i,*(lap+2-i));};\r
};\r
\r
+/*setup position in command array for the next command. Possibility of writing there (address in array = NULL) is checked when writing is realy done.*/\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
uint8_t *typ_hci_paket;\r
hci_command_hdr *hci_headr;\r
set_conn_ptype_cp *bth_cmd_packet;\r
+/*-- determine the size of memory needed for command in buff and determine if it fit there */\r
/*-------------------------------------------------------------------------------*/\r
/*-- urceni potreb. velikostipro command prikaz v buff. a zjisteni zda se vejde--*/\r
\r
if(bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)\r
{return 1;};\r
-/*nastaveni adres pro casti paketu + naplneni jednotlivych polozek*/\r
+/*setup adresses for packet parts + filling of inidividual fields*/\r
int hp_size=(sizeof(uint8_t)+HCI_COMMAND_HDR_SIZE+SET_CONN_PTYPE_CP_SIZE);\r
bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);\r
typ_hci_paket=(uint8_t*)bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]; //pozice v buff, ktera je prirazena paketu\r
uint8_t *typ_hci_paket;\r
hci_command_hdr *hci_headr;\r
disconnect_cp *bth_cmd_packet;\r
+/*-- determine the size of memory needed for command in buff and determine if it fit there */\r
/*-------------------------------------------------------------------------------*/\r
/*-- urceni potreb. velikostipro command prikaz v buff. a zjisteni zda se vejde--*/\r
\r
if(bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)\r
{return 1;};\r
-/*nastaveni adres pro casti paketu + naplneni jednotlivych polozek*/\r
+/*setup adresses for packet parts + filling of inidividual fields*/\r
int hp_size=HCI_PKT_SIZE+HCI_COMMAND_HDR_SIZE+DISCONNECT_CP_SIZE;\r
\r
bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);\r
uint8_t *typ_hci_paket;\r
hci_command_hdr *hci_headr;\r
write_link_policy_cp *bth_cmd_packet;\r
+/*-- determine the size of memory needed for command in buff and determine if it fit there */\r
/*-------------------------------------------------------------------------------*/\r
/*-- urceni potreb. velikostipro command prikaz v buff. a zjisteni zda se vejde--*/\r
\r
if(bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)\r
{return 1;};\r
-/*nastaveni adres pro casti paketu + naplneni jednotlivych polozek*/\r
+/*setup adresses for packet parts + filling of inidividual fields*/\r
int hp_size=HCI_PKT_SIZE+HCI_COMMAND_HDR_SIZE+WRITE_LINK_POLICY_CP_SIZE;\r
\r
bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);\r
/*------------------------ parts of packet-----------------------*/\r
uint8_t *typ_hci_paket;\r
hci_command_hdr *hci_headr;\r
+/*-- determine the size of memory needed for command in buff and determine if it fit there */\r
/*-------------------------------------------------------------------------------*/\r
/*-- urceni potreb. velikostipro command prikaz v buff. a zjisteni zda se vejde--*/\r
\r
if(bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)\r
{return 1;};\r
-/*nastaveni adres pro casti paketu + naplneni jednotlivych polozek*/\r
+/*setup adresses for packet parts + filling of inidividual fields*/\r
int hp_size=HCI_PKT_SIZE+HCI_COMMAND_HDR_SIZE;\r
\r
bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);\r
int bth_accept_conn_req_cp(bdaddr_t *bdaddr) /*0x01 - 0x0009*/\r
{\r
/*------------------------ parts of packet-----------------------*/\r
- uint8_t *typ_hci_paket;\r
+ uint8_t *typ_hci_paket; //FIXME: hjkhjkh\r
hci_command_hdr *hci_headr;\r
accept_conn_req_cp *bth_cmd_packet;\r
+/*-- determine the size of memory needed for command in buff and determine if it fit there */\r
/*-------------------------------------------------------------------------------*/\r
/*-- urceni potreb. velikostipro command prikaz v buff. a zjisteni zda se vejde--*/\r
\r
if(bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)\r
{return 1;};\r
-/*nastaveni adres pro casti paketu + naplneni jednotlivych polozek*/\r
+/*setup adresses for packet parts + filling of inidividual fields*/\r
int hp_size=(sizeof(uint8_t)+HCI_COMMAND_HDR_SIZE+ACCEPT_CONN_REQ_CP_SIZE);\r
\r
bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);\r
uint8_t *typ_hci_paket;\r
hci_command_hdr *hci_headr;\r
write_page_activity_cp *bth_cmd_packet;\r
+/*-- determine the size of memory needed for command in buff and determine if it fit there */\r
/*-------------------------------------------------------------------------------*/\r
/*-- urceni potreb. velikostipro command prikaz v buff. a zjisteni zda se vejde--*/\r
\r
if(bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)\r
{return 1;};\r
-/*nastaveni adres pro casti paketu + naplneni jednotlivych polozek*/\r
+/*setup adresses for packet parts + filling of inidividual fields*/\r
int hp_size=(sizeof(uint8_t)+HCI_COMMAND_HDR_SIZE+WRITE_PAGE_ACTIVITY_CP_SIZE);\r
\r
bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);\r
uint8_t *typ_hci_paket;\r
hci_command_hdr *hci_headr;\r
write_inq_activity_cp *bth_cmd_packet;\r
+/*-- determine the size of memory needed for command in buff and determine if it fit there */\r
/*-------------------------------------------------------------------------------*/\r
/*-- urceni potreb. velikostipro command prikaz v buff. a zjisteni zda se vejde--*/\r
\r
if(bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)\r
{return 1;};\r
-/*nastaveni adres pro casti paketu + naplneni jednotlivych polozek*/\r
+/*setup adresses for packet parts + filling of inidividual fields*/\r
int hp_size=(sizeof(uint8_t)+HCI_COMMAND_HDR_SIZE+WRITE_PAGE_ACTIVITY_CP_SIZE);\r
bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);\r
typ_hci_paket=(uint8_t*)bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]; //pozice v buff, ktera je prirazena paketu\r
/*------------------------ parts of packet-----------------------*/\r
uint8_t *typ_hci_paket;\r
hci_command_hdr *hci_headr;\r
+/*-- determine the size of memory needed for command in buff and determine if it fit there */\r
/*-------------------------------------------------------------------------------*/\r
/*-- urceni potreb. velikostipro command prikaz v buff. a zjisteni zda se vejde--*/\r
\r
if(bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)\r
{return 1;};\r
-/*nastaveni adres pro casti paketu + naplneni jednotlivych polozek*/\r
+/*setup adresses for packet parts + filling of inidividual fields*/\r
int hp_size=(sizeof(uint8_t)+HCI_COMMAND_HDR_SIZE);\r
bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);\r
typ_hci_paket=(uint8_t*)bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]; //pozice v buff, ktera je prirazena paketu\r
hci_command_hdr *hci_headr;\r
uint8_t *bth_cmd_packet;\r
\r
+/*-- determine the size of memory needed for command in buff and determine if it fit there */\r
/*-------------------------------------------------------------------------------*/\r
/*-- urceni potreb. velikostipro command prikaz v buff. a zjisteni zda se vejde--*/\r
\r
if(bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)\r
{return 1;};\r
-/*nastaveni adres pro casti paketu + naplneni jednotlivych polozek*/\r
+/*setup adresses for packet parts + filling of inidividual fields*/\r
int hp_size=(sizeof(uint8_t)+HCI_COMMAND_HDR_SIZE+WRITE_SCAN_ENABLE_SIZE);\r
bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);\r
typ_hci_paket=(uint8_t*)bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]; //pozice v buff, ktera je prirazena paketu\r
return -1;\r
};\r
\r
+//FIXME: All the czech comments are the same as in the first function.\r
+\r
\r
\r
/**\r
- * chyby generovane bth zarizenim\r
+ * Errors generated by a bluetooth device\r
*/\r
\r
static struct {\r
};\r
\r
/**\r
-* vypis chyby na terminal pres RS232\r
+* Output an error to a terminal unsing rs232\r
*/\r
void bth_error_detect_status(uint8_t status_num)\r
{\r
while(*(message+i)!=0)\r
{\r
#ifdef BTH_LX\r
- sci_rs232_sendch(*(message+i),sci_rs232_chan_default); //do PC\r
+ sci_rs232_sendch(*(message+i),sci_rs232_chan_default); //to PC\r
#endif\r
i++;\r
};\r
};\r
\r
/**\r
- * chyby programu - nutno upravit navratove parametry - sedi jenom 0 a 3\r
+ * errors in program - it is necessary to modify return parameters - matches only 0 and 3\r
*/\r
static struct {\r
uint8_t error_code;\r
char *error_doc;\r
}event_command[] = {\r
{ 0x00, "Status OK" },\r
- { 0x01, "nespecifikovana chyba" },\r
- { 0x02, "potvrzovaci fronta prazdna" },\r
- { 0x03, "fce nenapsana" },\r
+ { 0x01, "unspecified error" },\r
+ { 0x02, "confirmation queue is empty" },\r
+ { 0x03, "function is not implemented" },\r
};\r
\r
\r
\r
/**\r
- * vypis chyby na terminal pres RS232\r
+ * Output an error to terminal through RS232\r
*/\r
void bth_error_detect_event(uint8_t status_num)\r
{\r
\r
/*********************************************************************************/\r
\r
-/*navratove hodnoty\r
- 0 = OK - prikaz odstranen z fronty\r
- -1 = fronta prohledana, ale nebyl tam nalezen hledany OBCOD\r
- +num = index overovane polozky v poli "bth_pole_adrr_check_packet" s hledanym obcodem\r
+/*return values\r
+ 0 = OK - command removed from the queue\r
+ -1 = the queue was searched but the OPCODE was not found\r
+ +num = an index of verified item in array "bth_pole_adrr_check_packet" with the searched opcode\r
*/\r
int bth_del_event(uint16_t opcode)\r
{\r
};\r
\r
/****************************************************************************/\r
-/*------------------------ JEDNOTLIVE EVENT FUNKCE -------------------------*/\r
+/*------------------------ INDIVIDUAL EVENT FUNCTIONS ----------------------*/\r
/****************************************************************************/\r
/****************************************************************************/\r
-/*navratovo hodnoty\r
- 0 = vse OK\r
- 1 = polozka nenalezena\r
- 2 = v potvrzovaci fronte nebyly zadne prikazy k potvrzeni\r
- 3 = status vykazuje chybu prikazu\r
+/*returned values\r
+ 0 = everything OK\r
+ 1 = field not found\r
+ 2 = there was no commands in the confirmation queue to confirm\r
+ 3 = status embody an error of the command\r
*/\r
-int bth_evt_none(uint8_t *bth_p, uint8_t size) //fce s neex. indexem evt codu\r
+int bth_evt_none(uint8_t *bth_p, uint8_t size) //func with nonexisting index of event code\r
{\r
return -4;\r
};\r
bths_connect_bluet *bth_q;\r
int j;\r
\r
- for(j=0; j<=8;j++) //8 moznych zarizeni, se kterymi lze komunikovat\r
+ for(j=0; j<=8;j++) //8 possible devices, witch which we can comunicate\r
{\r
if(bth_connected[j]==NULL)\r
{break;};\r
}\r
- if(j==9){return (-1);}; //je mozno komunikovat pouze s 8-mi zarizenimi, toto je devate\r
- /*uvedu zarizeni do seznamu pripojenych zarizeni*/\r
+ if(j==9){return (-1);}; //it is possible to communicate with 8 devices at maximum. This one is the 9th one.\r
+ /* Add the device to the list od connected devices.*/\r
bth_connected[j]=(bths_connect_bluet*)calloc(1,sizeof(bths_connect_bluet));\r
bth_q=(bths_connect_bluet*)bth_connected[j];\r
- /*naplnim strukturu pripojeneho zarizeni informacemi o vzdalenem bth*/\r
+ /*Fill the structure of the connected device with information on remote device*/\r
memcpy(&(bth_q->bdaddr),(uint8_t*)bth_p+EVT_CONN_COMPLETE____bdaddr,sizeof(bdaddr_t));\r
// store_le16(&(bth_q->handle),(uint16_t)*(uint16_t*)((uint8_t*)bth_p+EVT_CONN_COMPLETE____handle));\r
__bthtomc16((uint8_t*)&(bth_q->handle),((uint8_t*)bth_p+EVT_CONN_COMPLETE____handle));\r
store16(bth_q->link_type,*((uint8_t*)bth_p+EVT_CONN_COMPLETE____link_type));\r
store16(bth_q->encr_mode,*((uint8_t*)bth_p+EVT_CONN_COMPLETE____encr_mode));\r
\r
- bth_cmd_write_link_policy_settings(bth_q->handle,htobs(0x000f)); //odpoved\r
+ bth_cmd_write_link_policy_settings(bth_q->handle,htobs(0x000f)); //reply\r
return (*((uint8_t*)bth_p+EVT_CONN_COMPLETE____status));\r
};\r
\r
{\r
bdaddr_t bdaddr;\r
// evt_conn_request bth_q;\r
- /*BD adresa zadajiciho zarizeni*/\r
+ /*BD address of requesting device*/\r
memcpy(&bdaddr,(uint8_t*)bth_p+EVT_CONN_REQUEST____bdaddr,sizeof(bdaddr_t));\r
// if(bth_seach_bdaddr(&bdaddr,&(bth_accept_bd_addr[0]),1));\r
bth_accept_conn_req_cp(&bdaddr);\r
}\r
else\r
{\r
- if(size-EVT_CMD_COMPLETE_SIZE==1) /*jedna se pouze o potvrzeni - status*/\r
+ if(size-EVT_CMD_COMPLETE_SIZE==1) /* this is just a confirmation - status*/\r
{\r
if(*((uint8_t*)bth_p+3)==0)\r
{\r
free(bth_pole_adrr_check_packet[index]);\r
bth_pole_adrr_check_packet[index]=NULL;\r
bth_local_info.busy=0;\r
- return 0; //prikaz probehl bez komplikaci\r
+ return 0; //no complications was encountered during command execution\r
}\r
else\r
{\r
- /*status neni OK - nastala chyba - odeslany comand prikaz je stale ve fronte k potvrzeni*/\r
+ /*status is not OK - an error occured - the sent command is still in the confirmation queue */\r
free(bth_pole_adrr_check_packet[index]);\r
bth_pole_adrr_check_packet[index]=NULL;\r
bth_local_info.busy=0;\r
}\r
else\r
{\r
- /*rozdelim obcode na OGF a OCF a prevedu na jednobytovou promenou*/\r
+ /*I split to obcode to OGF and OCF and convert it to an one-byte variable*/\r
// store_le16(&opcode,*(uint16_t*)((uint8_t*)bth_p+EVT_CMD_COMPLETE____opcode));\r
__bthtomc16((uint8_t*)&(opcode),((uint8_t*)bth_p+EVT_CMD_COMPLETE____opcode));\r
\r
case 0x02 :\r
bth_local_info.busy=0;\r
if(ocf<BTH_OGF_02_FC)\r
- return (bth_info_fce_ogf_02[ocf](((uint8_t*)bth_p+EVT_CMD_COMPLETE____opcode+2),size-EVT_CMD_COMPLETE_SIZE)); //cislo 0x00 je smysleno\r
+ return (bth_info_fce_ogf_02[ocf](((uint8_t*)bth_p+EVT_CMD_COMPLETE____opcode+2),size-EVT_CMD_COMPLETE_SIZE)); //the number 0x00 is a random guess\r
else return (-4);\r
case 0x03 :\r
bth_local_info.busy=0;\r
if(ocf<BTH_OGF_03_FC)\r
- return (bth_info_fce_ogf_03[ocf](((uint8_t*)bth_p+EVT_CMD_COMPLETE____opcode+2),size-EVT_CMD_COMPLETE_SIZE)); //cislo 0x00 je smysleno\r
+ return (bth_info_fce_ogf_03[ocf](((uint8_t*)bth_p+EVT_CMD_COMPLETE____opcode+2),size-EVT_CMD_COMPLETE_SIZE)); //the number 0x00 is a random guess\r
else return (-4);\r
\r
case 0x04 :\r
bth_local_info.busy=0;\r
if(ocf<BTH_OGF_04_FC)\r
- return (bth_info_fce_ogf_04[ocf](((uint8_t*)bth_p+EVT_CMD_COMPLETE____opcode+2),size-EVT_CMD_COMPLETE_SIZE)); //cislo 0x00 je smysleno\r
+ return (bth_info_fce_ogf_04[ocf](((uint8_t*)bth_p+EVT_CMD_COMPLETE____opcode+2),size-EVT_CMD_COMPLETE_SIZE)); //the number 0x00 is a random guess\r
else return (-4);\r
\r
};\r
}\r
else\r
{\r
- if(size-EVT_CMD_STATUS_SIZE==0) /*jedna se pouze o potvrzeni - status*/\r
+ if(size-EVT_CMD_STATUS_SIZE==0) /*this is just a confirmation - status*/\r
{\r
if(bth_q.status==0)\r
{\r
}\r
else\r
{\r
- /*status neni OK - nastala chyba - odeslany comand prikaz je stale ve fronte k potvrzeni*/\r
+ /*status is not OK - an error occured - the sent command is still in the confirmation queue */\r
free(bth_pole_adrr_check_packet[index]);\r
bth_pole_adrr_check_packet[index]=NULL;\r
};\r
}\r
else\r
{\r
- /*rozdelim obcode na OGF a OCF a prevedu na jednobytovou promenou*/\r
+ /*rozdelim obcode na OGF a OCF a prevedu na jednobytovou promenou*/ //same comment as in previous function\r
ogf=(uint8_t)cmd_opcode_ogf((uint16_t)*(uint16_t*)((uint8_t*)bth_p+EVT_CMD_COMPLETE____opcode));\r
ocf=(uint8_t)cmd_opcode_ocf((uint16_t)*(uint16_t*)((uint8_t*)bth_p+EVT_CMD_COMPLETE____opcode));\r
+/*This is a little more complicated cmd_status, which stores data inside and not the end. Other functions are split according to the obcode. Currently, functions are not implemented, only the "guidepost" is done.*/\r
/*jedna se o slozitejsi cmd_status, ktery sebou nese i data, nikoliv zaver, dalsi fce jsou deleny podle\r
obcodu. Fce nejsou napsany, je udelany pouze rozcestnik*/\r
switch(ogf) \r
case 0x04 : break;\r
};\r
};\r
- bth_local_info.busy=0; //NOTE predelat, neni vzdycky pravda\r
+ bth_local_info.busy=0; //NOTE do it differently, not always true\r
\r
};\r
return(bth_q.status);\r
uint16_t handle,num_pkt;\r
int i,j;\r
store16(bth_q.num_hndl,*((uint8_t*)bth_p+EVT_NUM_COMP_PKTS____num_hndl));\r
+/*Search through all devices with which the communications was started???*/\r
/*prohledam vsechna zarizeni, se kterymi mam uzavrenou komunikaci*/\r
for(j=0; j<(bth_q.num_hndl);j++)\r
{\r
// store_le16(&bth_q.max_slots,*((uint16_t*)((uint8_t*)bth_p+EVT_MAX_SLOTS_CHANGE____max_slots)));\r
__bthtomc16((uint8_t*)&(bth_q.max_slots),(uint8_t*)bth_p+EVT_MAX_SLOTS_CHANGE____max_slots);\r
\r
+/*Search through all devices with which the communications was started???*/\r
/*prohledam vsechna zarizeni, se kterymi mam uzavrenou komunikaci*/\r
for(i=0;i<8;i++)\r
{\r
__bthtomc16((uint8_t*)&(bth_q.ptype),(uint8_t*)bth_p+EVT_CONN_PTYPE_CHANGED____ptype);\r
\r
dev_num=bth_find_conected_dev(bth_q.handle);\r
-//bth_local_info.pkt_type; - localni info o paketech\r
-// Change_Connection_Packet_Type - cmd prikaz, kterym se pripadne daji nastavit svoje packety\r
+//bth_local_info.pkt_type; - local info on packets\r
+// Change_Connection_Packet_Type - command, which can in case of need setup its packets\r
+//skterym se pripadne daji nastavit svoje packety\r
if(dev_num>-1);\r
{\r
bth_connected[dev_num]->ptype=bth_q.ptype;\r
memcpy(&(bth_q.bdaddr),(uint8_t*)bth_p+EVT_PSCAN_REP_MODE_CHANGE____bdaddr,sizeof(bdaddr_t));\r
store16(bth_q.pscan_rep_mode,*((uint8_t*)bth_p+EVT_PSCAN_REP_MODE_CHANGE____pscan_rep_mode));\r
\r
+ /*Search through all devices with which the communications was started, needs to be written up */\r
/*prohledam vsechna zarizeni dle BDADDR, se kterymi mam uzavrenou komunikaci -NUTNO DOPSAT NOTE*/\r
//memcpy\r
\r
#include <periph/sci_rs232.h>
+/* the number of communication structures i.e. how many channels can be used for communication. It alse specifies howmany
+ independent couples of I/O buffers is here.*/
/*pocet komunikacnich struktur - tj. pres kolik kanalu je mozno komunikovat,
to zaroven znamena, kolik je nezavislych dvojic I/O bufferu*/
bth_inface_info_t bth_inface_chan_array[BTH_INFACE_CHANAL];
int bth_inface_setup(int chan)
{
bth_inface_info_t *bth_inface;
- bth_inface = &(bth_inface_chan_array[chan]); //mnozstvi komunikacnich rozhranni bth - PC
+ bth_inface = &(bth_inface_chan_array[chan]); // the number of communication interfaces bth - PC
bth_inface->bth_inface_que_in.buf_beg = bth_inface->bth_inface_buff_in;
bth_inface->bth_inface_que_in.buf_end = bth_inface->bth_inface_que_in.buf_beg+BTH_INFACE_BUF_LEN;
bth_inface->bth_inface_que_in.ip = bth_inface->bth_inface_que_in.buf_beg;
bths_command_buf_info bth_check_buf_info={LENCOMMAND,0,0};
/***********************************************************************************/
-/*kontroluje synchoronizaci prijimanych dat pomoci TPU jednotky*/
+/*FIXME this check synchronisation of received data using TPU unit of CPU*/
uint8_t bth_controll_flag=0;
/**-------------------------------------------------------------------------------*/
-/*----- odeslani command prikazu, pokud je local bluetooth volny k odeslani------*/
-/* 0 = data presunuta do SCI bufferu = budou odeslana, bluetooth zarizeni je volne
- 1 = prikaz se nepovedlo presunout do SCI bufferu, ale bluet device je volne
- 2 = bluetooth zarizeni je zamestnane, tj. data se nepresunula do bufferu
- 3 = v potvrzovacim zasobniku neni uz misto*/
+/*FIXME ----- sending of command, if the local bluetooth is free (ready to send)------*/
+/* 0 = data moved to SCI buffer = they will be sent, bluetooth device is free
+ 1 = it wasn't possible to move tha command to SCI bufferu, but bluet device is free
+ 2 = bluetooth device is busy, ie. data were not moved to the bufferu
+ 3 = there is no space left in confirmation queue*/
/**
+ * After this function is called, the packet, which is in the command queue, is sent. If there is no new
+ * packet or the device is busy, nothing is done.
+ *
* Po zavolani funkce, se odesle paket, ktery je zarazen ve fronte paketu k odeslani (bth zazizeni je
* volne), pokud neni novy paket nebo zazizeni neni volne, nic se nevykona
*/
int i;
int hp_size;
if(bth_local_info.busy!=0)
- {return 1;}; //zarizeni neni volne
+ {return 1;}; //device is busy
if(bth_com_buf_info.aktual==bth_com_buf_info.sent) //PRAVDEPODOBNE neni co odesilat
{
if(bth_com_buf_info.sent<(LENCOMMAND-2))
{
if(bth_pole_adrr_comm_packet[bth_com_buf_info.sent+1]==NULL)
- {return 1;}; //URCITE neni co odesilat
+ {return 1;}; //There is certainly nothing to send
}
else
{
if(bth_pole_adrr_comm_packet[0]==NULL)
- {return 1;}; //URCITE neni co odesilat
+ {return 1;}; //There is certainly nothing to send
};
};
- /*bth_send_packet(AdrOdkud,kolikBytu;)*/
+ /*bth_send_packet(AdrFrom,howmanyBytes;)*/
switch(*(uint8_t*)bth_pole_adrr_comm_packet[bth_com_buf_info.sent])
{
case HCI_ACLDATA_PKT:
case HCI_COMMAND_PKT:
hp_size=((uint16_t)*(((uint8_t*)bth_pole_adrr_comm_packet[bth_com_buf_info.sent])+HCI_PKT_SIZE+2)+HCI_COMMAND_HDR_SIZE+HCI_PKT_SIZE);
if(!(bth_send_packet(bth_pole_adrr_comm_packet[bth_com_buf_info.sent],hp_size)))
- {/*odeslano - zaradim prikaz k moznosti potvrzeni*/
+ {/*sent - add the command to allow confirmation*/
for(i=0; i<LENCOMMAND; i++)
{
if(bth_pole_adrr_check_packet[i]==NULL)
{
bth_pole_adrr_check_packet[i]=bth_pole_adrr_comm_packet[bth_com_buf_info.sent];
bth_pole_adrr_comm_packet[bth_com_buf_info.sent]=NULL;
- /*nastavim adresu pro pristi command prikaz - princip kruhove zasobniku*/
+ /*set the address for the next command - principle of ring buffer*/
if(bth_com_buf_info.sent<(LENCOMMAND-2)){bth_com_buf_info.sent++;}
else{ bth_com_buf_info.sent=0;};
return 0;
/**
- * Pomocna funkce
- * Prevod hexa znaku do tisknutelne podoby. V tomto tvaru se odesle po seriov. rozhranni do PC
+ * Auxiliary function
+ * Convert hexadecimal character to ASCII. It is then sent to serial line
*/
-
+//*************************** bth_conv_char_text *****************************
+// used to convers int into ascii letter and print it on serial
+// INPUT zn: interger to convert and print
+// OUTPUT :none
+//***************************************************************************
void bth_conv_char_text(uint8_t zn)
{ uint8_t map_leters[]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
uint8_t val;
/**
- *Funkce odesle data o velikosti hp_size od adresy hp do bth (UART)
+ //FIXME
+ *Sends data of the size hp_size from address hp to the bluetooth device (UART)
*/
int bth_send_packet(uint8_t *hp, uint16_t hp_size)
{
int zn,i;
- /*je bluetooth zarizeni volne, nebo zamestnano predchozim prikazem?*/
+ /*is bluetooth device free, or is it busy by the previous command?*/
if(bth_local_info.busy==0)
{
#ifndef BTH_LX
};
#endif
bth_local_info.busy=1;
- return(0); //vsechno odeslano ==== OK =====
+ return(0); //everything sent ==== OK =====
}
else
{
- return 2; //zamestnane
+ return 2; //busy
};
};
/**
- *Funkce vlozi znak do fronty
+ *Inserts a character to the queue
*/
inline int bth_que_put(bth_que_t *q, int c)
{
uint8_t *p;
- p=q->ip; //nastav se na aktual pozici v souboru
- *(p++)=c; //na nasledujici pam. bunku uloz znak
- if(p==q->buf_end) return -1;//buffer neni kruhovy p=q->buf_beg;
+ p=q->ip; //FIXME set us to the actual position in the file
+ *(p++)=c; //store the character to the next byte
+ if(p==q->buf_end) return -1;//this is not the ring buffer p=q->buf_beg;
// if(p==q->op) return -1;
q->ip=p;
- return 0; //pokud nejsou problemy, vrat znak, jinak -1
+ return 0; //in case of success return the character, otherwise -1
}
/**
- *prijaty HCI datovy paket je zaslan jako point to point
+//FIXME
+ *received HCI data packet is sent as point to point
*/
int bth_pkt_type_pointopoint(uint16_t handle, uint8_t bound_flag, uint8_t *bth_p, uint16_t size)
case 0x02:
return(0);
};
- /*skutecna nefalcovana data ...*/
- /*musim najit kanal s cislem cid pro zarizeni bth_dev_num*/
+ /*FIXME real data ...*/
+ /*We have to find the channel with the CID number for device bth_dev_num*/
if(bth_find_chanal(bth_dev_num, bth_l2cap_packet.cid)>-1)
{
- /*TADY JSOU DOSLA DATA, KTERA UZ NEJSOU KONFIGURACNI*/
+ /*here are the received data, which are not used for confguration */
bth_data=(uint8_t*)bth_p+L2CAP_HDR_SIZE;
// VypisHexa((void*)((uint8_t*)bth_data+i),1);
}else
{
- /*zasobnik plny, neni schopen prijmout dalsi znaky*/
+ /*queue is full, neni schopen prijmout dalsi znaky*/
// sci_rs232_sendch('.',sci_rs232_chan_default); //do PC
};
};
return(-5);
};
return(-1);
- case 0x40: return(-3); /*next data packet L2CAP*/ /*funkce neni rozepsana, prijmam jen 1pkt zpravy*/
+ case 0x40: return(-3); /*next data packet L2CAP*/ /*function is not written, I receive only one pakcet of the message*/
case 0x30: return (-4); /*Reserved for future use*/
case 0x00: return (-4); /*Reserved for future use*/
};
/**
- *prijaty HCI datovy paket je zaslan jako broadcast (nedopsana funkce)
+ *Received HCI data packet is sent as broadcast (not finished function)
*/
int bth_pkt_type_broadcast(uint16_t handle, uint8_t bound_flag, uint8_t *bth_p, uint16_t size)
{
/**
- *prijaty HCI datovy paket je zaslan vramci picosite (nedopsana funkce)
+ *Received HCI data packet is send to piconet (not finished function)
*/
int bth_pkt_type_piconet(uint16_t handle, uint8_t bound_flag, uint8_t *bth_p, uint16_t size)
{
/**
- *budouci vyuziti (nedopsana funkce)
+ *Reserved for future (not finished)
*/
int bth_pkt_type_reserved(uint16_t handle, uint8_t bound_flag, uint8_t *bth_p, uint16_t size)
{
/****************************************************************************/
/**
- *pointry na funkce. Funkce jsou volany podle prijateho datoveho HCI peketu
+ *pointers to functions. Functions are called according to the received HCI pakcet
*/
typedef int (*bth_kind_pkt)(uint16_t handle, uint8_t bound_flag, uint8_t *bth_p, uint16_t size);
bth_kind_pkt bth_char_pkt_fce[]={
/**
- *pointry na funkce. Funkce jsou volany podle event codu, dekodovaneho z prijateho event HCI peketu
+ *pointrs to functions. Functions are called according to the event code, decoded from the received HCI packet
*/
typedef int (*bth_p_ivent_fce)(uint8_t *bth_p, uint8_t size);
bth_p_ivent_fce bth_event_array_fce[]={bth_evt_none,bth_evt_inquiry_complete, bth_evt_inquiry_result,
/**
- *Hlavni funkce, ktera ulozi prijaty znak "c" (od bth) ulozi ho do vstupni fronty, zkontroluje zda-li
- * je paekt cely a pokud ano, tak zavola funkce pro jeho zpracovani (pro ACL HCI a pro Event HCI)
+ *The main function, which stores the received character "c" (from bth) to the input queue, checks if there is the whole pakcet in the queue and if so, it calls functions for processing the packet. (for ACL HCI and for Event HCI)
*/
int bth_recieve_packet(int c)
{
VypisHexa((uint8_t*)&c,1);
#endif
//VypisHexa((uint8_t*)&c,1);
- bth_que_put(&bth_rs232_que_in, c); //ulozim prijaty znak do zasobniku
- typ_paket=((uint8_t*)bth_rs232_que_in.buf_beg); //zjistim tzp paketu ACL, Even, SCO ...
+ bth_que_put(&bth_rs232_que_in, c); //store the received character to the queue
+ typ_paket=((uint8_t*)bth_rs232_que_in.buf_beg); //determine the type of the pakcet ACL, Even, SCO ...
switch(*typ_paket)
{
case HCI_EVENT_PKT:
- /*naplnim strukturu "hci_event_hdr" ze zasobniku - po bytech*/
+ /*fill in structure "hci_event_hdr" from the queue (bye by byte)*/
store16(bth_event_packet.evt, *(((uint8_t*)bth_rs232_que_in.buf_beg)+HCI_PKT_SIZE));
store16(bth_event_packet.plen, *(((uint8_t*)bth_rs232_que_in.buf_beg)+HCI_PKT_SIZE+1));
};
/*******/
- /*pointer na fci prislusenijici even codu*/
- if(bth_event_packet.evt<EV_SUM_FC) //overeni existence fce
+ /*pointer to the function matching the event code*/
+ if(bth_event_packet.evt<EV_SUM_FC) //check whether the function exists
{
data_ad=(uint8_t*)(bth_rs232_que_in.buf_beg+HCI_EVENT_HDR_SIZE+HCI_PKT_SIZE);
error_code=(*bth_event_array_fce[bth_event_packet.evt])(data_ad,bth_event_packet.plen);
- bth_rs232_que_in.ip=bth_rs232_que_in.buf_beg; //nastav se na zacatek, pro pristi event
+ bth_rs232_que_in.ip=bth_rs232_que_in.buf_beg; //set to the beginning for the next event
}else{
bth_rs232_que_in.ip=bth_rs232_que_in.buf_beg; //nastav se na zacatek, pro pristi event
return (-1);
};
if(error_code>=0)
{
- // bth_error_detect_status((uint8_t)error_code); //error vypisy
+ // bth_error_detect_status((uint8_t)error_code); //error msg
}
else
- {//bth_error_detect_event((uint8_t)(-error_code)); //error vypisy
+ {//bth_error_detect_event((uint8_t)(-error_code)); //error msg
};
};
};
if((bth_rs232_que_in.ip-bth_rs232_que_in.buf_beg) == ((bth_acl_packet.dlen)+HCI_ACL_HDR_SIZE+HCI_PKT_SIZE))
{
- /* **** kontrola sousednosti dvou znaku TPU3 **** */
+ /* **** check the adjacency of two characters TPU3 **** */
if(bth_controll_flag!=0)
{
bth_stop_TPU_counter();
__bthtomc16((uint8_t*)&(bth_acl_packet.handle),(((uint8_t*)bth_rs232_que_in.buf_beg)+HCI_PKT_SIZE+HCI_ACL_HDR____handle));
bth_acl_packet.handle=bth_acl_packet.handle & 0x0fff;
- /*prom 'char_acl_pkt' vyjadruje vlastnosti paketu, if point to point nebo broadcast, or char. L2CAP*/
+ /*variable 'char_acl_pkt' stores the properties of the packet, if it is point to point or broadcast, or char. L2CAP*/
store16(char_acl_pkt, (0xf0&*(((uint8_t*)bth_rs232_que_in.buf_beg)+HCI_PKT_SIZE+HCI_ACL_HDR____handle+1)));
- /*rozhodnuti o jaky paket se jedna (PtP,Piconet,broat...) a o jaky typ komunikace se zarizenim (L2CAP, HCI)*/
+ /*decide which packet is this (PtP,Piconet,broat...) and the type of communication (L2CAP, HCI)*/
data_ad=(uint8_t*)bth_rs232_que_in.buf_beg+HCI_PKT_SIZE+HCI_ACL_HDR_SIZE;
com_pr=char_acl_pkt&0xc0;
- if(com_pr<COM_PROT_SUM_FC) //fce existuje
+ if(com_pr<COM_PROT_SUM_FC) //func exists
{
bth_char_pkt_fce[com_pr]
(bth_acl_packet.handle, char_acl_pkt&0x30, data_ad,bth_acl_packet.dlen);
}
else
{
- /*HCI data - nikoliv L2CAP - obsluha ani nahravani do
- datoveho zas. neni napsano - predpoklada se zasilani dat pres L2CAP
- viz. if pred timto else */
+ /*HCI data - not L2CAP - neither handling nor loading to data queue is not implemented. It is assumed
+ sending of data using L2CAP. See if before this else. */
};
bth_rs232_que_in.ip=bth_rs232_que_in.buf_beg;
-// sci_rs232_sendch('\n',sci_rs232_chan_default); //do PC
+// sci_rs232_sendch('\n',sci_rs232_chan_default); //to PC
};
};
/**
- * Funkce vola funkce, ktere jsou potrebne pro nastaveni zarizeni do slave rezimu
+ * Calls functions, which are necessary for setting the device to the slave mode.
*/
void bth_parametr_slave(void)
{
/**
- * Funkce nastavi MC, aby mohl zasilat HCI pakety do bth zarizeni
- * Pokud jsou inicializovany TPU kanal, tak ho vynuluje a zastavi
+ * Sets the MCU up, so it can send HCI packets to bth device
+ * If TPU channels are initialized, it resets and stop it
*/
void bth_start(void)
{
/**
- * nastaveni zasobniku - inicializacni funkce
+ * Setting of the queue - initialization function
*/
void bth_init(void)
{
/****************************************************************************/
/**
- * Pomocna funce, ktera slouzi k prevodum znaku an tisknutelne znaky
+ * Auxiliary function, which converts characetrs to the printable form
*/
int VypisHexa(uint8_t *s, int delka)
{
printf("%c",tisk[((zn>>4)&0x000F)]);
printf("%c",tisk[zn & 0x000F]);
#else
- sci_rs232_sendch(tisk[(zn&0xf0)>>4],sci_rs232_chan_default); //do PC
- sci_rs232_sendch(tisk[(zn&0x0f)],sci_rs232_chan_default); //do PC
+ sci_rs232_sendch(tisk[(zn&0xf0)>>4],sci_rs232_chan_default); //to PC
+ sci_rs232_sendch(tisk[(zn&0x0f)],sci_rs232_chan_default); //to PC
#endif
};
long int timer;
/**
- * obsluha preruseni, inkrementuje promennou timer a blika diodami
+ * interrupt hanlder, increments the timer variable and blinks LEDs
*/
void bth_inruppt_pkt_controll(void) __attribute__ ((interrupt_handler));
/**
- * spusteni TPU casovace kanalu 1
+ * Starts TPU channel 1
*/
void bth_start_TPU_counter(void)
{
/**
- * zastaveni TPU casovace kanalu 1
+ * Stop TPU 1
*/
void bth_stop_TPU_counter(void)
{
/**
- * vynulovani TPU casovace kanalu 1
+ * Reset TPU 1
*/
void bth_clear_TPU_counter(void)
{
/**
- * funkce vraci pocet presuseni casovace
+ * Returns the number of timer interrupts
*/
long int bth_get_timer(void)
{
};
/**
- * nulovani poctu preruseni casovace
+ * Zeroes the timer variable
*/
void bth_nul_timer(void)
{
/**
- * inicializace casovace - HW 1-preteceni citace; 2-Dosazeni citace hodnoty TIER1_TGIEAm
+ * Timer initialization - HW 1-timer overflow; 2-???Dosazeni citace hodnoty TIER1_TGIEAm
*/
void bth_init_pkt_controll(void)
{
#include <string.h>\r
\r
/**/\r
-/*funkce hlada v seznamu bdadres ba2 velikosti num bdadresu ba1, pokud ji najde, vrati jeji poradi*/\r
+/*Search the list ba1 of the size num for bdadres ba2, if it is found, it's index is returned*/\r
\r
static inline int bth_seach_bdaddr(bdaddr_t *ba1, const bdaddr_t *ba2, int num)\r
{\r
return(value|pomoc);\r
};\r
\r
-static inline void store_le16(void *address, uint16_t value) //pro u16 s vyuzitim bigindianu\r
+static inline void store_le16(void *address, uint16_t value) //for u16 big endian\r
{\r
uint16_t be;\r
be = __cpu_to_le16(value);\r
memcpy(address, &be, sizeof(uint16_t));\r
}\r
\r
-static inline void store_be16(void *address, uint16_t value) //pro u16 s vyuzitim bigindianu\r
+static inline void store_be16(void *address, uint16_t value) //for u16 big endian\r
{\r
uint16_t be;\r
be = __cpu_to_be16(value);\r
\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