standalone sx1276 demo program

Dependencies:   SX1276Lib mbed

Fork of SX1276_GPS by CaryCoders

Committer:
ftagius
Date:
Tue Jul 14 14:58:23 2015 +0000
Revision:
31:2c813f321db7
Parent:
29:0ea07cc7124b
Child:
32:a2472bbe7c92
refactored sx1276 demo code

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ftagius 29:0ea07cc7124b 1 #include "mbed.h"
ftagius 29:0ea07cc7124b 2 #include "sx1276-hal.h"
ftagius 29:0ea07cc7124b 3 #include "main.h"
ftagius 29:0ea07cc7124b 4 #include "debug.h"
ftagius 31:2c813f321db7 5 //radfta #include "vt100.h"
ftagius 29:0ea07cc7124b 6 #include "serial_api.h"
ftagius 29:0ea07cc7124b 7
ftagius 29:0ea07cc7124b 8 int get_kbd_str(char* buf, int size)
ftagius 29:0ea07cc7124b 9 {
ftagius 29:0ea07cc7124b 10 char c;
ftagius 29:0ea07cc7124b 11 int i;
ftagius 29:0ea07cc7124b 12 static int prev_len;
ftagius 29:0ea07cc7124b 13
ftagius 29:0ea07cc7124b 14 for (i = 0;;) {
ftagius 29:0ea07cc7124b 15 if (pc.readable()) {
ftagius 29:0ea07cc7124b 16 c = pc.getc();
ftagius 29:0ea07cc7124b 17 if (c == 8 && i > 0) {
ftagius 29:0ea07cc7124b 18 pc.putc(8);
ftagius 29:0ea07cc7124b 19 pc.putc(' ');
ftagius 29:0ea07cc7124b 20 pc.putc(8);
ftagius 29:0ea07cc7124b 21 i--;
ftagius 29:0ea07cc7124b 22 } else if (c == '\r') {
ftagius 29:0ea07cc7124b 23 if (i == 0) {
ftagius 29:0ea07cc7124b 24 if (app == APP_CHAT)
ftagius 29:0ea07cc7124b 25 return 0;
ftagius 29:0ea07cc7124b 26 else
ftagius 29:0ea07cc7124b 27 return prev_len; // repeat previous
ftagius 29:0ea07cc7124b 28 } else {
ftagius 29:0ea07cc7124b 29 buf[i] = 0; // null terminate
ftagius 29:0ea07cc7124b 30 prev_len = i;
ftagius 29:0ea07cc7124b 31 return i;
ftagius 29:0ea07cc7124b 32 }
ftagius 29:0ea07cc7124b 33 } else if (c == 3) {
ftagius 29:0ea07cc7124b 34 // ctrl-C abort
ftagius 29:0ea07cc7124b 35 return -1;
ftagius 29:0ea07cc7124b 36 } else if (i < size) {
ftagius 29:0ea07cc7124b 37 buf[i++] = c;
ftagius 29:0ea07cc7124b 38 pc.putc(c);
ftagius 29:0ea07cc7124b 39 }
ftagius 29:0ea07cc7124b 40 } else {
ftagius 29:0ea07cc7124b 41 if (app == APP_PING)
ftagius 29:0ea07cc7124b 42 ping_pong();
ftagius 29:0ea07cc7124b 43 if (app == APP_HELLO)
ftagius 29:0ea07cc7124b 44 hello();
ftagius 29:0ea07cc7124b 45 if (app == APP_GPS)
ftagius 29:0ea07cc7124b 46 check_gps();
ftagius 29:0ea07cc7124b 47 #if 1
ftagius 29:0ea07cc7124b 48 if (app == APP_CHAT)
ftagius 29:0ea07cc7124b 49 {
ftagius 29:0ea07cc7124b 50 // printf("utility call to console chat\r\n");
ftagius 29:0ea07cc7124b 51 check_rx_chat();
ftagius 29:0ea07cc7124b 52 }
ftagius 29:0ea07cc7124b 53 #endif
ftagius 29:0ea07cc7124b 54 }
ftagius 29:0ea07cc7124b 55 } // ...for()
ftagius 29:0ea07cc7124b 56 }