]> rtime.felk.cvut.cz Git - mirosot.git/blobdiff - bluetooth/bth_command.c
An unsucesfull attempt to clean bluetooth library and make it working.
[mirosot.git] / bluetooth / bth_command.c
index 6979574fae6ef305d8fdd860264851544c84f1be..f275b1057082aceb2c15ba718e1e32e870063b42 100644 (file)
 \r
 #include <string.h>\r
 #include <stdlib.h>\r
-#ifdef BTH_LX\r
 #include <types.h>\r
+#ifdef BTH_LX\r
 #include <cpu_def.h>\r
 #include <h8s2638h.h>\r
 #include <periph/sci_rs232.h>\r
 #include <system_def.h>\r
-\r
-#else\r
-#include "types.h"\r
 #endif\r
 \r
 #include "hci.h"\r
@@ -63,13 +60,13 @@ int bth_cmd_inqury(uint8_t length, uint8_t rsp, uint8_t *lap)
 /*-- 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
+    if(bth_array_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)\r
     {return 1;};\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]; //possition in buff, which is assigned to the packet\r
+    bth_array_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);\r
+    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
     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
@@ -109,12 +106,12 @@ int change_connection_packet_type(uint16_t handle, uint16_t ptype)
 /*-------------------------------------------------------------------------------*/\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
+    if(bth_array_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)\r
     {return 1;};\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
+    bth_array_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);\r
+    typ_hci_paket=(uint8_t*)bth_array_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=(set_conn_ptype_cp *)(((uint8_t*)hci_headr)+HCI_COMMAND_HDR_SIZE);   //pointer on parametrs\r
 \r
@@ -143,13 +140,13 @@ int bth_cmd_disconnect(uint16_t handle, uint8_t reason)
 /*-------------------------------------------------------------------------------*/\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
+    if(bth_array_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)\r
     {return 1;};\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
-    typ_hci_paket=(uint8_t*)bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]; //pozice v buff, ktera je prirazena paketu\r
+    bth_array_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);\r
+    typ_hci_paket=(uint8_t*)bth_array_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=(disconnect_cp *)(((uint8_t*)hci_headr)+HCI_COMMAND_HDR_SIZE);   //pointer on parametrs\r
 \r
@@ -185,13 +182,13 @@ int bth_cmd_write_link_policy_settings(uint16_t handle, uint16_t policy) /*obcod
 /*-------------------------------------------------------------------------------*/\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
+    if(bth_array_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)\r
     {return 1;};\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
-    typ_hci_paket=(uint8_t*)bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]; //pozice v buff, ktera je prirazena paketu\r
+    bth_array_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);\r
+    typ_hci_paket=(uint8_t*)bth_array_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=(write_link_policy_cp *)(((uint8_t*)hci_headr)+HCI_COMMAND_HDR_SIZE);   //pointer on parametrs\r
 \r
@@ -224,13 +221,13 @@ int bth_cmd_reset(void)           /*opcode=0x0C03 OCF = 0x0003, OGF = 0x03*/
 /*-------------------------------------------------------------------------------*/\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
+    if(bth_array_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)\r
     {return 1;};\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
-    typ_hci_paket=(uint8_t*)bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]; //pozice v buff, ktera je prirazena paketu\r
+    bth_array_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);\r
+    typ_hci_paket=(uint8_t*)bth_array_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
 \r
     store16(*typ_hci_paket, HCI_COMMAND_PKT);\r
@@ -265,13 +262,13 @@ int bth_accept_conn_req_cp(bdaddr_t *bdaddr)                 /*0x01 - 0x0009*/
 /*-------------------------------------------------------------------------------*/\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
+    if(bth_array_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)\r
     {return 1;};\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
-    typ_hci_paket=(uint8_t*)bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]; //pozice v buff, ktera je prirazena paketu\r
+    bth_array_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);\r
+    typ_hci_paket=(uint8_t*)bth_array_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=(accept_conn_req_cp*)(((uint8_t*)hci_headr)+HCI_COMMAND_HDR_SIZE);   //pointer on parametrs\r
 \r
@@ -298,13 +295,13 @@ int bth_cmd_write_page_scan(uint16_t interval, uint16_t window)        /*obcode=
 /*-------------------------------------------------------------------------------*/\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
+    if(bth_array_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)\r
     {return 1;};\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
-    typ_hci_paket=(uint8_t*)bth_pole_adrr_comm_packet[bth_com_buf_info.aktual]; //pozice v buff, ktera je prirazena paketu\r
+    bth_array_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);\r
+    typ_hci_paket=(uint8_t*)bth_array_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=(write_page_activity_cp *)(((uint8_t*)hci_headr)+HCI_COMMAND_HDR_SIZE);   //pointer on parametrs\r
 \r
@@ -336,12 +333,12 @@ int bth_cmd_write_inquiry_scan_activity(uint16_t interval, uint16_t window) //0x
 /*-------------------------------------------------------------------------------*/\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
+    if(bth_array_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)\r
     {return 1;};\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
+    bth_array_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);\r
+    typ_hci_paket=(uint8_t*)bth_array_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=(write_inq_activity_cp *)(((uint8_t*)hci_headr)+HCI_COMMAND_HDR_SIZE);   //pointer on parametrs\r
 \r
@@ -367,12 +364,12 @@ int bth_cmd_read_bd_addr(void) /*opcode=0x0910 OCF = 0x0009, OGF = 0x04*/
 /*-------------------------------------------------------------------------------*/\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
+    if(bth_array_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)\r
     {return 1;};\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
+    bth_array_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);\r
+    typ_hci_paket=(uint8_t*)bth_array_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
 \r
     store16(*typ_hci_paket, HCI_COMMAND_PKT);\r
@@ -397,12 +394,12 @@ int bth_cmd_write_scan_enable(uint8_t set_ing_scan) //0x001A
 /*-------------------------------------------------------------------------------*/\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
+    if(bth_array_adrr_comm_packet[bth_com_buf_info.aktual]!=NULL)\r
     {return 1;};\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
+    bth_array_adrr_comm_packet[bth_com_buf_info.aktual]=malloc(hp_size);\r
+    typ_hci_paket=(uint8_t*)bth_array_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=(uint8_t *)(((uint8_t*)hci_headr)+HCI_COMMAND_HDR_SIZE);   //pointer on parametrs\r
 \r