|
|
@@ -4,6 +4,7 @@
|
|
|
#include "serial.h"
|
|
|
#include "rn42.h"
|
|
|
#include "print.h"
|
|
|
+#include "timer.h"
|
|
|
#include "wait.h"
|
|
|
|
|
|
|
|
|
@@ -47,11 +48,39 @@ void rn42_init(void)
|
|
|
serial_init();
|
|
|
}
|
|
|
|
|
|
+int16_t rn42_getc(void)
|
|
|
+{
|
|
|
+ return serial_recv2();
|
|
|
+}
|
|
|
+
|
|
|
+char *rn42_gets(uint16_t timeout)
|
|
|
+{
|
|
|
+ static char s[16];
|
|
|
+ uint16_t t = timer_read();
|
|
|
+ uint8_t i = 0;
|
|
|
+ int16_t c;
|
|
|
+ while (i < 15 && timer_elapsed(t) < timeout) {
|
|
|
+ if ((c = rn42_getc()) != -1) {
|
|
|
+ if ((char)c == '\r') continue;
|
|
|
+ if ((char)c == '\n') break;
|
|
|
+ s[i++] = c;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ s[i] = '\0';
|
|
|
+ return s;
|
|
|
+}
|
|
|
+
|
|
|
void rn42_putc(uint8_t c)
|
|
|
{
|
|
|
serial_send(c);
|
|
|
}
|
|
|
|
|
|
+void rn42_puts(char *s)
|
|
|
+{
|
|
|
+ while (*s)
|
|
|
+ serial_send(*s++);
|
|
|
+}
|
|
|
+
|
|
|
bool rn42_autoconnecting(void)
|
|
|
{
|
|
|
// GPIO6 for control connection(high: auto connect, low: disconnect)
|