1 /*******************************************************************
\r
4 bth_command.c - command functions (bth specification) - build command
\r
7 Copyright (C) 2006 by Petr Kovacik petr_kovacik@gmail.com
\r
9 *******************************************************************/
\r
16 #include <cpu_def.h>
\r
17 #include <h8s2638h.h>
\r
18 #include <periph/sci_rs232.h>
\r
19 #include <system_def.h>
\r
26 #include "hci_event.h"
\r
27 #include "hci_command.h"
\r
28 #include "inline_fce.h"
\r
31 bths_check_command *bth_find_end(bths_check_command *dyn_chan)
\r
33 bths_check_command *temp;
\r
37 while (temp->next!=NULL)
\r
39 temp=temp->next; /*put the command to the queue*/
\r
50 /********************************************************************/
\r
51 /*********************** OGF = 0x01 ****************************/
\r
52 /*-------------------LINK CONTROL COMMANDS--------------------------*/
\r
53 /********************************************************************/
\r
55 int bth_cmd_inqury(uint8_t length, uint8_t rsp, uint8_t *lap)
\r
57 /*------------------------ parts of packet-----------------------*/
\r
58 uint8_t *typ_hci_paket;
\r
59 hci_command_hdr *hci_headr;
\r
60 inquiry_cp *bth_cmd_packet;
\r
61 uint16_t i; //used in loops
\r
62 /*-------------------------------------------------------------------------------*/
\r
63 /*-- determine the size of memory needed for command in buff and determine if it fit there */
\r
66 if(bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)
\r
68 /*setup adresses for packet parts + filling of inidividual fields*/
\r
69 int hp_size=(sizeof(uint8_t)+HCI_COMMAND_HDR_SIZE+INQUIRY_CP_SIZE);
\r
71 bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);
\r
72 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
73 hci_headr=(hci_command_hdr *)(((uint8_t*)typ_hci_paket)+HCI_PKT_SIZE); //pointer to head
\r
74 bth_cmd_packet=(inquiry_cp *)(((uint8_t*)hci_headr)+HCI_COMMAND_HDR_SIZE); //pointer to parametrs
\r
76 store16(*typ_hci_paket, HCI_COMMAND_PKT);
\r
77 store_le16((uint8_t*)hci_headr+HCI_COMMAND_HDR____opcode,htobs(cmd_opcode_pack(OGF_LINK_CTL, OCF_INQUIRY)));
\r
78 store16(*((uint8_t*)hci_headr+HCI_COMMAND_HDR____plen),INQUIRY_CP_SIZE);
\r
80 /*pokud neni uvedeno lap zvoli se univerzlni*/
\r
81 /*if lap is not specified, the universal one is chosen*/
\r
82 store_le16((uint8_t*)bth_cmd_packet+INQUIRY_CP____length,length);
\r
83 store_le16((uint8_t*)bth_cmd_packet+INQUIRY_CP____num_rsp,rsp);
\r
87 uint8_t lap_univ[]={0x33,0x8b,0x9e};
\r
88 memcpy(((uint8_t*)bth_cmd_packet+INQUIRY_CP____lap),&lap_univ,3);
\r
91 for(i=0; i<3; i++) {store_le16((uint8_t*)bth_cmd_packet+INQUIRY_CP____lap+i,*(lap+2-i));};
\r
94 /*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
95 /*nastaveni pozice v poli command prikazu pro pristi prikaz. Moznost zapisu (adresa v poli = NULL)
\r
96 se overuje, az pri samotnem ukladani */
\r
97 if(bth_com_buf_info.aktual<(LENCOMMAND-2)){bth_com_buf_info.aktual++;}
\r
98 else{ bth_com_buf_info.aktual=0;};
\r
102 /*--- 0x01 - 0x000F --- Change_Connection_Packet_Type ---*/
\r
103 int change_connection_packet_type(uint16_t handle, uint16_t ptype)
\r
105 uint8_t *typ_hci_paket;
\r
106 hci_command_hdr *hci_headr;
\r
107 set_conn_ptype_cp *bth_cmd_packet;
\r
108 /*-- determine the size of memory needed for command in buff and determine if it fit there */
\r
109 /*-------------------------------------------------------------------------------*/
\r
110 /*-- urceni potreb. velikostipro command prikaz v buff. a zjisteni zda se vejde--*/
\r
112 if(bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)
\r
114 /*setup adresses for packet parts + filling of inidividual fields*/
\r
115 int hp_size=(sizeof(uint8_t)+HCI_COMMAND_HDR_SIZE+SET_CONN_PTYPE_CP_SIZE);
\r
116 bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);
\r
117 typ_hci_paket=(uint8_t*)bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]; //pozice v buff, ktera je prirazena paketu
\r
118 hci_headr=(hci_command_hdr *)(((uint8_t*)typ_hci_paket)+HCI_PKT_SIZE); //pointer on head
\r
119 bth_cmd_packet=(set_conn_ptype_cp *)(((uint8_t*)hci_headr)+HCI_COMMAND_HDR_SIZE); //pointer on parametrs
\r
121 store16(*typ_hci_paket, HCI_COMMAND_PKT);
\r
122 store_le16((uint8_t*)hci_headr+HCI_COMMAND_HDR____opcode,htobs(cmd_opcode_pack(OGF_LINK_CTL, OCF_SET_CONN_PTYPE)));
\r
123 store16(*((uint8_t*)hci_headr+HCI_COMMAND_HDR____plen),SET_CONN_PTYPE_CP_SIZE);
\r
124 store_le16((uint8_t*)bth_cmd_packet+SET_CONN_PTYPE_CP____handle,handle);
\r
125 store_le16((uint8_t*)bth_cmd_packet+SET_CONN_PTYPE_CP____pkt_type,ptype);
\r
127 /*nastaveni pozice v poli command prikazu pro pristi prikaz. Moznost zapisu (adresa v poli = NULL)
\r
128 se overuje, az pri samotnem ukladani */
\r
129 if(bth_com_buf_info.aktual<(LENCOMMAND-2)){bth_com_buf_info.aktual++;}
\r
130 else{ bth_com_buf_info.aktual=0;};
\r
136 int bth_cmd_disconnect(uint16_t handle, uint8_t reason)
\r
138 /*------------------------ parts of packet-----------------------*/
\r
139 uint8_t *typ_hci_paket;
\r
140 hci_command_hdr *hci_headr;
\r
141 disconnect_cp *bth_cmd_packet;
\r
142 /*-- determine the size of memory needed for command in buff and determine if it fit there */
\r
143 /*-------------------------------------------------------------------------------*/
\r
144 /*-- urceni potreb. velikostipro command prikaz v buff. a zjisteni zda se vejde--*/
\r
146 if(bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)
\r
148 /*setup adresses for packet parts + filling of inidividual fields*/
\r
149 int hp_size=HCI_PKT_SIZE+HCI_COMMAND_HDR_SIZE+DISCONNECT_CP_SIZE;
\r
151 bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);
\r
152 typ_hci_paket=(uint8_t*)bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]; //pozice v buff, ktera je prirazena paketu
\r
153 hci_headr=(hci_command_hdr *)(((uint8_t*)typ_hci_paket)+HCI_PKT_SIZE); //pointer on head
\r
154 bth_cmd_packet=(disconnect_cp *)(((uint8_t*)hci_headr)+HCI_COMMAND_HDR_SIZE); //pointer on parametrs
\r
156 store16(*typ_hci_paket, HCI_COMMAND_PKT);
\r
157 store_le16((uint8_t*)hci_headr+HCI_COMMAND_HDR____opcode,htobs(cmd_opcode_pack(OGF_LINK_POLICY, OCF_DISCONNECT)));
\r
158 store16(*((uint8_t*)hci_headr+HCI_COMMAND_HDR____plen),WRITE_PAGE_ACTIVITY_CP_SIZE);
\r
159 store_le16((uint16_t*)((uint8_t*)bth_cmd_packet+DISCONNECT_CP____handle),handle);
\r
160 store16(*((uint8_t*)bth_cmd_packet+DISCONNECT_CP____reason),reason);
\r
162 /*nastaveni pozice v poli command prikazu pro pristi prikaz. Moznost zapisu (adresa v poli = NULL)
\r
163 se overuje, az pri samotnem ukladani */
\r
164 if(bth_com_buf_info.aktual<(LENCOMMAND-2)){bth_com_buf_info.aktual++;}
\r
165 else{ bth_com_buf_info.aktual=0;};
\r
169 //--------------------------------------------------------------------------------------------
\r
170 //--------------------------------------------------------------------------------------------
\r
174 /********************************************************************/
\r
175 /*********************** OGF = 0x02 ****************************/
\r
176 /*-------------------LINK POLICY COMMANDS--------------------------*/
\r
177 /********************************************************************/
\r
178 int bth_cmd_write_link_policy_settings(uint16_t handle, uint16_t policy) /*obcode=0x0D08; 0x02--0x000D*/
\r
180 /*------------------------ parts of packet-----------------------*/
\r
181 uint8_t *typ_hci_paket;
\r
182 hci_command_hdr *hci_headr;
\r
183 write_link_policy_cp *bth_cmd_packet;
\r
184 /*-- determine the size of memory needed for command in buff and determine if it fit there */
\r
185 /*-------------------------------------------------------------------------------*/
\r
186 /*-- urceni potreb. velikostipro command prikaz v buff. a zjisteni zda se vejde--*/
\r
188 if(bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)
\r
190 /*setup adresses for packet parts + filling of inidividual fields*/
\r
191 int hp_size=HCI_PKT_SIZE+HCI_COMMAND_HDR_SIZE+WRITE_LINK_POLICY_CP_SIZE;
\r
193 bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);
\r
194 typ_hci_paket=(uint8_t*)bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]; //pozice v buff, ktera je prirazena paketu
\r
195 hci_headr=(hci_command_hdr *)(((uint8_t*)typ_hci_paket)+HCI_PKT_SIZE); //pointer on head
\r
196 bth_cmd_packet=(write_link_policy_cp *)(((uint8_t*)hci_headr)+HCI_COMMAND_HDR_SIZE); //pointer on parametrs
\r
198 store16(*typ_hci_paket, HCI_COMMAND_PKT);
\r
199 store_le16((uint8_t*)hci_headr+HCI_COMMAND_HDR____opcode,htobs(cmd_opcode_pack(OGF_LINK_POLICY, OCF_WRITE_LINK_POLICY)));
\r
200 store16(*((uint8_t*)hci_headr+HCI_COMMAND_HDR____plen),WRITE_PAGE_ACTIVITY_CP_SIZE);
\r
201 store_le16((uint16_t*)((uint8_t*)bth_cmd_packet+WRITE_LINK_POLICY_CP____handle),handle);
\r
202 store_le16((uint16_t*)((uint8_t*)bth_cmd_packet+WRITE_LINK_POLICY_CP____policy),policy);
\r
204 /*nastaveni pozice v poli command prikazu pro pristi prikaz. Moznost zapisu (adresa v poli = NULL)
\r
205 se overuje, az pri samotnem ukladani */
\r
206 if(bth_com_buf_info.aktual<(LENCOMMAND-2)){bth_com_buf_info.aktual++;}
\r
207 else{ bth_com_buf_info.aktual=0;};
\r
214 /********************************************************************/
\r
215 /*********************** OGF = 0x03 ****************************/
\r
216 /*--------------HOST CONTROLLER & BASEBAND COMMANDS-----------------*/
\r
217 /********************************************************************/
\r
218 int bth_cmd_reset(void) /*opcode=0x0C03 OCF = 0x0003, OGF = 0x03*/
\r
220 /*------------------------ parts of packet-----------------------*/
\r
221 uint8_t *typ_hci_paket;
\r
222 hci_command_hdr *hci_headr;
\r
223 /*-- determine the size of memory needed for command in buff and determine if it fit there */
\r
224 /*-------------------------------------------------------------------------------*/
\r
225 /*-- urceni potreb. velikostipro command prikaz v buff. a zjisteni zda se vejde--*/
\r
227 if(bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)
\r
229 /*setup adresses for packet parts + filling of inidividual fields*/
\r
230 int hp_size=HCI_PKT_SIZE+HCI_COMMAND_HDR_SIZE;
\r
232 bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);
\r
233 typ_hci_paket=(uint8_t*)bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]; //pozice v buff, ktera je prirazena paketu
\r
234 hci_headr=(hci_command_hdr *)(((uint8_t*)typ_hci_paket)+HCI_PKT_SIZE); //pointer on head
\r
236 store16(*typ_hci_paket, HCI_COMMAND_PKT);
\r
237 store_le16(((uint8_t*)hci_headr+HCI_COMMAND_HDR____opcode),htobs(cmd_opcode_pack(OGF_HOST_CTL,OCF_RESET )));
\r
240 store16(*((uint8_t*)hci_headr+HCI_COMMAND_HDR____plen),0);
\r
242 /*nastaveni pozice v poli command prikazu pro pristi prikaz. Moznost zapisu (adresa v poli = NULL)
\r
243 se overuje, az pri samotnem ukladani */
\r
244 if(bth_com_buf_info.aktual<(LENCOMMAND-2)){bth_com_buf_info.aktual++;}
\r
245 else{ bth_com_buf_info.aktual=0;};
\r
251 /********************************************************************/
\r
252 /*********************** OGF = 0x04 ****************************/
\r
253 /*-------------------INFORMATIONAL PARAMETERS-----------------------*/
\r
254 /********************************************************************/
\r
258 int bth_accept_conn_req_cp(bdaddr_t *bdaddr) /*0x01 - 0x0009*/
\r
260 /*------------------------ parts of packet-----------------------*/
\r
261 uint8_t *typ_hci_paket; //FIXME: hjkhjkh
\r
262 hci_command_hdr *hci_headr;
\r
263 accept_conn_req_cp *bth_cmd_packet;
\r
264 /*-- determine the size of memory needed for command in buff and determine if it fit there */
\r
265 /*-------------------------------------------------------------------------------*/
\r
266 /*-- urceni potreb. velikostipro command prikaz v buff. a zjisteni zda se vejde--*/
\r
268 if(bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)
\r
270 /*setup adresses for packet parts + filling of inidividual fields*/
\r
271 int hp_size=(sizeof(uint8_t)+HCI_COMMAND_HDR_SIZE+ACCEPT_CONN_REQ_CP_SIZE);
\r
273 bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);
\r
274 typ_hci_paket=(uint8_t*)bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]; //pozice v buff, ktera je prirazena paketu
\r
275 hci_headr=(hci_command_hdr *)(((uint8_t*)typ_hci_paket)+HCI_PKT_SIZE); //pointer on head
\r
276 bth_cmd_packet=(accept_conn_req_cp*)(((uint8_t*)hci_headr)+HCI_COMMAND_HDR_SIZE); //pointer on parametrs
\r
278 store16(*typ_hci_paket, HCI_COMMAND_PKT);
\r
279 store_le16((uint8_t*)hci_headr+HCI_COMMAND_HDR____opcode,htobs(cmd_opcode_pack(OGF_LINK_CTL, OCF_ACCEPT_CONN_REQ)));
\r
280 store16(*((uint8_t*)hci_headr+HCI_COMMAND_HDR____plen),ACCEPT_CONN_REQ_CP_SIZE);
\r
281 memcpy((uint8_t*)bth_cmd_packet+ACCEPT_CONN_REQ_CP____bdaddr,bdaddr,sizeof(bdaddr_t));
\r
282 store16(*((uint8_t*)bth_cmd_packet+ACCEPT_CONN_REQ_CP____role), 0x01); //ACL
\r
284 /*nastaveni pozice v poli command prikazu pro pristi prikaz. Moznost zapisu (adresa v poli = NULL)
\r
285 se overuje, az pri samotnem ukladani */
\r
286 if(bth_com_buf_info.aktual<(LENCOMMAND-2)){bth_com_buf_info.aktual++;}
\r
287 else{ bth_com_buf_info.aktual=0;};
\r
291 int bth_cmd_write_page_scan(uint16_t interval, uint16_t window) /*obcode=1C0C OGF = 0x001C OCF=0x03*/
\r
293 /*------------------------ parts of packet-----------------------*/
\r
294 uint8_t *typ_hci_paket;
\r
295 hci_command_hdr *hci_headr;
\r
296 write_page_activity_cp *bth_cmd_packet;
\r
297 /*-- determine the size of memory needed for command in buff and determine if it fit there */
\r
298 /*-------------------------------------------------------------------------------*/
\r
299 /*-- urceni potreb. velikostipro command prikaz v buff. a zjisteni zda se vejde--*/
\r
301 if(bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)
\r
303 /*setup adresses for packet parts + filling of inidividual fields*/
\r
304 int hp_size=(sizeof(uint8_t)+HCI_COMMAND_HDR_SIZE+WRITE_PAGE_ACTIVITY_CP_SIZE);
\r
306 bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);
\r
307 typ_hci_paket=(uint8_t*)bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]; //pozice v buff, ktera je prirazena paketu
\r
308 hci_headr=(hci_command_hdr *)(((uint8_t*)typ_hci_paket)+HCI_PKT_SIZE); //pointer on head
\r
309 bth_cmd_packet=(write_page_activity_cp *)(((uint8_t*)hci_headr)+HCI_COMMAND_HDR_SIZE); //pointer on parametrs
\r
311 store16(*typ_hci_paket, HCI_COMMAND_PKT);
\r
312 store_le16((uint8_t*)hci_headr+HCI_COMMAND_HDR____opcode,htobs(cmd_opcode_pack(OGF_HOST_CTL, OCF_WRITE_PAGE_ACTIVITY)));
\r
313 store16(*((uint8_t*)hci_headr+HCI_COMMAND_HDR____plen),WRITE_PAGE_ACTIVITY_CP_SIZE);
\r
314 store_le16((uint8_t*)bth_cmd_packet+WRITE_PAGE_ACTIVITY_CP____interval,interval);
\r
315 store_le16((uint8_t*)bth_cmd_packet+WRITE_PAGE_ACTIVITY_CP____window,window);
\r
317 /*nastaveni pozice v poli command prikazu pro pristi prikaz. Moznost zapisu (adresa v poli = NULL)
\r
318 se overuje, az pri samotnem ukladani */
\r
319 if(bth_com_buf_info.aktual<(LENCOMMAND-2)){bth_com_buf_info.aktual++;}
\r
320 else{ bth_com_buf_info.aktual=0;};
\r
326 //--------------------------------------------------------------------------------------------
\r
327 //--------------------------------------------------------------------------------------------
\r
328 //--------------------------------------------------------------------------------------------
\r
329 int bth_cmd_write_inquiry_scan_activity(uint16_t interval, uint16_t window) //0x001E
\r
331 /*------------------------ parts of packet-----------------------*/
\r
332 uint8_t *typ_hci_paket;
\r
333 hci_command_hdr *hci_headr;
\r
334 write_inq_activity_cp *bth_cmd_packet;
\r
335 /*-- determine the size of memory needed for command in buff and determine if it fit there */
\r
336 /*-------------------------------------------------------------------------------*/
\r
337 /*-- urceni potreb. velikostipro command prikaz v buff. a zjisteni zda se vejde--*/
\r
339 if(bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)
\r
341 /*setup adresses for packet parts + filling of inidividual fields*/
\r
342 int hp_size=(sizeof(uint8_t)+HCI_COMMAND_HDR_SIZE+WRITE_PAGE_ACTIVITY_CP_SIZE);
\r
343 bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);
\r
344 typ_hci_paket=(uint8_t*)bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]; //pozice v buff, ktera je prirazena paketu
\r
345 hci_headr=(hci_command_hdr *)(((uint8_t*)typ_hci_paket)+HCI_PKT_SIZE); //pointer on head
\r
346 bth_cmd_packet=(write_inq_activity_cp *)(((uint8_t*)hci_headr)+HCI_COMMAND_HDR_SIZE); //pointer on parametrs
\r
348 store16(*typ_hci_paket, HCI_COMMAND_PKT);
\r
349 store_le16((uint8_t*)hci_headr+HCI_COMMAND_HDR____opcode,htobs(cmd_opcode_pack(OGF_HOST_CTL, OCF_WRITE_INQ_ACTIVITY)));
\r
350 store16(*((uint8_t*)hci_headr+HCI_COMMAND_HDR____plen),WRITE_INQ_ACTIVITY_CP_SIZE);
\r
351 store_le16((uint8_t*)bth_cmd_packet+WRITE_INQ_ACTIVITY_CP____interval,interval);
\r
352 store_le16((uint8_t*)bth_cmd_packet+WRITE_INQ_ACTIVITY_CP____window,window);
\r
354 /*nastaveni pozice v poli command prikazu pro pristi prikaz. Moznost zapisu (adresa v poli = NULL)
\r
355 se overuje, az pri samotnem ukladani */
\r
356 if(bth_com_buf_info.aktual<(LENCOMMAND-2)){bth_com_buf_info.aktual++;}
\r
357 else{ bth_com_buf_info.aktual=0;};
\r
361 int bth_cmd_read_bd_addr(void) /*opcode=0x0910 OCF = 0x0009, OGF = 0x04*/
\r
363 /*------------------------ parts of packet-----------------------*/
\r
364 uint8_t *typ_hci_paket;
\r
365 hci_command_hdr *hci_headr;
\r
366 /*-- determine the size of memory needed for command in buff and determine if it fit there */
\r
367 /*-------------------------------------------------------------------------------*/
\r
368 /*-- urceni potreb. velikostipro command prikaz v buff. a zjisteni zda se vejde--*/
\r
370 if(bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)
\r
372 /*setup adresses for packet parts + filling of inidividual fields*/
\r
373 int hp_size=(sizeof(uint8_t)+HCI_COMMAND_HDR_SIZE);
\r
374 bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);
\r
375 typ_hci_paket=(uint8_t*)bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]; //pozice v buff, ktera je prirazena paketu
\r
376 hci_headr=(hci_command_hdr *)(((uint8_t*)typ_hci_paket)+HCI_PKT_SIZE); //pointer on head
\r
378 store16(*typ_hci_paket, HCI_COMMAND_PKT);
\r
379 store_le16((uint8_t*)hci_headr+HCI_COMMAND_HDR____opcode,htobs(cmd_opcode_pack(OGF_INFO_PARAM, OCF_READ_BD_ADDR)));
\r
380 store16(*((uint8_t*)hci_headr+HCI_COMMAND_HDR____plen),0);
\r
382 /*nastaveni pozice v poli command prikazu pro pristi prikaz. Moznost zapisu (adresa v poli = NULL)
\r
383 se overuje, az pri samotnem ukladani */
\r
384 if(bth_com_buf_info.aktual<(LENCOMMAND-2)){bth_com_buf_info.aktual++;}
\r
385 else{ bth_com_buf_info.aktual=0;};
\r
389 int bth_cmd_write_scan_enable(uint8_t set_ing_scan) //0x001A
\r
391 /*------------------------ parts of packet-----------------------*/
\r
392 uint8_t *typ_hci_paket;
\r
393 hci_command_hdr *hci_headr;
\r
394 uint8_t *bth_cmd_packet;
\r
396 /*-- determine the size of memory needed for command in buff and determine if it fit there */
\r
397 /*-------------------------------------------------------------------------------*/
\r
398 /*-- urceni potreb. velikostipro command prikaz v buff. a zjisteni zda se vejde--*/
\r
400 if(bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)
\r
402 /*setup adresses for packet parts + filling of inidividual fields*/
\r
403 int hp_size=(sizeof(uint8_t)+HCI_COMMAND_HDR_SIZE+WRITE_SCAN_ENABLE_SIZE);
\r
404 bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);
\r
405 typ_hci_paket=(uint8_t*)bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]; //pozice v buff, ktera je prirazena paketu
\r
406 hci_headr=(hci_command_hdr *)(((uint8_t*)typ_hci_paket)+HCI_PKT_SIZE); //pointer on head
\r
407 bth_cmd_packet=(uint8_t *)(((uint8_t*)hci_headr)+HCI_COMMAND_HDR_SIZE); //pointer on parametrs
\r
410 store16(*typ_hci_paket, HCI_COMMAND_PKT);
\r
411 store_le16((uint8_t*)hci_headr+HCI_COMMAND_HDR____opcode,htobs(cmd_opcode_pack(OGF_HOST_CTL, OCF_WRITE_SCAN_ENABLE)));
\r
412 store16(*((uint8_t*)hci_headr+HCI_COMMAND_HDR____plen),WRITE_SCAN_ENABLE_SIZE);
\r
413 store16(*bth_cmd_packet,set_ing_scan);
\r
414 /*nastaveni pozice v poli command prikazu pro pristi prikaz. Moznost zapisu (adresa v poli = NULL)
\r
415 se overuje, az pri samotnem ukladani */
\r
416 if(bth_com_buf_info.aktual<(LENCOMMAND-2)){bth_com_buf_info.aktual++;}
\r
417 else{ bth_com_buf_info.aktual=0;};
\r
421 //FIXME: All the czech comments are the same as in the first function.
\r