]> rtime.felk.cvut.cz Git - mirosot.git/blobdiff - bth_tests/bluetooth/bth_event_acc.c
Added bth_test application. Not finished.
[mirosot.git] / bth_tests / bluetooth / bth_event_acc.c
diff --git a/bth_tests/bluetooth/bth_event_acc.c b/bth_tests/bluetooth/bth_event_acc.c
new file mode 100644 (file)
index 0000000..fd14506
--- /dev/null
@@ -0,0 +1,524 @@
+\r
+\r
+/*******************************************************************\r
+  bluetooth library\r
+\r
+  hci_event_acc.c - Event fce (bth specification) - build event\r
+                  packet\r
+\r
+  Copyright (C) 2006 by Petr Kovacik petr_kovacik@gmail.com\r
+\r
+ *******************************************************************/\r
+\r
+\r
+#include <string.h>\r
+#include <stdlib.h>\r
+#include <types.h>\r
+#include "hci.h"\r
+#include "l2cap.h"\r
+#include "hci_event.h"\r
+#include "hci_command.h"\r
+\r
+#ifdef BTH_LX\r
+#include <periph/sci_rs232.h>\r
+#endif\r
+#include "inline_fce.h"\r
+\r
+\r
+\r
+typedef int (*bth_info_fce_def)(uint8_t *bth_p, uint8_t size);\r
+\r
+bth_info_fce_def bth_info_fce_ogf_01[]={\r
+  cmd_ev_none, cmd_ev_none,cmd_ev_none, cmd_ev_none, cmd_ev_none, cmd_ev_none, cmd_ev_none, cmd_ev_none,\r
+  cmd_ev_none, cmd_ev_none, cmd_ev_none, cmd_ev_01x000b, cmd_ev_none, cmd_ev_01x000d, cmd_ev_01x000e,\r
+  cmd_ev_none, cmd_ev_none, cmd_ev_none, cmd_ev_none, cmd_ev_none, cmd_ev_none, cmd_ev_none, cmd_ev_none,\r
+  cmd_ev_none, cmd_ev_none, cmd_ev_none, cmd_ev_none, cmd_ev_none, cmd_ev_none, cmd_ev_none, cmd_ev_none,\r
+  cmd_ev_none};\r
+#define BTH_OGF_01_FC (sizeof(bth_info_fce_ogf_01)/sizeof(bth_info_fce_ogf_01[0]))\r
+\r
+\r
+bth_info_fce_def bth_info_fce_ogf_02[]={\r
+  cmd_ev_none, cmd_ev_none, cmd_ev_none, cmd_ev_none, cmd_ev_none, cmd_ev_none, cmd_ev_none, cmd_ev_none,\r
+  cmd_ev_none, cmd_ev_02x0009, cmd_ev_none, cmd_ev_none, cmd_ev_02x000C, cmd_ev_02x000D};\r
+#define BTH_OGF_02_FC (sizeof(bth_info_fce_ogf_02)/sizeof(bth_info_fce_ogf_02[0]))\r
+\r
+\r
+bth_info_fce_def bth_info_fce_ogf_03[]={\r
+  cmd_ev_none, cmd_ev_none, cmd_ev_none, cmd_ev_none, cmd_ev_none, cmd_ev_none, cmd_ev_none, cmd_ev_none,\r
+  cmd_ev_03x0008, cmd_ev_03x0009, cmd_ev_none, cmd_ev_none, cmd_ev_none, cmd_ev_03x000d, cmd_ev_none, cmd_ev_none,\r
+  cmd_ev_none, cmd_ev_03x0011, cmd_ev_03x0012, cmd_ev_none, cmd_ev_03x0014, cmd_ev_03x0015,\r
+  cmd_ev_none, cmd_ev_03x0017, cmd_ev_none, cmd_ev_03x0019, cmd_ev_none, cmd_ev_none, cmd_ev_none, cmd_ev_03x001d,\r
+  cmd_ev_none, cmd_ev_03x001f, cmd_ev_none, cmd_ev_03x0021, cmd_ev_none, cmd_ev_03x0023, cmd_ev_none, cmd_ev_03x0025,\r
+  cmd_ev_none, cmd_ev_03x0027, cmd_ev_03x0028, cmd_ev_03x0029, cmd_ev_none, cmd_ev_03x002b, cmd_ev_none, cmd_ev_03x002d,\r
+  cmd_ev_03x002e,  cmd_ev_none, cmd_ev_none, cmd_ev_none, cmd_ev_none, cmd_ev_none, cmd_ev_none, cmd_ev_none, cmd_ev_03x0036,\r
+  cmd_ev_none, cmd_ev_03x0038, cmd_ev_03x0039, cmd_ev_none, cmd_ev_03x003b,\r
+  cmd_ev_none, cmd_ev_03x003d};\r
+#define BTH_OGF_03_FC (sizeof(bth_info_fce_ogf_03)/sizeof(bth_info_fce_ogf_03[0]))\r
+\r
+\r
+bth_info_fce_def bth_info_fce_ogf_04[]={\r
+  cmd_ev_none, cmd_ev_04x0001, cmd_ev_none, cmd_ev_04x0003, cmd_ev_none, cmd_ev_04x0005, cmd_ev_none, cmd_ev_04x0007,\r
+  cmd_ev_none, cmd_ev_04x0009};\r
+#define BTH_OGF_04_FC (sizeof(bth_info_fce_ogf_04)/sizeof(bth_info_fce_ogf_04[0]))\r
+\r
+\r
+\r
+/*********************************************************************************/\r
+\r
+/*return values\r
+  0 = OK - command removed from the queue\r
+  -1 = the queue was searched but the OPCODE was not found\r
+  +num = an index of verified item in array "bth_pole_adrr_check_packet" with the searched opcode\r
+*/\r
+int bth_del_event(uint16_t opcode)\r
+{\r
+  int i;\r
+  uint16_t opcode_pkt;\r
+  for(i=0;i<LENCOMMAND;i++)\r
+  {\r
+    if(bth_array_adrr_check_packet[i]!=NULL)\r
+    {\r
+      __bthtomc16(&opcode_pkt,((uint8_t*)bth_array_adrr_check_packet[i]+HCI_PKT_SIZE));\r
+      if(opcode_pkt==opcode)\r
+      {return i;};\r
+    };\r
+  };\r
+  return(-1);\r
+};\r
+\r
+/****************************************************************************/\r
+/*------------------------ INDIVIDUAL EVENT FUNCTIONS ----------------------*/\r
+/****************************************************************************/\r
+/****************************************************************************/\r
+/*returned values\r
+  0 = everything OK\r
+  1 = field not found\r
+  2 = there was no commands in the confirmation queue to confirm\r
+  3 = status embody an error of the command\r
+*/\r
+int bth_evt_none(uint8_t *bth_p, uint8_t size)  //func with nonexisting index of event code\r
+{\r
+  return -4;\r
+};\r
+\r
+\r
+int bth_evt_inquiry_complete(uint8_t *bth_p, uint8_t size)  //0x01 - EVT_INQUIRY_COMPLETE\r
+{\r
\r
+  return (*((uint8_t*)bth_p));\r
+};\r
+int bth_evt_inquiry_result(uint8_t *bth_p, uint8_t size)   //0x02\r
+{\r
+  return (-3);\r
+\r
+};\r
+\r
+int bth_evt_conn_complete(uint8_t *bth_p, uint8_t size)   //0x03\r
+{\r
+  bths_connect_bluet *bth_q;\r
+  int j;\r
+\r
+  for(j=0; j<=8;j++)  //8 possible devices, witch which we can comunicate\r
+  {\r
+    if(bth_connected[j]==NULL)\r
+    {break;};\r
+  }\r
+  if(j==9){return (-1);}; //it is possible to communicate with 8 devices at maximum. This one is the 9th one.\r
+  /* Add the device to the list od connected devices.*/\r
+  bth_connected[j]=(bths_connect_bluet*)calloc(1,sizeof(bths_connect_bluet));\r
+  bth_q=(bths_connect_bluet*)bth_connected[j];\r
+  /*Fill the structure of the connected device with information on remote device*/\r
+  memcpy(&(bth_q->bdaddr),(uint8_t*)bth_p+EVT_CONN_COMPLETE____bdaddr,sizeof(bdaddr_t));\r
+//  store_le16(&(bth_q->handle),(uint16_t)*(uint16_t*)((uint8_t*)bth_p+EVT_CONN_COMPLETE____handle));\r
+  __bthtomc16((uint8_t*)&(bth_q->handle),((uint8_t*)bth_p+EVT_CONN_COMPLETE____handle));\r
+/*  sci_rs232_sendch('c',sci_rs232_chan_default); //do PC\r
+  VypisHexa((void*)&(((bths_connect_bluet*)bth_connected[j])->handle),2);\r
+  sci_rs232_sendch('c',sci_rs232_chan_default); //do PC*/\r
+  \r
+  store8(bth_q->link_type,*((uint8_t*)bth_p+EVT_CONN_COMPLETE____link_type));\r
+  store8(bth_q->encr_mode,*((uint8_t*)bth_p+EVT_CONN_COMPLETE____encr_mode));\r
+\r
+  bth_cmd_write_link_policy_settings(bth_q->handle,htobs(0x000f)); //reply\r
+  return (*((uint8_t*)bth_p+EVT_CONN_COMPLETE____status));\r
+};\r
+\r
+int bth_evt_conn_request(uint8_t *bth_p, uint8_t size)   //0x04\r
+{\r
+  bdaddr_t  bdaddr;\r
+//  evt_conn_request bth_q;\r
+  /*BD address of requesting device*/\r
+  memcpy(&bdaddr,(uint8_t*)bth_p+EVT_CONN_REQUEST____bdaddr,sizeof(bdaddr_t));\r
+//  if(bth_seach_bdaddr(&bdaddr,&(bth_accept_bd_addr[0]),1));\r
+  bth_accept_conn_req_cp(&bdaddr);\r
+  return 0;\r
+};\r
+\r
+\r
+\r
+int bth_evt_disconn_complete(uint8_t *bth_p, uint8_t size)  //0x05\r
+{\r
+  int i;\r
+  evt_disconn_complete  bth_q;\r
+//  store_le16(&bth_q.handle,*((uint16_t*)((uint8_t*)bth_p+EVT_DISCONN_COMPLETE____status)));\r
+  __bthtomc16((uint8_t*)&(bth_q.handle),((uint8_t*)bth_p+EVT_DISCONN_COMPLETE____status));\r
+  i=bth_find_conected_dev(bth_q.handle);\r
+  free(bth_connected[i]); bth_connected[i]=NULL;\r
+//  bth_local_info.busy=0;\r
+  if(*((uint8_t*)bth_p+EVT_DISCONN_COMPLETE____reason)==0)\r
+    return (*((uint8_t*)bth_p+EVT_DISCONN_COMPLETE____status));\r
+  else\r
+    return (*((uint8_t*)bth_p+EVT_DISCONN_COMPLETE____reason));\r
+};\r
+\r
+int bth_evt_auth_complete(uint8_t *bth_p, uint8_t size)  //0x06\r
+{\r
+  return (-3);\r
+};\r
+\r
+int bth_remote_name_req_complete(uint8_t *bth_p, uint8_t size)   //0x07\r
+{\r
+  return (-3);\r
+};\r
+\r
+int bth_evt_encrypt_cahnge(uint8_t *bth_p, uint8_t size)  //0x08\r
+{\r
+  return (-3);\r
+};\r
+\r
+int bth_evt_change_conn_link_key_complete(uint8_t *bth_p, uint8_t size) //0x09\r
+{\r
+  return (-3);\r
+};\r
+\r
+int bth_evt_master_link_key_complete(uint8_t *bth_p, uint8_t size) //0x0A\r
+{\r
+  return (-3);\r
+};\r
+\r
+int bth_evt_read_remote_features_complete(uint8_t *bth_p, uint8_t size)  //0x0B\r
+{\r
+  return (-3);\r
+};\r
+\r
+int bth_evt_read_remote_version_complete(uint8_t *bth_p, uint8_t size)  //0x0C\r
+{\r
+  return (-3);\r
+};\r
+\r
+int bth_evt_qos_setup_complete(uint8_t *bth_p, uint8_t size) //0x0D\r
+{\r
+  return (-3);\r
+};\r
+\r
+int bth_evt_cmd_complete(uint8_t *bth_p, uint8_t size)  //0x0E\r
+{\r
+  evt_cmd_complete bth_q;\r
+  uint16_t opcode,ogf,ocf;\r
+  int index=-1;\r
+  \r
+  store8(bth_q.ncmd,*((uint8_t*)bth_p+EVT_CMD_COMPLETE____ncmd));\r
+//  store_le16(&bth_q.opcode,*((uint16_t*)((uint8_t*)bth_p+EVT_CMD_COMPLETE____opcode)));\r
+  __bthtomc16(&bth_q.opcode,(((uint8_t*)bth_p+EVT_CMD_COMPLETE____opcode)));\r
+  index=bth_del_event(bth_q.opcode);\r
+  if(index==-1)\r
+  {\r
+    return -1;\r
+  }\r
+  else\r
+  {\r
+    if(size-EVT_CMD_COMPLETE_SIZE==1) /* this is just a confirmation - status*/\r
+    {\r
+      if(*((uint8_t*)bth_p+3)==0)\r
+      {\r
+        free(bth_array_adrr_check_packet[index]);\r
+        bth_array_adrr_check_packet[index]=NULL;\r
+        bth_local_info.busy=0;\r
+        return 0; //no complications was encountered during command execution\r
+      }\r
+      else\r
+      {\r
+        /*status is not OK - an error occured - the sent command is still in the confirmation queue */\r
+        free(bth_array_adrr_check_packet[index]);\r
+        bth_array_adrr_check_packet[index]=NULL;\r
+        bth_local_info.busy=0;\r
+        return((int)*((uint8_t*)bth_p+EVT_CMD_COMPLETE_SIZE));\r
+      };\r
+    }\r
+    else\r
+    {\r
+      /*I split to obcode to OGF and OCF and convert it to an one-byte variable*/\r
+//      store_le16(&opcode,*(uint16_t*)((uint8_t*)bth_p+EVT_CMD_COMPLETE____opcode));\r
+      __bthtomc16((uint8_t*)&(opcode),((uint8_t*)bth_p+EVT_CMD_COMPLETE____opcode));\r
+\r
+      ogf=(uint8_t)cmd_opcode_ogf(opcode);\r
+      ocf=(uint8_t)cmd_opcode_ocf(opcode);\r
+      \r
+      switch(ogf)\r
+      {\r
+        case 0x01 :\r
+          bth_local_info.busy=0;\r
+          if(ocf<BTH_OGF_01_FC)\r
+            return (bth_info_fce_ogf_01[ocf](((uint8_t*)bth_p+EVT_CMD_COMPLETE____opcode+2),EVT_CMD_COMPLETE_SIZE));\r
+          else return (-4);\r
+        case 0x02 :\r
+          bth_local_info.busy=0;\r
+          if(ocf<BTH_OGF_02_FC)\r
+            return (bth_info_fce_ogf_02[ocf](((uint8_t*)bth_p+EVT_CMD_COMPLETE____opcode+2),size-EVT_CMD_COMPLETE_SIZE)); //the number 0x00 is a random guess\r
+          else return (-4);\r
+        case 0x03 :\r
+          bth_local_info.busy=0;\r
+          if(ocf<BTH_OGF_03_FC)\r
+            return (bth_info_fce_ogf_03[ocf](((uint8_t*)bth_p+EVT_CMD_COMPLETE____opcode+2),size-EVT_CMD_COMPLETE_SIZE)); //the number 0x00 is a random guess\r
+          else return (-4);\r
+          \r
+        case 0x04 :\r
+          bth_local_info.busy=0;\r
+          if(ocf<BTH_OGF_04_FC)\r
+            return (bth_info_fce_ogf_04[ocf](((uint8_t*)bth_p+EVT_CMD_COMPLETE____opcode+2),size-EVT_CMD_COMPLETE_SIZE)); //the number 0x00 is a random guess\r
+          else return (-4);\r
+\r
+      };\r
+    };\r
+  };\r
+  return (-1);\r
+};\r
+\r
+\r
+int bth_evt_cmd_status(uint8_t *bth_p, uint8_t size) //0x0F\r
+{\r
+  evt_cmd_status bth_q;\r
+  store8(bth_q.status,*((uint8_t*)bth_p+EVT_CMD_STATUS____status));\r
+  store8(bth_q.ncmd,*((uint8_t*)bth_p+EVT_CMD_STATUS____ncmd));\r
+//  store_le16(&bth_q.opcode,*((uint16_t*)((uint8_t*)bth_p+EVT_CMD_STATUS____opcode)));\r
+  __bthtomc8(&bth_q.opcode,(((uint8_t*)bth_p+EVT_CMD_STATUS____opcode)));\r
+//  memcpy(&bth_q.opcode,(((uint8_t*)bth_p+EVT_CMD_STATUS____opcode)),2);\r
+  uint8_t ogf, ocf;\r
+  int index;\r
+\r
+  index=bth_del_event(bth_q.opcode);\r
+  if(index==-1)\r
+  {\r
+    bth_local_info.busy=0;\r
+    return -1;\r
+  }\r
+  else\r
+  {\r
+    if(size-EVT_CMD_STATUS_SIZE==0) /*this is just a confirmation - status*/\r
+    {\r
+      if(bth_q.status==0)\r
+      {\r
+        free(bth_array_adrr_check_packet[index]);\r
+        bth_array_adrr_check_packet[index]=NULL;\r
+      }\r
+      else\r
+      {\r
+        /*status is not OK - an error occured - the sent command is still in the confirmation queue */\r
+        free(bth_array_adrr_check_packet[index]);\r
+        bth_array_adrr_check_packet[index]=NULL;\r
+      };\r
+    }\r
+    else\r
+    {\r
+      /*rozdelim obcode na OGF a OCF a prevedu na jednobytovou promenou*/ //same comment as in previous function\r
+      ogf=(uint8_t)cmd_opcode_ogf((uint16_t)*(uint16_t*)((uint8_t*)bth_p+EVT_CMD_COMPLETE____opcode));\r
+      ocf=(uint8_t)cmd_opcode_ocf((uint16_t)*(uint16_t*)((uint8_t*)bth_p+EVT_CMD_COMPLETE____opcode));\r
+/*This is a little more complicated cmd_status, which stores data inside and not the end. Other functions are split according to the obcode. Currently, functions are not implemented, only the "guidepost" is done.*/\r
+/*jedna se o slozitejsi cmd_status, ktery sebou nese i data, nikoliv zaver, dalsi fce jsou deleny podle\r
+obcodu. Fce nejsou napsany, je udelany pouze rozcestnik*/\r
+      switch(ogf)  \r
+      {\r
+        case 0x01 : break;\r
+        case 0x02 : break;\r
+        case 0x03 : break;\r
+        case 0x04 : break;\r
+      };\r
+    };\r
+    bth_local_info.busy=0; //NOTE do it differently, not always true\r
+\r
+  };\r
+  return(bth_q.status);\r
+};\r
+\r
+int bth_evt_hardware_error(uint8_t *bth_p, uint8_t size) //0x10\r
+{\r
+  return (-3);\r
+};\r
+\r
+int bth_evt_flush_occurred(uint8_t *bth_p, uint8_t size) //0x11\r
+{\r
+  return (-3);\r
+};\r
+\r
+int bth_evt_role_cahage(uint8_t *bth_p, uint8_t size) //0x12\r
+{\r
+  return (-3);\r
+};\r
+\r
+int bth_evt_num_comp_pkts(uint8_t *bth_p, uint8_t size)  //0x13\r
+{\r
+  evt_num_comp_pkts bth_q;\r
+  uint16_t handle,num_pkt;\r
+  int i,j;\r
+  store16(bth_q.num_hndl,*((uint8_t*)bth_p+EVT_NUM_COMP_PKTS____num_hndl));\r
+/*Search through all devices with which the communications was started???*/\r
+/*prohledam vsechna zarizeni, se kterymi mam uzavrenou komunikaci*/\r
+  for(j=0; j<(bth_q.num_hndl);j++)\r
+  {\r
+    __bthtomc16((uint8_t*)&(handle),((uint8_t*)bth_p+1+(j*4)));\r
+\r
+    __bthtomc16((uint8_t*)&(num_pkt),((uint8_t*)bth_p+3+(j*4)));\r
+\r
+    for(i=0;i<8;i++)\r
+    {\r
+      if(bth_connected[i]!=NULL)\r
+      {\r
+        if(bth_connected[i]->handle==handle)\r
+        {\r
+//          sci_rs232_sendch(';',sci_rs232_chan_default); //do PC\r
+//           VypisHexa((void*)&(handle),2);\r
+//           sci_rs232_sendch(';',sci_rs232_chan_default); //do PC\r
+          break;\r
+        };\r
+      };\r
+    };\r
+  };\r
+  bth_local_info.busy=0;\r
+  return(0);\r
+};\r
+\r
+int bth_evt_mode_change(uint8_t *bth_p, uint8_t size)  //0x14\r
+{\r
+  return (-3);\r
+};\r
+\r
+int bth_evt_return_link_keys(uint8_t *bth_p, uint8_t size)  //0x15\r
+{\r
+  return(-3);\r
+};\r
+\r
+int bth_evt_pin_code_req(uint8_t *bth_p, uint8_t size) //0x16\r
+{\r
+  return (-3);\r
+};\r
+\r
+int bth_evt_link_key_req(uint8_t *bth_p, uint8_t size)  //0x17\r
+{\r
+  return (-3);\r
+};\r
+\r
+int bth_evt_link_key_notify(uint8_t *bth_p, uint8_t size)  //0x18\r
+{\r
+  return (-3);\r
+};\r
+\r
+int bth_evt_loopback_command(uint8_t *bth_p, uint8_t size)  //0x19\r
+{\r
+  return (-3);\r
+};\r
+\r
+int bth_evt_data_buffer_overflow(uint8_t *bth_p, uint8_t size) //0x1A\r
+{\r
+  return (-3);\r
+};\r
+\r
+int bth_evt_max_slots_change(uint8_t *bth_p, uint8_t size)  //0x1B\r
+{\r
+  evt_max_slots_change bth_q;\r
+  int i;\r
+//  store_le16(&bth_q.handle,*((uint16_t*)((uint8_t*)bth_p+EVT_MAX_SLOTS_CHANGE____handle)));\r
+  __bthtomc16((uint8_t*)&(bth_q.handle),(uint8_t*)bth_p+EVT_MAX_SLOTS_CHANGE____handle);\r
+  \r
+//  store_le16(&bth_q.max_slots,*((uint16_t*)((uint8_t*)bth_p+EVT_MAX_SLOTS_CHANGE____max_slots)));\r
+  __bthtomc16((uint8_t*)&(bth_q.max_slots),(uint8_t*)bth_p+EVT_MAX_SLOTS_CHANGE____max_slots);\r
+\r
+/*Search through all devices with which the communications was started???*/\r
+  /*prohledam vsechna zarizeni, se kterymi mam uzavrenou komunikaci*/\r
+  for(i=0;i<8;i++)\r
+  {\r
+/*    sci_rs232_sendch('j',sci_rs232_chan_default); //do PC\r
+    VypisHexa((void*)&(((bths_connect_bluet*)bth_connected[i])->handle),2);\r
+    sci_rs232_sendch('j',sci_rs232_chan_default); //do PC*/\r
+    if(bth_connected[i]!=NULL)\r
+    {\r
+      \r
+/*      sci_rs232_sendch('k',sci_rs232_chan_default); //do PC\r
+      VypisHexa((void*)&(bth_q.handle),2);\r
+      sci_rs232_sendch('k',sci_rs232_chan_default); //do PC*/\r
+      \r
+      if(bth_connected[i]->handle==bth_q.handle)\r
+      {\r
+\r
+        bth_connected[i]->max_slots=bth_q.max_slots;\r
+        return (0);\r
+      };\r
+    };\r
+  };\r
+  return(-1);\r
+};\r
+\r
+int bth_evt_read_clock_offset_complete(uint8_t *bth_p, uint8_t size)  //0x1C\r
+{\r
+  return (-3);\r
+};\r
+\r
+int bth_evt_conn_ptype_changed(uint8_t *bth_p, uint8_t size)  //0x1D\r
+{\r
+  evt_conn_ptype_changed bth_q;\r
+//  uint16_t local_ptype;\r
+  int dev_num;\r
+  store16(bth_q.status,*((uint8_t*)bth_p+EVT_CONN_PTYPE_CHANGED____status));\r
+//  store_le16(&bth_q.handle,*((uint16_t*)((uint8_t*)bth_p+EVT_CONN_PTYPE_CHANGED____handle)));\r
+  __bthtomc16((uint8_t*)&(bth_q.handle),(uint8_t*)bth_p+EVT_CONN_PTYPE_CHANGED____handle);\r
+\r
+//  store_le16(&bth_q.ptype,*((uint16_t*)((uint8_t*)bth_p+EVT_CONN_PTYPE_CHANGED____ptype)));\r
+  __bthtomc16((uint8_t*)&(bth_q.ptype),(uint8_t*)bth_p+EVT_CONN_PTYPE_CHANGED____ptype);\r
+\r
+  dev_num=bth_find_conected_dev(bth_q.handle);\r
+//bth_local_info.pkt_type; - local info on packets\r
+//  Change_Connection_Packet_Type - command, which can in case of need setup its packets\r
+//skterym se pripadne daji nastavit svoje packety\r
+  if(dev_num>-1);\r
+  {\r
+    bth_connected[dev_num]->ptype=bth_q.ptype;\r
+    return(bth_q.status);\r
+  };\r
+  return(-1);\r
+\r
+};\r
+\r
+int bth_evt_qos_violation(uint8_t *bth_p, uint8_t size) //0x1E\r
+{\r
+  return (-3);\r
+\r
+};\r
+\r
+int bth_evt_page_scan_mode_change(uint8_t *bth_p, uint8_t size)  //0x1F\r
+{\r
+  return (-3);\r
+\r
+\r
+};\r
+\r
+int bth_evt_pscan_rep_mode_change(uint8_t *bth_p, uint8_t size)  //0x20\r
+{\r
+  evt_pscan_rep_mode_change bth_q;\r
+  memcpy(&(bth_q.bdaddr),(uint8_t*)bth_p+EVT_PSCAN_REP_MODE_CHANGE____bdaddr,sizeof(bdaddr_t));\r
+  store16(bth_q.pscan_rep_mode,*((uint8_t*)bth_p+EVT_PSCAN_REP_MODE_CHANGE____pscan_rep_mode));\r
+        \r
+  /*Search through all devices with which the communications was started, needs to be  written up */\r
+  /*prohledam vsechna zarizeni dle BDADDR, se kterymi mam uzavrenou komunikaci -NUTNO DOPSAT NOTE*/\r
+  //memcpy\r
+    \r
+  return(-1);\r
+};\r
+\r
+int bth_evt_flow_spec_complete(uint8_t *bth_p, uint8_t size)  //0x21\r
+{\r
+  return (-3);\r
+};\r
+\r
+int bth_evt_inquiry_result_with_rssi(uint8_t *bth_p, uint8_t size)  //0x22\r
+{\r
+  return (-3);\r
+\r
+};\r