]> rtime.felk.cvut.cz Git - mirosot.git/blobdiff - testapp/cmd_bth.c
An unsucesfull attempt to clean bluetooth library and make it working.
[mirosot.git] / testapp / cmd_bth.c
diff --git a/testapp/cmd_bth.c b/testapp/cmd_bth.c
new file mode 100644 (file)
index 0000000..348c411
--- /dev/null
@@ -0,0 +1,41 @@
+#include <cmd_proc.h>
+#include <cmd_bth.h>
+#include <string.h>
+
+cmd_io_t cmd_io_bth;
+
+
+int cmd_bth_processor_run(void)
+{
+  int val;
+  cmd_io_t* cmd_io;
+
+  cmd_io=&cmd_io_bth;
+  if(cmd_bth_line_out(cmd_io))
+    return 1;
+
+  if(cmd_bth_line_in(cmd_io)<=0)
+    return 0;
+
+  if(cmd_bth){
+    val=proc_cmd_line(cmd_io, cmd_bth, cmd_io->priv.ed_line.in->buf);
+  }else{
+    val=-CMDERR_BADCMD;
+  }
+
+  if(cmd_io->priv.ed_line.out->inbuf){
+    cmd_io_putc(cmd_io,'\r');
+    cmd_io_putc(cmd_io,'\n');
+
+  }else if(val<0){
+    char s[20];
+    cmd_io_write(&cmd_io_bth,"ERROR ",6);
+    i2str(s,-val,0,0);
+    cmd_io_write(cmd_io,s,strlen(s));
+    cmd_io_putc(cmd_io,'\r');
+    cmd_io_putc(cmd_io,'\n');
+  }
+  return 1;
+}
+
+