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
23 #include "hci_event.h"
\r
24 #include "hci_command.h"
\r
25 #include "inline_fce.h"
\r
28 bths_check_command *bth_find_end(bths_check_command *dyn_chan)
\r
30 bths_check_command *temp;
\r
34 while (temp->next!=NULL)
\r
36 temp=temp->next; /*put the command to the queue*/
\r
47 /********************************************************************/
\r
48 /*********************** OGF = 0x01 ****************************/
\r
49 /*-------------------LINK CONTROL COMMANDS--------------------------*/
\r
50 /********************************************************************/
\r
52 int bth_cmd_inqury(uint8_t length, uint8_t rsp, uint8_t *lap)
\r
54 /*------------------------ parts of packet-----------------------*/
\r
55 uint8_t *typ_hci_paket;
\r
56 hci_command_hdr *hci_headr;
\r
57 inquiry_cp *bth_cmd_packet;
\r
58 uint16_t i; //used in loops
\r
59 /*-------------------------------------------------------------------------------*/
\r
60 /*-- determine the size of memory needed for command in buff and determine if it fit there */
\r
63 if(bth_array_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)
\r
65 /*setup adresses for packet parts + filling of inidividual fields*/
\r
66 int hp_size=(sizeof(uint8_t)+HCI_COMMAND_HDR_SIZE+INQUIRY_CP_SIZE);
\r
68 bth_array_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);
\r
69 typ_hci_paket=(uint8_t*)bth_array_adrr_comm_packet[bth_com_buf_info.aktual]; //possition in buff, which is assigned to the packet
\r
70 hci_headr=(hci_command_hdr *)(((uint8_t*)typ_hci_paket)+HCI_PKT_SIZE); //pointer to head
\r
71 bth_cmd_packet=(inquiry_cp *)(((uint8_t*)hci_headr)+HCI_COMMAND_HDR_SIZE); //pointer to parametrs
\r
73 store16(*typ_hci_paket, HCI_COMMAND_PKT);
\r
74 store_le16((uint8_t*)hci_headr+HCI_COMMAND_HDR____opcode,htobs(cmd_opcode_pack(OGF_LINK_CTL, OCF_INQUIRY)));
\r
75 store16(*((uint8_t*)hci_headr+HCI_COMMAND_HDR____plen),INQUIRY_CP_SIZE);
\r
77 /*pokud neni uvedeno lap zvoli se univerzlni*/
\r
78 /*if lap is not specified, the universal one is chosen*/
\r
79 store_le16((uint8_t*)bth_cmd_packet+INQUIRY_CP____length,length);
\r
80 store_le16((uint8_t*)bth_cmd_packet+INQUIRY_CP____num_rsp,rsp);
\r
84 uint8_t lap_univ[]={0x33,0x8b,0x9e};
\r
85 memcpy(((uint8_t*)bth_cmd_packet+INQUIRY_CP____lap),&lap_univ,3);
\r
88 for(i=0; i<3; i++) {store_le16((uint8_t*)bth_cmd_packet+INQUIRY_CP____lap+i,*(lap+2-i));};
\r
91 /*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
92 /*nastaveni pozice v poli command prikazu pro pristi prikaz. Moznost zapisu (adresa v poli = NULL)
\r
93 se overuje, az pri samotnem ukladani */
\r
94 if(bth_com_buf_info.aktual<(LENCOMMAND-2)){bth_com_buf_info.aktual++;}
\r
95 else{ bth_com_buf_info.aktual=0;};
\r
99 /*--- 0x01 - 0x000F --- Change_Connection_Packet_Type ---*/
\r
100 int change_connection_packet_type(uint16_t handle, uint16_t ptype)
\r
102 uint8_t *typ_hci_paket;
\r
103 hci_command_hdr *hci_headr;
\r
104 set_conn_ptype_cp *bth_cmd_packet;
\r
105 /*-- determine the size of memory needed for command in buff and determine if it fit there */
\r
106 /*-------------------------------------------------------------------------------*/
\r
107 /*-- urceni potreb. velikostipro command prikaz v buff. a zjisteni zda se vejde--*/
\r
109 if(bth_array_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)
\r
111 /*setup adresses for packet parts + filling of inidividual fields*/
\r
112 int hp_size=(sizeof(uint8_t)+HCI_COMMAND_HDR_SIZE+SET_CONN_PTYPE_CP_SIZE);
\r
113 bth_array_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);
\r
114 typ_hci_paket=(uint8_t*)bth_array_adrr_comm_packet[bth_com_buf_info.aktual]; //pozice v buff, ktera je prirazena paketu
\r
115 hci_headr=(hci_command_hdr *)(((uint8_t*)typ_hci_paket)+HCI_PKT_SIZE); //pointer on head
\r
116 bth_cmd_packet=(set_conn_ptype_cp *)(((uint8_t*)hci_headr)+HCI_COMMAND_HDR_SIZE); //pointer on parametrs
\r
118 store16(*typ_hci_paket, HCI_COMMAND_PKT);
\r
119 store_le16((uint8_t*)hci_headr+HCI_COMMAND_HDR____opcode,htobs(cmd_opcode_pack(OGF_LINK_CTL, OCF_SET_CONN_PTYPE)));
\r
120 store16(*((uint8_t*)hci_headr+HCI_COMMAND_HDR____plen),SET_CONN_PTYPE_CP_SIZE);
\r
121 store_le16((uint8_t*)bth_cmd_packet+SET_CONN_PTYPE_CP____handle,handle);
\r
122 store_le16((uint8_t*)bth_cmd_packet+SET_CONN_PTYPE_CP____pkt_type,ptype);
\r
124 /*nastaveni pozice v poli command prikazu pro pristi prikaz. Moznost zapisu (adresa v poli = NULL)
\r
125 se overuje, az pri samotnem ukladani */
\r
126 if(bth_com_buf_info.aktual<(LENCOMMAND-2)){bth_com_buf_info.aktual++;}
\r
127 else{ bth_com_buf_info.aktual=0;};
\r
133 int bth_cmd_disconnect(uint16_t handle, uint8_t reason)
\r
135 /*------------------------ parts of packet-----------------------*/
\r
136 uint8_t *typ_hci_paket;
\r
137 hci_command_hdr *hci_headr;
\r
138 disconnect_cp *bth_cmd_packet;
\r
139 /*-- determine the size of memory needed for command in buff and determine if it fit there */
\r
140 /*-------------------------------------------------------------------------------*/
\r
141 /*-- urceni potreb. velikostipro command prikaz v buff. a zjisteni zda se vejde--*/
\r
143 if(bth_array_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)
\r
145 /*setup adresses for packet parts + filling of inidividual fields*/
\r
146 int hp_size=HCI_PKT_SIZE+HCI_COMMAND_HDR_SIZE+DISCONNECT_CP_SIZE;
\r
148 bth_array_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);
\r
149 typ_hci_paket=(uint8_t*)bth_array_adrr_comm_packet[bth_com_buf_info.aktual]; //pozice v buff, ktera je prirazena paketu
\r
150 hci_headr=(hci_command_hdr *)(((uint8_t*)typ_hci_paket)+HCI_PKT_SIZE); //pointer on head
\r
151 bth_cmd_packet=(disconnect_cp *)(((uint8_t*)hci_headr)+HCI_COMMAND_HDR_SIZE); //pointer on parametrs
\r
153 store16(*typ_hci_paket, HCI_COMMAND_PKT);
\r
154 store_le16((uint8_t*)hci_headr+HCI_COMMAND_HDR____opcode,htobs(cmd_opcode_pack(OGF_LINK_POLICY, OCF_DISCONNECT)));
\r
155 store16(*((uint8_t*)hci_headr+HCI_COMMAND_HDR____plen),WRITE_PAGE_ACTIVITY_CP_SIZE);
\r
156 store_le16((uint16_t*)((uint8_t*)bth_cmd_packet+DISCONNECT_CP____handle),handle);
\r
157 store16(*((uint8_t*)bth_cmd_packet+DISCONNECT_CP____reason),reason);
\r
159 /*nastaveni pozice v poli command prikazu pro pristi prikaz. Moznost zapisu (adresa v poli = NULL)
\r
160 se overuje, az pri samotnem ukladani */
\r
161 if(bth_com_buf_info.aktual<(LENCOMMAND-2)){bth_com_buf_info.aktual++;}
\r
162 else{ bth_com_buf_info.aktual=0;};
\r
166 //--------------------------------------------------------------------------------------------
\r
167 //--------------------------------------------------------------------------------------------
\r
171 /********************************************************************/
\r
172 /*********************** OGF = 0x02 ****************************/
\r
173 /*-------------------LINK POLICY COMMANDS--------------------------*/
\r
174 /********************************************************************/
\r
175 int bth_cmd_write_link_policy_settings(uint16_t handle, uint16_t policy) /*obcode=0x0D08; 0x02--0x000D*/
\r
177 /*------------------------ parts of packet-----------------------*/
\r
178 uint8_t *typ_hci_paket;
\r
179 hci_command_hdr *hci_headr;
\r
180 write_link_policy_cp *bth_cmd_packet;
\r
181 /*-- determine the size of memory needed for command in buff and determine if it fit there */
\r
182 /*-------------------------------------------------------------------------------*/
\r
183 /*-- urceni potreb. velikostipro command prikaz v buff. a zjisteni zda se vejde--*/
\r
185 if(bth_array_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)
\r
187 /*setup adresses for packet parts + filling of inidividual fields*/
\r
188 int hp_size=HCI_PKT_SIZE+HCI_COMMAND_HDR_SIZE+WRITE_LINK_POLICY_CP_SIZE;
\r
190 bth_array_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);
\r
191 typ_hci_paket=(uint8_t*)bth_array_adrr_comm_packet[bth_com_buf_info.aktual]; //pozice v buff, ktera je prirazena paketu
\r
192 hci_headr=(hci_command_hdr *)(((uint8_t*)typ_hci_paket)+HCI_PKT_SIZE); //pointer on head
\r
193 bth_cmd_packet=(write_link_policy_cp *)(((uint8_t*)hci_headr)+HCI_COMMAND_HDR_SIZE); //pointer on parametrs
\r
195 store16(*typ_hci_paket, HCI_COMMAND_PKT);
\r
196 store_le16((uint8_t*)hci_headr+HCI_COMMAND_HDR____opcode,htobs(cmd_opcode_pack(OGF_LINK_POLICY, OCF_WRITE_LINK_POLICY)));
\r
197 store16(*((uint8_t*)hci_headr+HCI_COMMAND_HDR____plen),WRITE_PAGE_ACTIVITY_CP_SIZE);
\r
198 store_le16((uint16_t*)((uint8_t*)bth_cmd_packet+WRITE_LINK_POLICY_CP____handle),handle);
\r
199 store_le16((uint16_t*)((uint8_t*)bth_cmd_packet+WRITE_LINK_POLICY_CP____policy),policy);
\r
201 /*nastaveni pozice v poli command prikazu pro pristi prikaz. Moznost zapisu (adresa v poli = NULL)
\r
202 se overuje, az pri samotnem ukladani */
\r
203 if(bth_com_buf_info.aktual<(LENCOMMAND-2)){bth_com_buf_info.aktual++;}
\r
204 else{ bth_com_buf_info.aktual=0;};
\r
211 /********************************************************************/
\r
212 /*********************** OGF = 0x03 ****************************/
\r
213 /*--------------HOST CONTROLLER & BASEBAND COMMANDS-----------------*/
\r
214 /********************************************************************/
\r
215 int bth_cmd_reset(void) /*opcode=0x0C03 OCF = 0x0003, OGF = 0x03*/
\r
217 /*------------------------ parts of packet-----------------------*/
\r
218 uint8_t *typ_hci_paket;
\r
219 hci_command_hdr *hci_headr;
\r
220 /*-- determine the size of memory needed for command in buff and determine if it fit there */
\r
221 /*-------------------------------------------------------------------------------*/
\r
222 /*-- urceni potreb. velikostipro command prikaz v buff. a zjisteni zda se vejde--*/
\r
224 if(bth_array_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)
\r
226 /*setup adresses for packet parts + filling of inidividual fields*/
\r
227 int hp_size=HCI_PKT_SIZE+HCI_COMMAND_HDR_SIZE;
\r
229 bth_array_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);
\r
230 typ_hci_paket=(uint8_t*)bth_array_adrr_comm_packet[bth_com_buf_info.aktual]; //pozice v buff, ktera je prirazena paketu
\r
231 hci_headr=(hci_command_hdr *)(((uint8_t*)typ_hci_paket)+HCI_PKT_SIZE); //pointer on head
\r
233 store16(*typ_hci_paket, HCI_COMMAND_PKT);
\r
234 store_le16(((uint8_t*)hci_headr+HCI_COMMAND_HDR____opcode),htobs(cmd_opcode_pack(OGF_HOST_CTL,OCF_RESET )));
\r
237 store16(*((uint8_t*)hci_headr+HCI_COMMAND_HDR____plen),0);
\r
239 /*nastaveni pozice v poli command prikazu pro pristi prikaz. Moznost zapisu (adresa v poli = NULL)
\r
240 se overuje, az pri samotnem ukladani */
\r
241 if(bth_com_buf_info.aktual<(LENCOMMAND-2)){bth_com_buf_info.aktual++;}
\r
242 else{ bth_com_buf_info.aktual=0;};
\r
248 /********************************************************************/
\r
249 /*********************** OGF = 0x04 ****************************/
\r
250 /*-------------------INFORMATIONAL PARAMETERS-----------------------*/
\r
251 /********************************************************************/
\r
255 int bth_accept_conn_req_cp(bdaddr_t *bdaddr) /*0x01 - 0x0009*/
\r
257 /*------------------------ parts of packet-----------------------*/
\r
258 uint8_t *typ_hci_paket; //FIXME: hjkhjkh
\r
259 hci_command_hdr *hci_headr;
\r
260 accept_conn_req_cp *bth_cmd_packet;
\r
261 /*-- determine the size of memory needed for command in buff and determine if it fit there */
\r
262 /*-------------------------------------------------------------------------------*/
\r
263 /*-- urceni potreb. velikostipro command prikaz v buff. a zjisteni zda se vejde--*/
\r
265 if(bth_array_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)
\r
267 /*setup adresses for packet parts + filling of inidividual fields*/
\r
268 int hp_size=(sizeof(uint8_t)+HCI_COMMAND_HDR_SIZE+ACCEPT_CONN_REQ_CP_SIZE);
\r
270 bth_array_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);
\r
271 typ_hci_paket=(uint8_t*)bth_array_adrr_comm_packet[bth_com_buf_info.aktual]; //pozice v buff, ktera je prirazena paketu
\r
272 hci_headr=(hci_command_hdr *)(((uint8_t*)typ_hci_paket)+HCI_PKT_SIZE); //pointer on head
\r
273 bth_cmd_packet=(accept_conn_req_cp*)(((uint8_t*)hci_headr)+HCI_COMMAND_HDR_SIZE); //pointer on parametrs
\r
275 store16(*typ_hci_paket, HCI_COMMAND_PKT);
\r
276 store_le16((uint8_t*)hci_headr+HCI_COMMAND_HDR____opcode,htobs(cmd_opcode_pack(OGF_LINK_CTL, OCF_ACCEPT_CONN_REQ)));
\r
277 store16(*((uint8_t*)hci_headr+HCI_COMMAND_HDR____plen),ACCEPT_CONN_REQ_CP_SIZE);
\r
278 memcpy((uint8_t*)bth_cmd_packet+ACCEPT_CONN_REQ_CP____bdaddr,bdaddr,sizeof(bdaddr_t));
\r
279 store16(*((uint8_t*)bth_cmd_packet+ACCEPT_CONN_REQ_CP____role), 0x01); //ACL
\r
281 /*nastaveni pozice v poli command prikazu pro pristi prikaz. Moznost zapisu (adresa v poli = NULL)
\r
282 se overuje, az pri samotnem ukladani */
\r
283 if(bth_com_buf_info.aktual<(LENCOMMAND-2)){bth_com_buf_info.aktual++;}
\r
284 else{ bth_com_buf_info.aktual=0;};
\r
288 int bth_cmd_write_page_scan(uint16_t interval, uint16_t window) /*obcode=1C0C OGF = 0x001C OCF=0x03*/
\r
290 /*------------------------ parts of packet-----------------------*/
\r
291 uint8_t *typ_hci_paket;
\r
292 hci_command_hdr *hci_headr;
\r
293 write_page_activity_cp *bth_cmd_packet;
\r
294 /*-- determine the size of memory needed for command in buff and determine if it fit there */
\r
295 /*-------------------------------------------------------------------------------*/
\r
296 /*-- urceni potreb. velikostipro command prikaz v buff. a zjisteni zda se vejde--*/
\r
298 if(bth_array_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)
\r
300 /*setup adresses for packet parts + filling of inidividual fields*/
\r
301 int hp_size=(sizeof(uint8_t)+HCI_COMMAND_HDR_SIZE+WRITE_PAGE_ACTIVITY_CP_SIZE);
\r
303 bth_array_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);
\r
304 typ_hci_paket=(uint8_t*)bth_array_adrr_comm_packet[bth_com_buf_info.aktual]; //pozice v buff, ktera je prirazena paketu
\r
305 hci_headr=(hci_command_hdr *)(((uint8_t*)typ_hci_paket)+HCI_PKT_SIZE); //pointer on head
\r
306 bth_cmd_packet=(write_page_activity_cp *)(((uint8_t*)hci_headr)+HCI_COMMAND_HDR_SIZE); //pointer on parametrs
\r
308 store16(*typ_hci_paket, HCI_COMMAND_PKT);
\r
309 store_le16((uint8_t*)hci_headr+HCI_COMMAND_HDR____opcode,htobs(cmd_opcode_pack(OGF_HOST_CTL, OCF_WRITE_PAGE_ACTIVITY)));
\r
310 store16(*((uint8_t*)hci_headr+HCI_COMMAND_HDR____plen),WRITE_PAGE_ACTIVITY_CP_SIZE);
\r
311 store_le16((uint8_t*)bth_cmd_packet+WRITE_PAGE_ACTIVITY_CP____interval,interval);
\r
312 store_le16((uint8_t*)bth_cmd_packet+WRITE_PAGE_ACTIVITY_CP____window,window);
\r
314 /*nastaveni pozice v poli command prikazu pro pristi prikaz. Moznost zapisu (adresa v poli = NULL)
\r
315 se overuje, az pri samotnem ukladani */
\r
316 if(bth_com_buf_info.aktual<(LENCOMMAND-2)){bth_com_buf_info.aktual++;}
\r
317 else{ bth_com_buf_info.aktual=0;};
\r
323 //--------------------------------------------------------------------------------------------
\r
324 //--------------------------------------------------------------------------------------------
\r
325 //--------------------------------------------------------------------------------------------
\r
326 int bth_cmd_write_inquiry_scan_activity(uint16_t interval, uint16_t window) //0x001E
\r
328 /*------------------------ parts of packet-----------------------*/
\r
329 uint8_t *typ_hci_paket;
\r
330 hci_command_hdr *hci_headr;
\r
331 write_inq_activity_cp *bth_cmd_packet;
\r
332 /*-- determine the size of memory needed for command in buff and determine if it fit there */
\r
333 /*-------------------------------------------------------------------------------*/
\r
334 /*-- urceni potreb. velikostipro command prikaz v buff. a zjisteni zda se vejde--*/
\r
336 if(bth_array_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)
\r
338 /*setup adresses for packet parts + filling of inidividual fields*/
\r
339 int hp_size=(sizeof(uint8_t)+HCI_COMMAND_HDR_SIZE+WRITE_PAGE_ACTIVITY_CP_SIZE);
\r
340 bth_array_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);
\r
341 typ_hci_paket=(uint8_t*)bth_array_adrr_comm_packet[bth_com_buf_info.aktual]; //pozice v buff, ktera je prirazena paketu
\r
342 hci_headr=(hci_command_hdr *)(((uint8_t*)typ_hci_paket)+HCI_PKT_SIZE); //pointer on head
\r
343 bth_cmd_packet=(write_inq_activity_cp *)(((uint8_t*)hci_headr)+HCI_COMMAND_HDR_SIZE); //pointer on parametrs
\r
345 store16(*typ_hci_paket, HCI_COMMAND_PKT);
\r
346 store_le16((uint8_t*)hci_headr+HCI_COMMAND_HDR____opcode,htobs(cmd_opcode_pack(OGF_HOST_CTL, OCF_WRITE_INQ_ACTIVITY)));
\r
347 store16(*((uint8_t*)hci_headr+HCI_COMMAND_HDR____plen),WRITE_INQ_ACTIVITY_CP_SIZE);
\r
348 store_le16((uint8_t*)bth_cmd_packet+WRITE_INQ_ACTIVITY_CP____interval,interval);
\r
349 store_le16((uint8_t*)bth_cmd_packet+WRITE_INQ_ACTIVITY_CP____window,window);
\r
351 /*nastaveni pozice v poli command prikazu pro pristi prikaz. Moznost zapisu (adresa v poli = NULL)
\r
352 se overuje, az pri samotnem ukladani */
\r
353 if(bth_com_buf_info.aktual<(LENCOMMAND-2)){bth_com_buf_info.aktual++;}
\r
354 else{ bth_com_buf_info.aktual=0;};
\r
358 int bth_cmd_read_bd_addr(void) /*opcode=0x0910 OCF = 0x0009, OGF = 0x04*/
\r
360 /*------------------------ parts of packet-----------------------*/
\r
361 uint8_t *typ_hci_paket;
\r
362 hci_command_hdr *hci_headr;
\r
363 /*-- determine the size of memory needed for command in buff and determine if it fit there */
\r
364 /*-------------------------------------------------------------------------------*/
\r
365 /*-- urceni potreb. velikostipro command prikaz v buff. a zjisteni zda se vejde--*/
\r
367 if(bth_array_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)
\r
369 /*setup adresses for packet parts + filling of inidividual fields*/
\r
370 int hp_size=(sizeof(uint8_t)+HCI_COMMAND_HDR_SIZE);
\r
371 bth_array_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);
\r
372 typ_hci_paket=(uint8_t*)bth_array_adrr_comm_packet[bth_com_buf_info.aktual]; //pozice v buff, ktera je prirazena paketu
\r
373 hci_headr=(hci_command_hdr *)(((uint8_t*)typ_hci_paket)+HCI_PKT_SIZE); //pointer on head
\r
375 store16(*typ_hci_paket, HCI_COMMAND_PKT);
\r
376 store_le16((uint8_t*)hci_headr+HCI_COMMAND_HDR____opcode,htobs(cmd_opcode_pack(OGF_INFO_PARAM, OCF_READ_BD_ADDR)));
\r
377 store16(*((uint8_t*)hci_headr+HCI_COMMAND_HDR____plen),0);
\r
379 /*nastaveni pozice v poli command prikazu pro pristi prikaz. Moznost zapisu (adresa v poli = NULL)
\r
380 se overuje, az pri samotnem ukladani */
\r
381 if(bth_com_buf_info.aktual<(LENCOMMAND-2)){bth_com_buf_info.aktual++;}
\r
382 else{ bth_com_buf_info.aktual=0;};
\r
386 int bth_cmd_write_scan_enable(uint8_t set_ing_scan) //0x001A
\r
388 /*------------------------ parts of packet-----------------------*/
\r
389 uint8_t *typ_hci_paket;
\r
390 hci_command_hdr *hci_headr;
\r
391 uint8_t *bth_cmd_packet;
\r
393 /*-- determine the size of memory needed for command in buff and determine if it fit there */
\r
394 /*-------------------------------------------------------------------------------*/
\r
395 /*-- urceni potreb. velikostipro command prikaz v buff. a zjisteni zda se vejde--*/
\r
397 if(bth_array_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)
\r
399 /*setup adresses for packet parts + filling of inidividual fields*/
\r
400 int hp_size=(sizeof(uint8_t)+HCI_COMMAND_HDR_SIZE+WRITE_SCAN_ENABLE_SIZE);
\r
401 bth_array_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);
\r
402 typ_hci_paket=(uint8_t*)bth_array_adrr_comm_packet[bth_com_buf_info.aktual]; //pozice v buff, ktera je prirazena paketu
\r
403 hci_headr=(hci_command_hdr *)(((uint8_t*)typ_hci_paket)+HCI_PKT_SIZE); //pointer on head
\r
404 bth_cmd_packet=(uint8_t *)(((uint8_t*)hci_headr)+HCI_COMMAND_HDR_SIZE); //pointer on parametrs
\r
407 store16(*typ_hci_paket, HCI_COMMAND_PKT);
\r
408 store_le16((uint8_t*)hci_headr+HCI_COMMAND_HDR____opcode,htobs(cmd_opcode_pack(OGF_HOST_CTL, OCF_WRITE_SCAN_ENABLE)));
\r
409 store16(*((uint8_t*)hci_headr+HCI_COMMAND_HDR____plen),WRITE_SCAN_ENABLE_SIZE);
\r
410 store16(*bth_cmd_packet,set_ing_scan);
\r
411 /*nastaveni pozice v poli command prikazu pro pristi prikaz. Moznost zapisu (adresa v poli = NULL)
\r
412 se overuje, az pri samotnem ukladani */
\r
413 if(bth_com_buf_info.aktual<(LENCOMMAND-2)){bth_com_buf_info.aktual++;}
\r
414 else{ bth_com_buf_info.aktual=0;};
\r
418 //FIXME: All the czech comments are the same as in the first function.
\r