/*******************************************************************\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