]> rtime.felk.cvut.cz Git - mirosot.git/blob - bluetooth/bth_error.c
99dfb25fcfd87aca3817026212e4f00bebfee0e4
[mirosot.git] / bluetooth / bth_error.c
1 #ifdef BTH_LX\r
2 #include <types.h>\r
3 #include <cpu_def.h>\r
4 #include <h8s2638h.h>\r
5 #include <system_def.h>\r
6 #include <periph/sci_rs232.h>\r
7 #else\r
8 #include "types.h"\r
9 #endif\r
10 \r
11 #include <stdlib.h>\r
12 #include "hci.h"\r
13 #include "hci_error.h"\r
14 \r
15 \r
16 /**\r
17  * chyby generovane bth zarizenim\r
18 */\r
19 \r
20 static struct {\r
21         uint8_t error_code;\r
22         char *error_doc;\r
23 } status_command[] = {\r
24    { 0x00,   "Status OK"                                },\r
25    { 0x01,   "Unknown HCI Command"                      },\r
26    { 0x02,   "No Connection"                            },\r
27    { 0x03,   "Hardware Failure"                         },\r
28    { 0x04,   "Page Timeout"                             },\r
29    { 0x05,   "Authentication Failure"                   },\r
30    { 0x06,   "Key Missing"                              },\r
31    { 0x07,   "Memory Full"                              },\r
32    { 0x08,   "Connection Timeout"                       },\r
33    { 0x09,   "Max Number Of Connections"                },\r
34    { 0x0A,   "Max Number Of SCO Connections To A Device"},\r
35    { 0x0B,   "ACL connection already exists"            },\r
36    { 0x0C,   "Command Disallowed"                       },\r
37    { 0x0D,   "Host Rejected due to limited resources"   },\r
38    { 0x0E,   "Host Rejected due to security reasons"    },\r
39    { 0x0F,   "Host Rejected due to remote device is only a personal device" },\r
40    { 0x10,   "Host Timeout"                             },\r
41    { 0x11,   "Unsupported Feature or Parameter Value"   },\r
42    { 0x12,   "Invalid HCI Command Parameters"           },\r
43    { 0x13,   "Other End Terminated Connection: User Ended Connection" },\r
44    { 0x14,   "Other End Terminated Connection: Low Resources"         },\r
45    { 0x15,   "Other End Terminated Connection: About to Power Off"    },\r
46    { 0x16,   "Connection Terminated by Local Host"      },\r
47    { 0x17,   "Repeated Attempts"                        },\r
48 };\r
49 \r
50 /**\r
51 * vypis chyby na terminal pres RS232\r
52 */\r
53 void bth_error_detect_status(uint8_t status_num)\r
54 {\r
55   uint8_t *message;\r
56   int i=0;\r
57   if(status_num<sizeof(status_command));\r
58   {\r
59     message=status_command[status_num].error_doc;\r
60     while(*(message+i)!=0)\r
61     {\r
62       #ifdef BTH_LX\r
63       sci_rs232_sendch(*(message+i),sci_rs232_chan_default); //do PC\r
64       #endif\r
65       i++;\r
66     };\r
67   };\r
68   return;\r
69 };\r
70 \r
71 /**\r
72  * chyby programu - nutno upravit navratove parametry - sedi jenom 0 a 3\r
73 */\r
74 static struct {\r
75         uint8_t error_code;\r
76         char *error_doc;\r
77  }event_command[] = {\r
78    { 0x00,   "Status OK"                                },\r
79    { 0x01,   "nespecifikovana chyba"                    },\r
80    { 0x02,   "potvrzovaci fronta prazdna"               },\r
81    { 0x03,   "fce nenapsana"               },\r
82    };\r
83 \r
84 \r
85 \r
86    /**\r
87     * vypis chyby na terminal pres RS232\r
88  */\r
89    void bth_error_detect_event(uint8_t status_num)\r
90 {\r
91   uint8_t *message;\r
92   int i=0;\r
93   if(status_num<sizeof(event_command));\r
94   {\r
95     message=event_command[status_num].error_doc;\r
96     while(*(message+i)!=0)\r
97     {\r
98       #ifdef BTH_LX\r
99       sci_rs232_sendch(*(message+i),sci_rs232_chan_default); //do PC\r
100       #endif\r
101       i++;\r
102     };\r
103   };\r
104   return;\r
105 };\r