Bluetooth hc05 library
Diff: hc05.cpp
- Revision:
- 1:8d4296aafa55
- Parent:
- 0:15a264bf1590
- Child:
- 2:38f1fb034a75
diff -r 15a264bf1590 -r 8d4296aafa55 hc05.cpp --- a/hc05.cpp Thu Aug 16 21:09:39 2018 +0000 +++ b/hc05.cpp Fri Aug 17 12:51:39 2018 +0000 @@ -94,7 +94,7 @@ case UART1 : at0.at_send("AT+ADDR?\r\n", ""); if(t_interrupt == OFF) { - return at0.getAnswer(4); + return at0.getAnswer(1); } else { return at0.buffer; } @@ -102,7 +102,7 @@ case UART6 : at1.at_send1("AT+ADDR?\r\n", ""); if(t_interrupt1 == OFF) { - return at1.getAnswer(4); + return at1.getAnswer(1); } else { return at1.buffer; } @@ -262,7 +262,7 @@ case UART1 : at0.at_send("AT+PSWD?\r\n", ""); if(t_interrupt == OFF) { - return at0.getAnswer(4); + return at0.getAnswer(1); } else { return at0.buffer; } @@ -270,7 +270,7 @@ case UART6 : at1.at_send1("AT+PSWD?\r\n", ""); if(t_interrupt1 == OFF) { - return at1.getAnswer(4); + return at1.getAnswer(1); } else { return at1.buffer; } @@ -431,5 +431,51 @@ } +char *bt_modul_hc05::set_modul_address(UART num, char *addr) +{ + switch(num) { + case UART1 : + at0.at_send1("AT+ADDR=%s\r\n", addr); + if(t_interrupt == OFF) { + return at0.getAnswer(3); + } else { + return at0.buffer; + } + case UART6 : + at0.at_send1("AT+ADDR=%s\r\n", addr); + if(t_interrupt1 == OFF) { + return at1.getAnswer(3); + } else { + return at1.buffer; + } + + } + return 0; + +} + +char *bt_modul_hc05::set_modul_name(UART num, char *name) +{ + switch(num) { + case UART1 : + at0.at_send("AT+NAME=%s\r\n", name); + if(t_interrupt == OFF) { + return at0.getAnswer(3); + } else { + return at0.buffer; + } + + case UART6 : + at1.at_send1("AT+NAME=%s\r\n", name); + if(t_interrupt1 == OFF) { + return at1.getAnswer(3); + } else { + return at1.buffer; + } + + } + return 0; + +}