]> rtime.felk.cvut.cz Git - mirosot.git/blobdiff - bluetooth/bth_command.c
Comments translated to english
[mirosot.git] / bluetooth / bth_command.c
index c9b221c72fb61dddb7e57524b0ccf8c0eefeb31f..6979574fae6ef305d8fdd860264851544c84f1be 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************\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
@@ -58,25 +58,27 @@ int bth_cmd_inqury(uint8_t length, uint8_t rsp, uint8_t *lap)
     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
@@ -89,6 +91,7 @@ int bth_cmd_inqury(uint8_t length, uint8_t rsp, uint8_t *lap)
       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
@@ -102,12 +105,13 @@ int change_connection_packet_type(uint16_t handle, uint16_t ptype)
     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
@@ -135,12 +139,13 @@ int bth_cmd_disconnect(uint16_t handle, uint8_t reason)
     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
@@ -176,12 +181,13 @@ int bth_cmd_write_link_policy_settings(uint16_t handle, uint16_t policy) /*obcod
     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
@@ -214,12 +220,13 @@ int bth_cmd_reset(void)           /*opcode=0x0C03 OCF = 0x0003, OGF = 0x03*/
 /*------------------------ 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
@@ -251,15 +258,16 @@ se overuje, az pri samotnem ukladani */
 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
@@ -286,12 +294,13 @@ int bth_cmd_write_page_scan(uint16_t interval, uint16_t window)        /*obcode=
     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
@@ -323,12 +332,13 @@ int bth_cmd_write_inquiry_scan_activity(uint16_t interval, uint16_t window) //0x
     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
@@ -353,12 +363,13 @@ int bth_cmd_read_bd_addr(void) /*opcode=0x0910 OCF = 0x0009, OGF = 0x04*/
 /*------------------------ 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
@@ -382,12 +393,13 @@ int bth_cmd_write_scan_enable(uint8_t set_ing_scan) //0x001A
     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
@@ -406,3 +418,5 @@ se overuje, az pri samotnem ukladani */
   return -1;\r
 };\r
 \r
+//FIXME: All the czech comments are the same as in the first function.\r
+\r