Bluetooth hc05 library

Dependents:   Nucleo_bt

Committer:
rainerraul
Date:
Sun Aug 26 10:56:11 2018 +0000
Revision:
15:7db8c9913007
Parent:
14:1b81b957214a
Child:
16:8c5c8d0a1cfb
test some routines master and slave mode

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rainerraul 0:15a264bf1590 1 #include "mbed.h"
rainerraul 0:15a264bf1590 2 #include "at.h"
rainerraul 0:15a264bf1590 3 #include "hc05.h"
rainerraul 0:15a264bf1590 4
rainerraul 0:15a264bf1590 5
rainerraul 0:15a264bf1590 6 void bt_modul_hc05::initUART(UART num, unsigned long baudrate, _IRQ interrupt)
rainerraul 0:15a264bf1590 7 {
rainerraul 11:770663228ced 8 t_uart = num;
rainerraul 12:4a779fa69f6b 9
rainerraul 11:770663228ced 10 switch(t_uart) {
rainerraul 0:15a264bf1590 11 case UART1 :
rainerraul 0:15a264bf1590 12 at0.device_init(baudrate, interrupt);
rainerraul 0:15a264bf1590 13 t_interrupt = interrupt;
rainerraul 0:15a264bf1590 14 break;
rainerraul 0:15a264bf1590 15 case UART6 :
rainerraul 0:15a264bf1590 16 at1.device_init1(baudrate, interrupt);
rainerraul 0:15a264bf1590 17 t_interrupt1 = interrupt;
rainerraul 0:15a264bf1590 18 break;
rainerraul 0:15a264bf1590 19 }
rainerraul 0:15a264bf1590 20
rainerraul 0:15a264bf1590 21 }
rainerraul 0:15a264bf1590 22
rainerraul 11:770663228ced 23 char *bt_modul_hc05::get_version()
rainerraul 0:15a264bf1590 24 {
rainerraul 11:770663228ced 25 switch(t_uart) {
rainerraul 0:15a264bf1590 26 case UART1 :
rainerraul 0:15a264bf1590 27 at0.at_send("AT+VERSION?\r\n", "");
rainerraul 0:15a264bf1590 28 if(t_interrupt == OFF) {
rainerraul 10:2e1538dc2e1a 29 return at0.getAnswer(800);
rainerraul 0:15a264bf1590 30 } else {
rainerraul 0:15a264bf1590 31 return at0.buffer;
rainerraul 0:15a264bf1590 32 }
rainerraul 0:15a264bf1590 33
rainerraul 0:15a264bf1590 34 case UART6 :
rainerraul 0:15a264bf1590 35 at1.at_send1("AT+VERSION?\r\n", "");
rainerraul 0:15a264bf1590 36 if(t_interrupt1 == OFF) {
rainerraul 10:2e1538dc2e1a 37 return at1.getAnswer(800);
rainerraul 0:15a264bf1590 38 } else {
rainerraul 0:15a264bf1590 39 return at1.buffer;
rainerraul 0:15a264bf1590 40 }
rainerraul 0:15a264bf1590 41
rainerraul 0:15a264bf1590 42 }
rainerraul 0:15a264bf1590 43 return 0;
rainerraul 0:15a264bf1590 44 }
rainerraul 0:15a264bf1590 45
rainerraul 11:770663228ced 46 char *bt_modul_hc05::set_reset()
rainerraul 0:15a264bf1590 47 {
rainerraul 11:770663228ced 48 switch(t_uart) {
rainerraul 0:15a264bf1590 49 case UART1 :
rainerraul 0:15a264bf1590 50 at0.at_send("AT+RESET\r\n", "");
rainerraul 0:15a264bf1590 51 if(t_interrupt == OFF) {
rainerraul 10:2e1538dc2e1a 52 return at0.getAnswer(800);
rainerraul 0:15a264bf1590 53 } else {
rainerraul 0:15a264bf1590 54 return at0.buffer;
rainerraul 0:15a264bf1590 55 }
rainerraul 0:15a264bf1590 56
rainerraul 0:15a264bf1590 57 case UART6 :
rainerraul 0:15a264bf1590 58 at1.at_send1("AT+RESET\r\n", "");
rainerraul 0:15a264bf1590 59 if(t_interrupt1 == OFF) {
rainerraul 10:2e1538dc2e1a 60 return at1.getAnswer(800);
rainerraul 0:15a264bf1590 61 } else {
rainerraul 0:15a264bf1590 62 return at1.buffer;
rainerraul 0:15a264bf1590 63 }
rainerraul 0:15a264bf1590 64
rainerraul 0:15a264bf1590 65 }
rainerraul 0:15a264bf1590 66 return 0;
rainerraul 0:15a264bf1590 67 }
rainerraul 0:15a264bf1590 68
rainerraul 11:770663228ced 69 char *bt_modul_hc05::set_default_settings()
rainerraul 0:15a264bf1590 70 {
rainerraul 11:770663228ced 71 switch(t_uart) {
rainerraul 0:15a264bf1590 72 case UART1 :
rainerraul 0:15a264bf1590 73 at0.at_send("AT+ORGL\r\n", "");
rainerraul 0:15a264bf1590 74 if(t_interrupt == OFF) {
rainerraul 10:2e1538dc2e1a 75 return at0.getAnswer(800);
rainerraul 0:15a264bf1590 76 } else {
rainerraul 0:15a264bf1590 77 return at0.buffer;
rainerraul 0:15a264bf1590 78 }
rainerraul 0:15a264bf1590 79
rainerraul 0:15a264bf1590 80 case UART6 :
rainerraul 0:15a264bf1590 81 at1.at_send1("AT+ORGL\r\n", "");
rainerraul 0:15a264bf1590 82 if(t_interrupt1 == OFF) {
rainerraul 10:2e1538dc2e1a 83 return at1.getAnswer(800);
rainerraul 0:15a264bf1590 84 } else {
rainerraul 0:15a264bf1590 85 return at1.buffer;
rainerraul 0:15a264bf1590 86 }
rainerraul 0:15a264bf1590 87
rainerraul 0:15a264bf1590 88 }
rainerraul 0:15a264bf1590 89 return 0;
rainerraul 0:15a264bf1590 90
rainerraul 0:15a264bf1590 91 }
rainerraul 0:15a264bf1590 92
rainerraul 11:770663228ced 93 char *bt_modul_hc05::get_modul_address()
rainerraul 0:15a264bf1590 94 {
rainerraul 11:770663228ced 95 switch(t_uart) {
rainerraul 0:15a264bf1590 96 case UART1 :
rainerraul 0:15a264bf1590 97 at0.at_send("AT+ADDR?\r\n", "");
rainerraul 0:15a264bf1590 98 if(t_interrupt == OFF) {
rainerraul 10:2e1538dc2e1a 99 return at0.getAnswer(600);
rainerraul 0:15a264bf1590 100 } else {
rainerraul 0:15a264bf1590 101 return at0.buffer;
rainerraul 0:15a264bf1590 102 }
rainerraul 0:15a264bf1590 103
rainerraul 0:15a264bf1590 104 case UART6 :
rainerraul 0:15a264bf1590 105 at1.at_send1("AT+ADDR?\r\n", "");
rainerraul 0:15a264bf1590 106 if(t_interrupt1 == OFF) {
rainerraul 10:2e1538dc2e1a 107 return at1.getAnswer(600);
rainerraul 0:15a264bf1590 108 } else {
rainerraul 0:15a264bf1590 109 return at1.buffer;
rainerraul 0:15a264bf1590 110 }
rainerraul 0:15a264bf1590 111
rainerraul 0:15a264bf1590 112 }
rainerraul 0:15a264bf1590 113 return 0;
rainerraul 0:15a264bf1590 114
rainerraul 0:15a264bf1590 115 }
rainerraul 0:15a264bf1590 116
rainerraul 11:770663228ced 117 char *bt_modul_hc05::get_modul_name()
rainerraul 0:15a264bf1590 118 {
rainerraul 11:770663228ced 119 switch(t_uart) {
rainerraul 0:15a264bf1590 120 case UART1 :
rainerraul 0:15a264bf1590 121 at0.at_send("AT+NAME?\r\n", "");
rainerraul 0:15a264bf1590 122 if(t_interrupt == OFF) {
rainerraul 10:2e1538dc2e1a 123 return at0.getAnswer(800);
rainerraul 0:15a264bf1590 124 } else {
rainerraul 0:15a264bf1590 125 return at0.buffer;
rainerraul 0:15a264bf1590 126 }
rainerraul 0:15a264bf1590 127
rainerraul 0:15a264bf1590 128 case UART6 :
rainerraul 0:15a264bf1590 129 at1.at_send1("AT+NAME?\r\n", "");
rainerraul 0:15a264bf1590 130 if(t_interrupt1 == OFF) {
rainerraul 10:2e1538dc2e1a 131 return at1.getAnswer(800);
rainerraul 0:15a264bf1590 132 } else {
rainerraul 0:15a264bf1590 133 return at1.buffer;
rainerraul 0:15a264bf1590 134 }
rainerraul 0:15a264bf1590 135
rainerraul 0:15a264bf1590 136 }
rainerraul 0:15a264bf1590 137 return 0;
rainerraul 0:15a264bf1590 138
rainerraul 0:15a264bf1590 139 }
rainerraul 0:15a264bf1590 140
rainerraul 11:770663228ced 141 char *bt_modul_hc05::get_device_name()
rainerraul 0:15a264bf1590 142 {
rainerraul 11:770663228ced 143 switch(t_uart) {
rainerraul 0:15a264bf1590 144 case UART1 :
rainerraul 0:15a264bf1590 145 at0.at_send("AT+RNAME?\r\n", "");
rainerraul 0:15a264bf1590 146 if(t_interrupt == OFF) {
rainerraul 10:2e1538dc2e1a 147 return at0.getAnswer(800);
rainerraul 0:15a264bf1590 148 } else {
rainerraul 0:15a264bf1590 149 return at0.buffer;
rainerraul 0:15a264bf1590 150 }
rainerraul 0:15a264bf1590 151
rainerraul 0:15a264bf1590 152 case UART6 :
rainerraul 0:15a264bf1590 153 at1.at_send1("AT+RNAME?\r\n", "");
rainerraul 0:15a264bf1590 154 if(t_interrupt1 == OFF) {
rainerraul 10:2e1538dc2e1a 155 return at1.getAnswer(800);
rainerraul 0:15a264bf1590 156 } else {
rainerraul 0:15a264bf1590 157 return at1.buffer;
rainerraul 0:15a264bf1590 158 }
rainerraul 0:15a264bf1590 159
rainerraul 0:15a264bf1590 160 }
rainerraul 0:15a264bf1590 161 return 0;
rainerraul 0:15a264bf1590 162
rainerraul 0:15a264bf1590 163 }
rainerraul 0:15a264bf1590 164
rainerraul 11:770663228ced 165 char *bt_modul_hc05::get_modul_role()
rainerraul 0:15a264bf1590 166 {
rainerraul 11:770663228ced 167 switch(t_uart) {
rainerraul 0:15a264bf1590 168 case UART1 :
rainerraul 0:15a264bf1590 169 at0.at_send("AT+ROLE?\r\n", "");
rainerraul 0:15a264bf1590 170 if(t_interrupt == OFF) {
rainerraul 10:2e1538dc2e1a 171 return at0.getAnswer(600);
rainerraul 0:15a264bf1590 172 } else {
rainerraul 0:15a264bf1590 173 return at0.buffer;
rainerraul 0:15a264bf1590 174 }
rainerraul 0:15a264bf1590 175
rainerraul 0:15a264bf1590 176 case UART6 :
rainerraul 0:15a264bf1590 177 at1.at_send1("AT+ROLE?\r\n", "");
rainerraul 0:15a264bf1590 178 if(t_interrupt1 == OFF) {
rainerraul 10:2e1538dc2e1a 179 return at1.getAnswer(600);
rainerraul 0:15a264bf1590 180 } else {
rainerraul 0:15a264bf1590 181 return at1.buffer;
rainerraul 0:15a264bf1590 182 }
rainerraul 0:15a264bf1590 183
rainerraul 0:15a264bf1590 184 }
rainerraul 0:15a264bf1590 185 return 0;
rainerraul 0:15a264bf1590 186
rainerraul 0:15a264bf1590 187 }
rainerraul 0:15a264bf1590 188
rainerraul 11:770663228ced 189 char *bt_modul_hc05::get_device_class()
rainerraul 0:15a264bf1590 190 {
rainerraul 11:770663228ced 191 switch(t_uart) {
rainerraul 0:15a264bf1590 192 case UART1 :
rainerraul 0:15a264bf1590 193 at0.at_send("AT+CLASS?\r\n", "");
rainerraul 0:15a264bf1590 194 if(t_interrupt == OFF) {
rainerraul 10:2e1538dc2e1a 195 return at0.getAnswer(600);
rainerraul 0:15a264bf1590 196 } else {
rainerraul 0:15a264bf1590 197 return at0.buffer;
rainerraul 0:15a264bf1590 198 }
rainerraul 0:15a264bf1590 199
rainerraul 0:15a264bf1590 200 case UART6 :
rainerraul 0:15a264bf1590 201 at1.at_send1("AT+CLASS?\r\n", "");
rainerraul 0:15a264bf1590 202 if(t_interrupt1 == OFF) {
rainerraul 10:2e1538dc2e1a 203 return at1.getAnswer(600);
rainerraul 0:15a264bf1590 204 } else {
rainerraul 0:15a264bf1590 205 return at1.buffer;
rainerraul 0:15a264bf1590 206 }
rainerraul 0:15a264bf1590 207
rainerraul 0:15a264bf1590 208 }
rainerraul 0:15a264bf1590 209 return 0;
rainerraul 0:15a264bf1590 210
rainerraul 0:15a264bf1590 211 }
rainerraul 0:15a264bf1590 212
rainerraul 11:770663228ced 213 char *bt_modul_hc05::get_modul_giac()
rainerraul 0:15a264bf1590 214 {
rainerraul 11:770663228ced 215 switch(t_uart) {
rainerraul 0:15a264bf1590 216 case UART1 :
rainerraul 0:15a264bf1590 217 at0.at_send("AT+IAC?\r\n", "");
rainerraul 0:15a264bf1590 218 if(t_interrupt == OFF) {
rainerraul 10:2e1538dc2e1a 219 return at0.getAnswer(600);
rainerraul 0:15a264bf1590 220 } else {
rainerraul 0:15a264bf1590 221 return at0.buffer;
rainerraul 0:15a264bf1590 222 }
rainerraul 0:15a264bf1590 223
rainerraul 0:15a264bf1590 224 case UART6 :
rainerraul 0:15a264bf1590 225 at1.at_send1("AT+IAC?\r\n", "");
rainerraul 0:15a264bf1590 226 if(t_interrupt1 == OFF) {
rainerraul 10:2e1538dc2e1a 227 return at1.getAnswer(600);
rainerraul 0:15a264bf1590 228 } else {
rainerraul 0:15a264bf1590 229 return at1.buffer;
rainerraul 0:15a264bf1590 230 }
rainerraul 0:15a264bf1590 231
rainerraul 0:15a264bf1590 232 }
rainerraul 0:15a264bf1590 233 return 0;
rainerraul 0:15a264bf1590 234
rainerraul 0:15a264bf1590 235 }
rainerraul 0:15a264bf1590 236
rainerraul 11:770663228ced 237 char *bt_modul_hc05::get_modul_inquiry()
rainerraul 0:15a264bf1590 238 {
rainerraul 11:770663228ced 239 switch(t_uart) {
rainerraul 0:15a264bf1590 240 case UART1 :
rainerraul 0:15a264bf1590 241 at0.at_send("AT+INQM?\r\n", "");
rainerraul 0:15a264bf1590 242 if(t_interrupt == OFF) {
rainerraul 10:2e1538dc2e1a 243 return at0.getAnswer(800);
rainerraul 0:15a264bf1590 244 } else {
rainerraul 0:15a264bf1590 245 return at0.buffer;
rainerraul 0:15a264bf1590 246 }
rainerraul 0:15a264bf1590 247
rainerraul 0:15a264bf1590 248 case UART6 :
rainerraul 0:15a264bf1590 249 at1.at_send1("AT+INQM?\r\n", "");
rainerraul 0:15a264bf1590 250 if(t_interrupt1 == OFF) {
rainerraul 10:2e1538dc2e1a 251 return at1.getAnswer(800);
rainerraul 0:15a264bf1590 252 } else {
rainerraul 0:15a264bf1590 253 return at1.buffer;
rainerraul 0:15a264bf1590 254 }
rainerraul 0:15a264bf1590 255
rainerraul 0:15a264bf1590 256 }
rainerraul 0:15a264bf1590 257 return 0;
rainerraul 0:15a264bf1590 258
rainerraul 0:15a264bf1590 259 }
rainerraul 0:15a264bf1590 260
rainerraul 11:770663228ced 261 char *bt_modul_hc05::get_modul_pincode()
rainerraul 0:15a264bf1590 262 {
rainerraul 11:770663228ced 263 switch(t_uart) {
rainerraul 0:15a264bf1590 264 case UART1 :
rainerraul 0:15a264bf1590 265 at0.at_send("AT+PSWD?\r\n", "");
rainerraul 0:15a264bf1590 266 if(t_interrupt == OFF) {
rainerraul 10:2e1538dc2e1a 267 return at0.getAnswer(600);
rainerraul 0:15a264bf1590 268 } else {
rainerraul 0:15a264bf1590 269 return at0.buffer;
rainerraul 0:15a264bf1590 270 }
rainerraul 0:15a264bf1590 271
rainerraul 0:15a264bf1590 272 case UART6 :
rainerraul 0:15a264bf1590 273 at1.at_send1("AT+PSWD?\r\n", "");
rainerraul 0:15a264bf1590 274 if(t_interrupt1 == OFF) {
rainerraul 10:2e1538dc2e1a 275 return at1.getAnswer(600);
rainerraul 0:15a264bf1590 276 } else {
rainerraul 0:15a264bf1590 277 return at1.buffer;
rainerraul 0:15a264bf1590 278 }
rainerraul 0:15a264bf1590 279
rainerraul 0:15a264bf1590 280 }
rainerraul 0:15a264bf1590 281 return 0;
rainerraul 0:15a264bf1590 282
rainerraul 0:15a264bf1590 283 }
rainerraul 0:15a264bf1590 284
rainerraul 11:770663228ced 285 char *bt_modul_hc05::get_modul_uart()
rainerraul 0:15a264bf1590 286 {
rainerraul 11:770663228ced 287 switch(t_uart) {
rainerraul 0:15a264bf1590 288 case UART1 :
rainerraul 0:15a264bf1590 289 at0.at_send("AT+UART?\r\n", "");
rainerraul 0:15a264bf1590 290 if(t_interrupt == OFF) {
rainerraul 10:2e1538dc2e1a 291 return at0.getAnswer(600);
rainerraul 0:15a264bf1590 292 } else {
rainerraul 0:15a264bf1590 293 return at0.buffer;
rainerraul 0:15a264bf1590 294 }
rainerraul 0:15a264bf1590 295
rainerraul 0:15a264bf1590 296 case UART6 :
rainerraul 0:15a264bf1590 297 at1.at_send1("AT+UART?\r\n", "");
rainerraul 0:15a264bf1590 298 if(t_interrupt1 == OFF) {
rainerraul 10:2e1538dc2e1a 299 return at1.getAnswer(600);
rainerraul 0:15a264bf1590 300 } else {
rainerraul 0:15a264bf1590 301 return at1.buffer;
rainerraul 0:15a264bf1590 302 }
rainerraul 0:15a264bf1590 303
rainerraul 0:15a264bf1590 304 }
rainerraul 0:15a264bf1590 305 return 0;
rainerraul 0:15a264bf1590 306
rainerraul 0:15a264bf1590 307 }
rainerraul 0:15a264bf1590 308
rainerraul 11:770663228ced 309 char *bt_modul_hc05::get_modul_inqm()
rainerraul 0:15a264bf1590 310 {
rainerraul 11:770663228ced 311 switch(t_uart) {
rainerraul 0:15a264bf1590 312 case UART1 :
rainerraul 10:2e1538dc2e1a 313 at0.at_send("AT+INQ\r\n", "");
rainerraul 0:15a264bf1590 314
rainerraul 0:15a264bf1590 315 if(t_interrupt == OFF) {
rainerraul 13:85c3dac25599 316 return at0.getAnswer(600);
rainerraul 0:15a264bf1590 317 } else {
rainerraul 0:15a264bf1590 318 return at0.buffer;
rainerraul 0:15a264bf1590 319 }
rainerraul 0:15a264bf1590 320
rainerraul 0:15a264bf1590 321 case UART6 :
rainerraul 10:2e1538dc2e1a 322 at1.at_send1("AT+INQ\r\n", "");
rainerraul 0:15a264bf1590 323
rainerraul 0:15a264bf1590 324 if(t_interrupt1 == OFF) {
rainerraul 13:85c3dac25599 325 return at1.getAnswer(600);
rainerraul 0:15a264bf1590 326 } else {
rainerraul 0:15a264bf1590 327 return at1.buffer;
rainerraul 0:15a264bf1590 328 }
rainerraul 0:15a264bf1590 329
rainerraul 0:15a264bf1590 330 }
rainerraul 0:15a264bf1590 331 return 0;
rainerraul 0:15a264bf1590 332
rainerraul 0:15a264bf1590 333 }
rainerraul 0:15a264bf1590 334
rainerraul 11:770663228ced 335 char *bt_modul_hc05::get_modul_init()
rainerraul 0:15a264bf1590 336 {
rainerraul 11:770663228ced 337 switch(t_uart) {
rainerraul 0:15a264bf1590 338 case UART1 :
rainerraul 0:15a264bf1590 339 at0.at_send("AT+INIT\r\n", "");
rainerraul 0:15a264bf1590 340
rainerraul 0:15a264bf1590 341 if(t_interrupt == OFF) {
rainerraul 10:2e1538dc2e1a 342 return at0.getAnswer(800);
rainerraul 0:15a264bf1590 343 } else {
rainerraul 0:15a264bf1590 344 return at0.buffer;
rainerraul 0:15a264bf1590 345 }
rainerraul 0:15a264bf1590 346
rainerraul 0:15a264bf1590 347
rainerraul 0:15a264bf1590 348 case UART6 :
rainerraul 0:15a264bf1590 349 at1.at_send("AT+INIT\r\n", "");
rainerraul 0:15a264bf1590 350
rainerraul 0:15a264bf1590 351 if(t_interrupt1 == OFF) {
rainerraul 10:2e1538dc2e1a 352 return at1.getAnswer(800);
rainerraul 0:15a264bf1590 353 } else {
rainerraul 0:15a264bf1590 354 return at1.buffer;
rainerraul 0:15a264bf1590 355 }
rainerraul 0:15a264bf1590 356
rainerraul 0:15a264bf1590 357
rainerraul 0:15a264bf1590 358 }
rainerraul 0:15a264bf1590 359 return 0;
rainerraul 0:15a264bf1590 360
rainerraul 0:15a264bf1590 361 }
rainerraul 0:15a264bf1590 362
rainerraul 11:770663228ced 363 char *bt_modul_hc05::get_modul_state()
rainerraul 0:15a264bf1590 364 {
rainerraul 11:770663228ced 365 switch(t_uart) {
rainerraul 0:15a264bf1590 366 case UART1 :
rainerraul 0:15a264bf1590 367 at0.at_send("AT+STATE?\r\n", "");
rainerraul 0:15a264bf1590 368 if(t_interrupt == OFF) {
rainerraul 10:2e1538dc2e1a 369 return at0.getAnswer(800);
rainerraul 0:15a264bf1590 370 } else {
rainerraul 0:15a264bf1590 371 return at0.buffer;
rainerraul 0:15a264bf1590 372 }
rainerraul 0:15a264bf1590 373
rainerraul 0:15a264bf1590 374 case UART6 :
rainerraul 0:15a264bf1590 375 at1.at_send1("AT+STATE?\r\n", "");
rainerraul 0:15a264bf1590 376 if(t_interrupt1 == OFF) {
rainerraul 10:2e1538dc2e1a 377 return at1.getAnswer(800);
rainerraul 0:15a264bf1590 378 } else {
rainerraul 0:15a264bf1590 379 return at1.buffer;
rainerraul 0:15a264bf1590 380 }
rainerraul 0:15a264bf1590 381
rainerraul 0:15a264bf1590 382 }
rainerraul 0:15a264bf1590 383 return 0;
rainerraul 0:15a264bf1590 384
rainerraul 0:15a264bf1590 385 }
rainerraul 0:15a264bf1590 386
rainerraul 11:770663228ced 387 char *bt_modul_hc05::get_addr_mode()
rainerraul 0:15a264bf1590 388 {
rainerraul 11:770663228ced 389 switch(t_uart) {
rainerraul 0:15a264bf1590 390 case UART1 :
rainerraul 0:15a264bf1590 391 at0.at_send("AT+CMODE?\r\n", "");
rainerraul 0:15a264bf1590 392 if(t_interrupt == OFF) {
rainerraul 10:2e1538dc2e1a 393 return at0.getAnswer(600);
rainerraul 0:15a264bf1590 394 } else {
rainerraul 0:15a264bf1590 395 return at0.buffer;
rainerraul 0:15a264bf1590 396 }
rainerraul 0:15a264bf1590 397
rainerraul 0:15a264bf1590 398 case UART6 :
rainerraul 0:15a264bf1590 399 at1.at_send1("AT+CMODE?\r\n", "");
rainerraul 0:15a264bf1590 400 if(t_interrupt1 == OFF) {
rainerraul 10:2e1538dc2e1a 401 return at1.getAnswer(600);
rainerraul 0:15a264bf1590 402 } else {
rainerraul 0:15a264bf1590 403 return at1.buffer;
rainerraul 0:15a264bf1590 404 }
rainerraul 0:15a264bf1590 405
rainerraul 0:15a264bf1590 406 }
rainerraul 0:15a264bf1590 407 return 0;
rainerraul 0:15a264bf1590 408
rainerraul 0:15a264bf1590 409 }
rainerraul 0:15a264bf1590 410
rainerraul 11:770663228ced 411 char *bt_modul_hc05::get_fixed_addr()
rainerraul 0:15a264bf1590 412 {
rainerraul 11:770663228ced 413 switch(t_uart) {
rainerraul 0:15a264bf1590 414 case UART1 :
rainerraul 0:15a264bf1590 415 at0.at_send("AT+BIND?\r\n", "");
rainerraul 0:15a264bf1590 416 if(t_interrupt == OFF) {
rainerraul 10:2e1538dc2e1a 417 return at0.getAnswer(600);
rainerraul 0:15a264bf1590 418 } else {
rainerraul 0:15a264bf1590 419 return at0.buffer;
rainerraul 0:15a264bf1590 420 }
rainerraul 0:15a264bf1590 421
rainerraul 0:15a264bf1590 422 case UART6 :
rainerraul 0:15a264bf1590 423 at1.at_send1("AT+BIND?\r\n", "");
rainerraul 0:15a264bf1590 424 if(t_interrupt1 == OFF) {
rainerraul 10:2e1538dc2e1a 425 return at1.getAnswer(600);
rainerraul 0:15a264bf1590 426 } else {
rainerraul 0:15a264bf1590 427 return at1.buffer;
rainerraul 0:15a264bf1590 428 }
rainerraul 0:15a264bf1590 429
rainerraul 0:15a264bf1590 430 }
rainerraul 0:15a264bf1590 431 return 0;
rainerraul 0:15a264bf1590 432
rainerraul 0:15a264bf1590 433 }
rainerraul 0:15a264bf1590 434
rainerraul 11:770663228ced 435 char *bt_modul_hc05::set_modul_role(ROLE role)
rainerraul 1:8d4296aafa55 436 {
rainerraul 0:15a264bf1590 437
rainerraul 11:770663228ced 438 switch(t_uart) {
rainerraul 1:8d4296aafa55 439 case UART1 :
rainerraul 2:38f1fb034a75 440 at0.at_send("AT+ROLE=%i\r\n", (char*)role);
rainerraul 1:8d4296aafa55 441 if(t_interrupt == OFF) {
rainerraul 10:2e1538dc2e1a 442 return at0.getAnswer(600);
rainerraul 1:8d4296aafa55 443 } else {
rainerraul 1:8d4296aafa55 444 return at0.buffer;
rainerraul 1:8d4296aafa55 445 }
rainerraul 0:15a264bf1590 446
rainerraul 1:8d4296aafa55 447 case UART6 :
rainerraul 2:38f1fb034a75 448 at1.at_send1("AT+ROLE=%i\r\n", (char*)role);
rainerraul 1:8d4296aafa55 449 if(t_interrupt1 == OFF) {
rainerraul 10:2e1538dc2e1a 450 return at1.getAnswer(600);
rainerraul 10:2e1538dc2e1a 451 } else {
rainerraul 10:2e1538dc2e1a 452 return at1.buffer;
rainerraul 10:2e1538dc2e1a 453 }
rainerraul 10:2e1538dc2e1a 454
rainerraul 10:2e1538dc2e1a 455 }
rainerraul 10:2e1538dc2e1a 456 return 0;
rainerraul 10:2e1538dc2e1a 457
rainerraul 10:2e1538dc2e1a 458 }
rainerraul 10:2e1538dc2e1a 459
rainerraul 11:770663228ced 460 char *bt_modul_hc05::set_device_class(int dclass)
rainerraul 10:2e1538dc2e1a 461 {
rainerraul 11:770663228ced 462 switch(t_uart) {
rainerraul 10:2e1538dc2e1a 463 case UART1 :
rainerraul 10:2e1538dc2e1a 464 at0.at_send("AT+CLASS=%i\r\n", (char*) dclass);
rainerraul 10:2e1538dc2e1a 465 if(t_interrupt == OFF) {
rainerraul 10:2e1538dc2e1a 466 return at0.getAnswer(600);
rainerraul 10:2e1538dc2e1a 467 } else {
rainerraul 10:2e1538dc2e1a 468 return at0.buffer;
rainerraul 10:2e1538dc2e1a 469 }
rainerraul 10:2e1538dc2e1a 470
rainerraul 10:2e1538dc2e1a 471 case UART6 :
rainerraul 10:2e1538dc2e1a 472 at1.at_send1("AT+CLASS=%i\r\n", (char*) dclass);
rainerraul 10:2e1538dc2e1a 473 if(t_interrupt1 == OFF) {
rainerraul 10:2e1538dc2e1a 474 return at1.getAnswer(600);
rainerraul 10:2e1538dc2e1a 475 } else {
rainerraul 10:2e1538dc2e1a 476 return at1.buffer;
rainerraul 10:2e1538dc2e1a 477 }
rainerraul 10:2e1538dc2e1a 478
rainerraul 10:2e1538dc2e1a 479 }
rainerraul 10:2e1538dc2e1a 480 return 0;
rainerraul 10:2e1538dc2e1a 481
rainerraul 10:2e1538dc2e1a 482 }
rainerraul 10:2e1538dc2e1a 483
rainerraul 11:770663228ced 484 char *bt_modul_hc05::set_modul_giac(char *giac)
rainerraul 10:2e1538dc2e1a 485 {
rainerraul 11:770663228ced 486 switch(t_uart) {
rainerraul 10:2e1538dc2e1a 487 case UART1 :
rainerraul 10:2e1538dc2e1a 488 at0.at_send("AT+IAC=%s\r\n", giac);
rainerraul 10:2e1538dc2e1a 489 if(t_interrupt == OFF) {
rainerraul 10:2e1538dc2e1a 490 return at0.getAnswer(600);
rainerraul 10:2e1538dc2e1a 491 } else {
rainerraul 10:2e1538dc2e1a 492 return at0.buffer;
rainerraul 10:2e1538dc2e1a 493 }
rainerraul 10:2e1538dc2e1a 494
rainerraul 10:2e1538dc2e1a 495 case UART6 :
rainerraul 10:2e1538dc2e1a 496 at1.at_send1("AT+IAC=%s\r\n", giac);
rainerraul 10:2e1538dc2e1a 497 if(t_interrupt1 == OFF) {
rainerraul 10:2e1538dc2e1a 498 return at1.getAnswer(600);
rainerraul 1:8d4296aafa55 499 } else {
rainerraul 1:8d4296aafa55 500 return at1.buffer;
rainerraul 1:8d4296aafa55 501 }
rainerraul 1:8d4296aafa55 502
rainerraul 1:8d4296aafa55 503 }
rainerraul 1:8d4296aafa55 504 return 0;
rainerraul 1:8d4296aafa55 505
rainerraul 1:8d4296aafa55 506 }
rainerraul 1:8d4296aafa55 507
rainerraul 11:770663228ced 508 char *bt_modul_hc05::set_modul_pincode(char *pin)
rainerraul 1:8d4296aafa55 509 {
rainerraul 11:770663228ced 510 switch(t_uart) {
rainerraul 1:8d4296aafa55 511 case UART1 :
rainerraul 2:38f1fb034a75 512 at0.at_send("AT+PSWD=%s\r\n", pin);
rainerraul 1:8d4296aafa55 513 if(t_interrupt == OFF) {
rainerraul 10:2e1538dc2e1a 514 return at0.getAnswer(600);
rainerraul 1:8d4296aafa55 515 } else {
rainerraul 1:8d4296aafa55 516 return at0.buffer;
rainerraul 1:8d4296aafa55 517 }
rainerraul 1:8d4296aafa55 518
rainerraul 1:8d4296aafa55 519 case UART6 :
rainerraul 2:38f1fb034a75 520 at1.at_send1("AT+PSWD=%s\r\n", pin);
rainerraul 1:8d4296aafa55 521 if(t_interrupt1 == OFF) {
rainerraul 10:2e1538dc2e1a 522 return at1.getAnswer(600);
rainerraul 10:2e1538dc2e1a 523 } else {
rainerraul 10:2e1538dc2e1a 524 return at1.buffer;
rainerraul 10:2e1538dc2e1a 525 }
rainerraul 10:2e1538dc2e1a 526
rainerraul 10:2e1538dc2e1a 527 }
rainerraul 10:2e1538dc2e1a 528 return 0;
rainerraul 10:2e1538dc2e1a 529
rainerraul 10:2e1538dc2e1a 530 }
rainerraul 10:2e1538dc2e1a 531
rainerraul 11:770663228ced 532 char *bt_modul_hc05::set_modul_inquiry(char *inqparams)
rainerraul 10:2e1538dc2e1a 533 {
rainerraul 11:770663228ced 534 switch(t_uart) {
rainerraul 10:2e1538dc2e1a 535 case UART1 :
rainerraul 10:2e1538dc2e1a 536 at0.at_send("AT+INQM=%s\r\n", inqparams);
rainerraul 10:2e1538dc2e1a 537 if(t_interrupt == OFF) {
rainerraul 10:2e1538dc2e1a 538 return at0.getAnswer(800);
rainerraul 10:2e1538dc2e1a 539 } else {
rainerraul 10:2e1538dc2e1a 540 return at0.buffer;
rainerraul 10:2e1538dc2e1a 541 }
rainerraul 10:2e1538dc2e1a 542
rainerraul 10:2e1538dc2e1a 543 case UART6 :
rainerraul 10:2e1538dc2e1a 544 at1.at_send1("AT+INQM=%s\r\n", inqparams);
rainerraul 10:2e1538dc2e1a 545 if(t_interrupt1 == OFF) {
rainerraul 10:2e1538dc2e1a 546 return at1.getAnswer(800);
rainerraul 1:8d4296aafa55 547 } else {
rainerraul 1:8d4296aafa55 548 return at1.buffer;
rainerraul 1:8d4296aafa55 549 }
rainerraul 1:8d4296aafa55 550
rainerraul 1:8d4296aafa55 551 }
rainerraul 1:8d4296aafa55 552 return 0;
rainerraul 1:8d4296aafa55 553
rainerraul 1:8d4296aafa55 554 }
rainerraul 2:38f1fb034a75 555
rainerraul 11:770663228ced 556 char *bt_modul_hc05::set_modul_name(char *name)
rainerraul 7:8b004c3d7e89 557 {
rainerraul 11:770663228ced 558 switch(t_uart) {
rainerraul 7:8b004c3d7e89 559 case UART1 :
rainerraul 7:8b004c3d7e89 560 at0.at_send("AT+NAME=%s\r\n", name);
rainerraul 7:8b004c3d7e89 561 if(t_interrupt == OFF) {
rainerraul 10:2e1538dc2e1a 562 return at0.getAnswer(800);
rainerraul 7:8b004c3d7e89 563 } else {
rainerraul 7:8b004c3d7e89 564 return at0.buffer;
rainerraul 7:8b004c3d7e89 565 }
rainerraul 7:8b004c3d7e89 566
rainerraul 7:8b004c3d7e89 567 case UART6 :
rainerraul 7:8b004c3d7e89 568 at1.at_send1("AT+NAME=%s\r\n", name);
rainerraul 7:8b004c3d7e89 569 if(t_interrupt1 == OFF) {
rainerraul 10:2e1538dc2e1a 570 return at1.getAnswer(800);
rainerraul 7:8b004c3d7e89 571 } else {
rainerraul 7:8b004c3d7e89 572 return at1.buffer;
rainerraul 7:8b004c3d7e89 573 }
rainerraul 7:8b004c3d7e89 574
rainerraul 7:8b004c3d7e89 575 }
rainerraul 7:8b004c3d7e89 576 return 0;
rainerraul 7:8b004c3d7e89 577
rainerraul 7:8b004c3d7e89 578 }
rainerraul 7:8b004c3d7e89 579
rainerraul 11:770663228ced 580 char *bt_modul_hc05::set_modul_uart(char *uartparams)
rainerraul 2:38f1fb034a75 581 {
rainerraul 11:770663228ced 582 switch(t_uart) {
rainerraul 2:38f1fb034a75 583 case UART1 :
rainerraul 3:86c6baa6255d 584 at0.at_send("AT+UART=%s\r\n", uartparams);
rainerraul 2:38f1fb034a75 585 if(t_interrupt == OFF) {
rainerraul 10:2e1538dc2e1a 586 return at0.getAnswer(600);
rainerraul 2:38f1fb034a75 587 } else {
rainerraul 2:38f1fb034a75 588 return at0.buffer;
rainerraul 2:38f1fb034a75 589 }
rainerraul 2:38f1fb034a75 590
rainerraul 2:38f1fb034a75 591 case UART6 :
rainerraul 3:86c6baa6255d 592 at1.at_send1("AT+UART=%s\r\n", uartparams);
rainerraul 3:86c6baa6255d 593 if(t_interrupt1 == OFF) {
rainerraul 10:2e1538dc2e1a 594 return at1.getAnswer(600);
rainerraul 3:86c6baa6255d 595 } else {
rainerraul 3:86c6baa6255d 596 return at1.buffer;
rainerraul 3:86c6baa6255d 597 }
rainerraul 3:86c6baa6255d 598
rainerraul 3:86c6baa6255d 599 }
rainerraul 3:86c6baa6255d 600 return 0;
rainerraul 3:86c6baa6255d 601 }
rainerraul 3:86c6baa6255d 602
rainerraul 3:86c6baa6255d 603
rainerraul 14:1b81b957214a 604 char *bt_modul_hc05::set_addr_fixed(char *address)
rainerraul 3:86c6baa6255d 605 {
rainerraul 11:770663228ced 606 switch(t_uart) {
rainerraul 3:86c6baa6255d 607 case UART1 :
rainerraul 13:85c3dac25599 608 at0.at_send("AT+BIND=%s\r\n", address);
rainerraul 3:86c6baa6255d 609 if(t_interrupt == OFF) {
rainerraul 10:2e1538dc2e1a 610 return at0.getAnswer(600);
rainerraul 3:86c6baa6255d 611 } else {
rainerraul 3:86c6baa6255d 612 return at0.buffer;
rainerraul 3:86c6baa6255d 613 }
rainerraul 3:86c6baa6255d 614
rainerraul 3:86c6baa6255d 615 case UART6 :
rainerraul 13:85c3dac25599 616 at1.at_send1("AT+BIND=%s\r\n", address);
rainerraul 2:38f1fb034a75 617 if(t_interrupt1 == OFF) {
rainerraul 10:2e1538dc2e1a 618 return at1.getAnswer(600);
rainerraul 2:38f1fb034a75 619 } else {
rainerraul 2:38f1fb034a75 620 return at1.buffer;
rainerraul 2:38f1fb034a75 621 }
rainerraul 2:38f1fb034a75 622
rainerraul 2:38f1fb034a75 623 }
rainerraul 2:38f1fb034a75 624 return 0;
rainerraul 2:38f1fb034a75 625
rainerraul 2:38f1fb034a75 626 }
rainerraul 3:86c6baa6255d 627
rainerraul 3:86c6baa6255d 628
rainerraul 11:770663228ced 629 char *bt_modul_hc05::set_addr_mode(CMODE mode)
rainerraul 3:86c6baa6255d 630 {
rainerraul 11:770663228ced 631 switch(t_uart) {
rainerraul 3:86c6baa6255d 632 case UART1 :
rainerraul 3:86c6baa6255d 633 at0.at_send("AT+CMODE=%i\r\n", (char*)mode);
rainerraul 3:86c6baa6255d 634 if(t_interrupt == OFF) {
rainerraul 10:2e1538dc2e1a 635 return at0.getAnswer(600);
rainerraul 3:86c6baa6255d 636 } else {
rainerraul 3:86c6baa6255d 637 return at0.buffer;
rainerraul 3:86c6baa6255d 638 }
rainerraul 3:86c6baa6255d 639
rainerraul 3:86c6baa6255d 640 case UART6 :
rainerraul 3:86c6baa6255d 641 at1.at_send1("AT+CMODE=%i\r\n", (char*)mode);
rainerraul 3:86c6baa6255d 642 if(t_interrupt1 == OFF) {
rainerraul 10:2e1538dc2e1a 643 return at1.getAnswer(600);
rainerraul 3:86c6baa6255d 644 } else {
rainerraul 3:86c6baa6255d 645 return at1.buffer;
rainerraul 3:86c6baa6255d 646 }
rainerraul 3:86c6baa6255d 647
rainerraul 3:86c6baa6255d 648 }
rainerraul 3:86c6baa6255d 649 return 0;
rainerraul 7:8b004c3d7e89 650 }
rainerraul 7:8b004c3d7e89 651
rainerraul 11:770663228ced 652 char *bt_modul_hc05::search_device(char *address)
rainerraul 4:1eee19777111 653 {
rainerraul 11:770663228ced 654 switch(t_uart) {
rainerraul 4:1eee19777111 655 case UART1 :
rainerraul 4:1eee19777111 656 at0.at_send("AT+FSAD=%s\r\n", address);
rainerraul 4:1eee19777111 657 if(t_interrupt == OFF) {
rainerraul 10:2e1538dc2e1a 658 return at0.getAnswer(800);
rainerraul 4:1eee19777111 659 } else {
rainerraul 4:1eee19777111 660 return at0.buffer;
rainerraul 4:1eee19777111 661 }
rainerraul 4:1eee19777111 662
rainerraul 4:1eee19777111 663 case UART6 :
rainerraul 4:1eee19777111 664 at1.at_send1("AT+FSAD=%s\r\n", address);
rainerraul 4:1eee19777111 665 if(t_interrupt1 == OFF) {
rainerraul 10:2e1538dc2e1a 666 return at1.getAnswer(800);
rainerraul 4:1eee19777111 667 } else {
rainerraul 4:1eee19777111 668 return at1.buffer;
rainerraul 4:1eee19777111 669 }
rainerraul 4:1eee19777111 670
rainerraul 4:1eee19777111 671 }
rainerraul 4:1eee19777111 672 return 0;
rainerraul 7:8b004c3d7e89 673 }
rainerraul 7:8b004c3d7e89 674
rainerraul 13:85c3dac25599 675 char *bt_modul_hc05::set_device_paired(char *address, int timeout)
rainerraul 13:85c3dac25599 676 {
rainerraul 13:85c3dac25599 677 switch(t_uart) {
rainerraul 13:85c3dac25599 678 case UART1 :
rainerraul 13:85c3dac25599 679 sprintf("%c,%d", address, timeout);
rainerraul 13:85c3dac25599 680 at0.at_send("AT+PAIR=%s\r\n", address);
rainerraul 13:85c3dac25599 681 if(t_interrupt == OFF) {
rainerraul 13:85c3dac25599 682 return at0.getAnswer(800);
rainerraul 13:85c3dac25599 683 } else {
rainerraul 13:85c3dac25599 684 return at0.buffer;
rainerraul 13:85c3dac25599 685 }
rainerraul 13:85c3dac25599 686
rainerraul 13:85c3dac25599 687 case UART6 :
rainerraul 13:85c3dac25599 688 sprintf("%c,%d", address, timeout);
rainerraul 13:85c3dac25599 689 at1.at_send1("AT+FSAD=%s\r\n", address);
rainerraul 13:85c3dac25599 690 if(t_interrupt1 == OFF) {
rainerraul 13:85c3dac25599 691 return at1.getAnswer(800);
rainerraul 13:85c3dac25599 692 } else {
rainerraul 13:85c3dac25599 693 return at1.buffer;
rainerraul 13:85c3dac25599 694 }
rainerraul 13:85c3dac25599 695
rainerraul 13:85c3dac25599 696 }
rainerraul 13:85c3dac25599 697 return 0;
rainerraul 13:85c3dac25599 698 }
rainerraul 13:85c3dac25599 699
rainerraul 13:85c3dac25599 700
rainerraul 11:770663228ced 701 char *bt_modul_hc05::delete_device(char *address)
rainerraul 4:1eee19777111 702 {
rainerraul 11:770663228ced 703 switch(t_uart) {
rainerraul 4:1eee19777111 704 case UART1 :
rainerraul 4:1eee19777111 705 at0.at_send("AT+PMSAD=%s\r\n", address);
rainerraul 4:1eee19777111 706 if(t_interrupt == OFF) {
rainerraul 10:2e1538dc2e1a 707 return at0.getAnswer(800);
rainerraul 4:1eee19777111 708 } else {
rainerraul 4:1eee19777111 709 return at0.buffer;
rainerraul 4:1eee19777111 710 }
rainerraul 4:1eee19777111 711
rainerraul 4:1eee19777111 712 case UART6 :
rainerraul 4:1eee19777111 713 at1.at_send1("AT+PMSAD=%s\r\n", address);
rainerraul 4:1eee19777111 714 if(t_interrupt1 == OFF) {
rainerraul 10:2e1538dc2e1a 715 return at1.getAnswer(800);
rainerraul 4:1eee19777111 716 } else {
rainerraul 4:1eee19777111 717 return at1.buffer;
rainerraul 4:1eee19777111 718 }
rainerraul 4:1eee19777111 719
rainerraul 4:1eee19777111 720 }
rainerraul 4:1eee19777111 721 return 0;
rainerraul 7:8b004c3d7e89 722 }
rainerraul 7:8b004c3d7e89 723
rainerraul 11:770663228ced 724 char *bt_modul_hc05::delete_all()
rainerraul 4:1eee19777111 725 {
rainerraul 11:770663228ced 726 switch(t_uart) {
rainerraul 4:1eee19777111 727 case UART1 :
rainerraul 5:498533929bb6 728 at0.at_send("AT+RMAAD\r\n", "");
rainerraul 4:1eee19777111 729 if(t_interrupt == OFF) {
rainerraul 10:2e1538dc2e1a 730 return at0.getAnswer(800);
rainerraul 4:1eee19777111 731 } else {
rainerraul 4:1eee19777111 732 return at0.buffer;
rainerraul 4:1eee19777111 733 }
rainerraul 4:1eee19777111 734
rainerraul 4:1eee19777111 735 case UART6 :
rainerraul 5:498533929bb6 736 at1.at_send1("AT+RMAAD\r\n", "");
rainerraul 4:1eee19777111 737 if(t_interrupt1 == OFF) {
rainerraul 10:2e1538dc2e1a 738 return at1.getAnswer(800);
rainerraul 4:1eee19777111 739 } else {
rainerraul 4:1eee19777111 740 return at1.buffer;
rainerraul 4:1eee19777111 741 }
rainerraul 4:1eee19777111 742
rainerraul 4:1eee19777111 743 }
rainerraul 4:1eee19777111 744 return 0;
rainerraul 7:8b004c3d7e89 745 }
rainerraul 7:8b004c3d7e89 746
rainerraul 11:770663228ced 747 char *bt_modul_hc05::connect_device(char *address)
rainerraul 4:1eee19777111 748 {
rainerraul 11:770663228ced 749 switch(t_uart) {
rainerraul 4:1eee19777111 750 case UART1 :
rainerraul 4:1eee19777111 751 at0.at_send("AT+LINK=%s\r\n", address);
rainerraul 4:1eee19777111 752 if(t_interrupt == OFF) {
rainerraul 10:2e1538dc2e1a 753 return at0.getAnswer(800);
rainerraul 4:1eee19777111 754 } else {
rainerraul 4:1eee19777111 755 return at0.buffer;
rainerraul 4:1eee19777111 756 }
rainerraul 4:1eee19777111 757
rainerraul 4:1eee19777111 758 case UART6 :
rainerraul 4:1eee19777111 759 at1.at_send1("AT+LINK=%s\r\n", address);
rainerraul 4:1eee19777111 760 if(t_interrupt1 == OFF) {
rainerraul 10:2e1538dc2e1a 761 return at1.getAnswer(800);
rainerraul 4:1eee19777111 762 } else {
rainerraul 4:1eee19777111 763 return at1.buffer;
rainerraul 4:1eee19777111 764 }
rainerraul 4:1eee19777111 765
rainerraul 4:1eee19777111 766 }
rainerraul 4:1eee19777111 767 return 0;
rainerraul 7:8b004c3d7e89 768 }
rainerraul 7:8b004c3d7e89 769
rainerraul 11:770663228ced 770 char *bt_modul_hc05::disconnect_device(char *address)
rainerraul 4:1eee19777111 771 {
rainerraul 11:770663228ced 772 switch(t_uart) {
rainerraul 4:1eee19777111 773 case UART1 :
rainerraul 4:1eee19777111 774 at0.at_send("AT+DISC=%s\r\n", address);
rainerraul 4:1eee19777111 775 if(t_interrupt == OFF) {
rainerraul 10:2e1538dc2e1a 776 return at0.getAnswer(800);
rainerraul 4:1eee19777111 777 } else {
rainerraul 4:1eee19777111 778 return at0.buffer;
rainerraul 4:1eee19777111 779 }
rainerraul 4:1eee19777111 780
rainerraul 4:1eee19777111 781 case UART6 :
rainerraul 4:1eee19777111 782 at1.at_send1("AT+DISC=%s\r\n", address);
rainerraul 4:1eee19777111 783 if(t_interrupt1 == OFF) {
rainerraul 10:2e1538dc2e1a 784 return at1.getAnswer(800);
rainerraul 4:1eee19777111 785 } else {
rainerraul 4:1eee19777111 786 return at1.buffer;
rainerraul 4:1eee19777111 787 }
rainerraul 4:1eee19777111 788
rainerraul 4:1eee19777111 789 }
rainerraul 4:1eee19777111 790 return 0;
rainerraul 7:8b004c3d7e89 791 }
rainerraul 7:8b004c3d7e89 792
rainerraul 11:770663228ced 793 bool bt_modul_hc05::data_send(char *data)
rainerraul 7:8b004c3d7e89 794 {
rainerraul 11:770663228ced 795 switch(t_uart) {
rainerraul 7:8b004c3d7e89 796 case UART1 :
rainerraul 7:8b004c3d7e89 797 at0.at_send("%s\r\n", data);
rainerraul 7:8b004c3d7e89 798 return true;
rainerraul 7:8b004c3d7e89 799 case UART6 :
rainerraul 7:8b004c3d7e89 800 at1.at_send1("%s\r\n", data);
rainerraul 7:8b004c3d7e89 801 return true;
rainerraul 7:8b004c3d7e89 802 }
rainerraul 7:8b004c3d7e89 803 return false;
rainerraul 7:8b004c3d7e89 804 }
rainerraul 7:8b004c3d7e89 805
rainerraul 11:770663228ced 806 char *bt_modul_hc05::data_receive()
rainerraul 7:8b004c3d7e89 807 {
rainerraul 11:770663228ced 808 switch(t_uart) {
rainerraul 7:8b004c3d7e89 809 case UART1 :
rainerraul 8:cfdf0583ef6a 810 if(t_interrupt == OFF) {
rainerraul 10:2e1538dc2e1a 811 return at0.getAnswer(800);
rainerraul 8:cfdf0583ef6a 812 } else {
rainerraul 8:cfdf0583ef6a 813 return at0.buffer;
rainerraul 8:cfdf0583ef6a 814 }
rainerraul 7:8b004c3d7e89 815
rainerraul 7:8b004c3d7e89 816 case UART6 :
rainerraul 8:cfdf0583ef6a 817 if(t_interrupt1 == OFF) {
rainerraul 10:2e1538dc2e1a 818 return at1.getAnswer(800);
rainerraul 8:cfdf0583ef6a 819 } else {
rainerraul 8:cfdf0583ef6a 820 return at1.buffer;
rainerraul 8:cfdf0583ef6a 821 }
rainerraul 7:8b004c3d7e89 822 }
rainerraul 7:8b004c3d7e89 823 return '\0';
rainerraul 7:8b004c3d7e89 824
rainerraul 9:a8a96ce56d6e 825 }
rainerraul 9:a8a96ce56d6e 826
rainerraul 11:770663228ced 827 void bt_modul_hc05::flush()
rainerraul 9:a8a96ce56d6e 828 {
rainerraul 11:770663228ced 829 switch(t_uart) {
rainerraul 9:a8a96ce56d6e 830 case UART1 :
rainerraul 9:a8a96ce56d6e 831 if(t_interrupt == ON) {
rainerraul 9:a8a96ce56d6e 832 at0.clear();
rainerraul 9:a8a96ce56d6e 833 }
rainerraul 9:a8a96ce56d6e 834
rainerraul 9:a8a96ce56d6e 835 case UART6 :
rainerraul 9:a8a96ce56d6e 836 if(t_interrupt1 == ON) {
rainerraul 9:a8a96ce56d6e 837 at1.clear();
rainerraul 9:a8a96ce56d6e 838 }
rainerraul 9:a8a96ce56d6e 839 }
rainerraul 10:2e1538dc2e1a 840 }
rainerraul 10:2e1538dc2e1a 841
rainerraul 14:1b81b957214a 842 char *bt_modul_hc05::search_device()
rainerraul 10:2e1538dc2e1a 843 {
rainerraul 13:85c3dac25599 844 bt_modul_hc05::set_addr_mode(ANY);
rainerraul 11:770663228ced 845 bt_modul_hc05::get_modul_init();
rainerraul 11:770663228ced 846 bt_modul_hc05::set_modul_giac("9e8b33");
rainerraul 11:770663228ced 847 bt_modul_hc05::set_device_class(0);
rainerraul 13:85c3dac25599 848 bt_modul_hc05::set_modul_inquiry("1,8,6");
rainerraul 11:770663228ced 849 return bt_modul_hc05::get_modul_inqm();
rainerraul 10:2e1538dc2e1a 850 }
rainerraul 10:2e1538dc2e1a 851
rainerraul 12:4a779fa69f6b 852 char *bt_modul_hc05::link_device_any(char *address)
rainerraul 10:2e1538dc2e1a 853 {
rainerraul 12:4a779fa69f6b 854 bt_modul_hc05::set_addr_mode(ANY);
rainerraul 13:85c3dac25599 855 bt_modul_hc05::search_device(address);
rainerraul 14:1b81b957214a 856 bt_modul_hc05::set_addr_fixed(address);
rainerraul 13:85c3dac25599 857 return bt_modul_hc05::connect_device(address);
rainerraul 13:85c3dac25599 858
rainerraul 12:4a779fa69f6b 859 }
rainerraul 12:4a779fa69f6b 860
rainerraul 12:4a779fa69f6b 861 char *bt_modul_hc05::link_device_fixed(char *address)
rainerraul 12:4a779fa69f6b 862 {
rainerraul 13:85c3dac25599 863
rainerraul 12:4a779fa69f6b 864 bt_modul_hc05::set_addr_mode(FIXED);
rainerraul 14:1b81b957214a 865 bt_modul_hc05::set_addr_fixed(address);
rainerraul 13:85c3dac25599 866 return bt_modul_hc05::connect_device(address);
rainerraul 13:85c3dac25599 867
rainerraul 13:85c3dac25599 868 }
rainerraul 13:85c3dac25599 869
rainerraul 13:85c3dac25599 870 char *bt_modul_hc05::link_device_paired(char *address)
rainerraul 13:85c3dac25599 871 {
rainerraul 13:85c3dac25599 872 bt_modul_hc05::set_addr_mode(ANY);
rainerraul 13:85c3dac25599 873 bt_modul_hc05::get_modul_init();
rainerraul 13:85c3dac25599 874 bt_modul_hc05::set_device_paired(address, 10);
rainerraul 13:85c3dac25599 875 return bt_modul_hc05::connect_device(address);
rainerraul 13:85c3dac25599 876
rainerraul 14:1b81b957214a 877 }
rainerraul 14:1b81b957214a 878
rainerraul 14:1b81b957214a 879 void bt_modul_hc05::init_master_fixed(char *pin, char *name, char *address)
rainerraul 14:1b81b957214a 880 {
rainerraul 14:1b81b957214a 881 bt_modul_hc05::set_modul_role(MASTER);
rainerraul 14:1b81b957214a 882 bt_modul_hc05::set_modul_pincode(pin);
rainerraul 14:1b81b957214a 883 bt_modul_hc05::set_modul_name(name);
rainerraul 14:1b81b957214a 884 bt_modul_hc05::link_device_fixed(address);
rainerraul 14:1b81b957214a 885 bt_modul_hc05::set_reset();
rainerraul 14:1b81b957214a 886 }
rainerraul 14:1b81b957214a 887
rainerraul 14:1b81b957214a 888 void bt_modul_hc05::init_slave(char *pin, char *name)
rainerraul 14:1b81b957214a 889 {
rainerraul 14:1b81b957214a 890 bt_modul_hc05::set_modul_role(SLAVE);
rainerraul 14:1b81b957214a 891 bt_modul_hc05::set_modul_pincode(pin);
rainerraul 15:7db8c9913007 892 bt_modul_hc05::set_modul_name(name);
rainerraul 15:7db8c9913007 893 bt_modul_hc05::set_reset();
rainerraul 7:8b004c3d7e89 894 }