X-Git-Url: https://rtime.felk.cvut.cz/gitweb/mirosot.git/blobdiff_plain/7d1f56342192651c81dcc6844ea46a72dfd198f6..86608e251db3b85b5d9cec1d487261b11325edbe:/bluetooth/bth_event_acc.c diff --git a/bluetooth/bth_event_acc.c b/bluetooth/bth_event_acc.c index 98032a6..e4966a5 100644 --- a/bluetooth/bth_event_acc.c +++ b/bluetooth/bth_event_acc.c @@ -65,10 +65,10 @@ bth_info_fce_def bth_info_fce_ogf_04[]={ /*********************************************************************************/ -/*navratove hodnoty - 0 = OK - prikaz odstranen z fronty - -1 = fronta prohledana, ale nebyl tam nalezen hledany OBCOD - +num = index overovane polozky v poli "bth_pole_adrr_check_packet" s hledanym obcodem +/*return values + 0 = OK - command removed from the queue + -1 = the queue was searched but the OPCODE was not found + +num = an index of verified item in array "bth_pole_adrr_check_packet" with the searched opcode */ int bth_del_event(uint16_t opcode) { @@ -87,16 +87,16 @@ int bth_del_event(uint16_t opcode) }; /****************************************************************************/ -/*------------------------ JEDNOTLIVE EVENT FUNKCE -------------------------*/ +/*------------------------ INDIVIDUAL EVENT FUNCTIONS ----------------------*/ /****************************************************************************/ /****************************************************************************/ -/*navratovo hodnoty - 0 = vse OK - 1 = polozka nenalezena - 2 = v potvrzovaci fronte nebyly zadne prikazy k potvrzeni - 3 = status vykazuje chybu prikazu +/*returned values + 0 = everything OK + 1 = field not found + 2 = there was no commands in the confirmation queue to confirm + 3 = status embody an error of the command */ -int bth_evt_none(uint8_t *bth_p, uint8_t size) //fce s neex. indexem evt codu +int bth_evt_none(uint8_t *bth_p, uint8_t size) //func with nonexisting index of event code { return -4; }; @@ -118,16 +118,16 @@ int bth_evt_conn_complete(uint8_t *bth_p, uint8_t size) //0x03 bths_connect_bluet *bth_q; int j; - for(j=0; j<=8;j++) //8 moznych zarizeni, se kterymi lze komunikovat + for(j=0; j<=8;j++) //8 possible devices, witch which we can comunicate { if(bth_connected[j]==NULL) {break;}; } - if(j==9){return (-1);}; //je mozno komunikovat pouze s 8-mi zarizenimi, toto je devate - /*uvedu zarizeni do seznamu pripojenych zarizeni*/ + if(j==9){return (-1);}; //it is possible to communicate with 8 devices at maximum. This one is the 9th one. + /* Add the device to the list od connected devices.*/ bth_connected[j]=(bths_connect_bluet*)calloc(1,sizeof(bths_connect_bluet)); bth_q=(bths_connect_bluet*)bth_connected[j]; - /*naplnim strukturu pripojeneho zarizeni informacemi o vzdalenem bth*/ + /*Fill the structure of the connected device with information on remote device*/ memcpy(&(bth_q->bdaddr),(uint8_t*)bth_p+EVT_CONN_COMPLETE____bdaddr,sizeof(bdaddr_t)); // store_le16(&(bth_q->handle),(uint16_t)*(uint16_t*)((uint8_t*)bth_p+EVT_CONN_COMPLETE____handle)); __bthtomc16((uint8_t*)&(bth_q->handle),((uint8_t*)bth_p+EVT_CONN_COMPLETE____handle)); @@ -138,7 +138,7 @@ int bth_evt_conn_complete(uint8_t *bth_p, uint8_t size) //0x03 store16(bth_q->link_type,*((uint8_t*)bth_p+EVT_CONN_COMPLETE____link_type)); store16(bth_q->encr_mode,*((uint8_t*)bth_p+EVT_CONN_COMPLETE____encr_mode)); - bth_cmd_write_link_policy_settings(bth_q->handle,htobs(0x000f)); //odpoved + bth_cmd_write_link_policy_settings(bth_q->handle,htobs(0x000f)); //reply return (*((uint8_t*)bth_p+EVT_CONN_COMPLETE____status)); }; @@ -146,7 +146,7 @@ int bth_evt_conn_request(uint8_t *bth_p, uint8_t size) //0x04 { bdaddr_t bdaddr; // evt_conn_request bth_q; - /*BD adresa zadajiciho zarizeni*/ + /*BD address of requesting device*/ memcpy(&bdaddr,(uint8_t*)bth_p+EVT_CONN_REQUEST____bdaddr,sizeof(bdaddr_t)); // if(bth_seach_bdaddr(&bdaddr,&(bth_accept_bd_addr[0]),1)); bth_accept_conn_req_cp(&bdaddr); @@ -226,18 +226,18 @@ int bth_evt_cmd_complete(uint8_t *bth_p, uint8_t size) //0x0E } else { - if(size-EVT_CMD_COMPLETE_SIZE==1) /*jedna se pouze o potvrzeni - status*/ + if(size-EVT_CMD_COMPLETE_SIZE==1) /* this is just a confirmation - status*/ { if(*((uint8_t*)bth_p+3)==0) { free(bth_pole_adrr_check_packet[index]); bth_pole_adrr_check_packet[index]=NULL; bth_local_info.busy=0; - return 0; //prikaz probehl bez komplikaci + return 0; //no complications was encountered during command execution } else { - /*status neni OK - nastala chyba - odeslany comand prikaz je stale ve fronte k potvrzeni*/ + /*status is not OK - an error occured - the sent command is still in the confirmation queue */ free(bth_pole_adrr_check_packet[index]); bth_pole_adrr_check_packet[index]=NULL; bth_local_info.busy=0; @@ -246,7 +246,7 @@ int bth_evt_cmd_complete(uint8_t *bth_p, uint8_t size) //0x0E } else { - /*rozdelim obcode na OGF a OCF a prevedu na jednobytovou promenou*/ + /*I split to obcode to OGF and OCF and convert it to an one-byte variable*/ // store_le16(&opcode,*(uint16_t*)((uint8_t*)bth_p+EVT_CMD_COMPLETE____opcode)); __bthtomc16((uint8_t*)&(opcode),((uint8_t*)bth_p+EVT_CMD_COMPLETE____opcode)); @@ -263,18 +263,18 @@ int bth_evt_cmd_complete(uint8_t *bth_p, uint8_t size) //0x0E case 0x02 : bth_local_info.busy=0; if(ocf-1); { bth_connected[dev_num]->ptype=bth_q.ptype; @@ -501,6 +505,7 @@ int bth_evt_pscan_rep_mode_change(uint8_t *bth_p, uint8_t size) //0x20 memcpy(&(bth_q.bdaddr),(uint8_t*)bth_p+EVT_PSCAN_REP_MODE_CHANGE____bdaddr,sizeof(bdaddr_t)); store16(bth_q.pscan_rep_mode,*((uint8_t*)bth_p+EVT_PSCAN_REP_MODE_CHANGE____pscan_rep_mode)); + /*Search through all devices with which the communications was started, needs to be written up */ /*prohledam vsechna zarizeni dle BDADDR, se kterymi mam uzavrenou komunikaci -NUTNO DOPSAT NOTE*/ //memcpy