Suga koubou / IM920

Dependents:   IM920_sample IM920_SDlog IM920_sample IM920_sample3 ... more

Files at this revision

API Documentation at this revision

Comitter:
idealtechlab
Date:
Thu Jan 29 06:16:10 2015 +0000
Parent:
3:db269462ad1c
Child:
5:2fd9b1725283
Commit message:
setCh, setPower

Changed in this revision

IM920.cpp Show annotated file Show diff for this revision Revisions of this file
IM920.h Show annotated file Show diff for this revision Revisions of this file
IM920_cmd.cpp Show annotated file Show diff for this revision Revisions of this file
IM920_util.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/IM920.cpp	Thu Jan 08 13:25:46 2015 +0000
+++ b/IM920.cpp	Thu Jan 29 06:16:10 2015 +0000
@@ -37,17 +37,6 @@
     return 0;
 }
 
-
-int IM920::setNode (int node) {
-    _state.node = node;
-    return cmdSTNN(_state.node);
-}
-
-int IM920::getNode () {
-    cmdRDNN();
-    return _state.node;
-}
-
 void IM920::poll () {
 
     if (_state.received && _state.buf != NULL)
--- a/IM920.h	Thu Jan 08 13:25:46 2015 +0000
+++ b/IM920.h	Thu Jan 29 06:16:10 2015 +0000
@@ -28,7 +28,7 @@
 #include <string.h>
 
 //Debug is disabled by default
-#if defined(DEBUG) and (!defined(TARGET_LPC11U24))
+#if defined(DEBUG)
 #define DBG(x, ...) std::printf("[DBG]" x "\r\n", ##__VA_ARGS__);
 #define WARN(x, ...) std::printf("[WARN]" x "\r\n", ##__VA_ARGS__);
 #define ERR(x, ...) std::printf("[ERR]" x "\r\n", ##__VA_ARGS__);
@@ -62,8 +62,9 @@
     IM920 (PinName tx, PinName rx, PinName busy, PinName reset, int baud = IM920_BAUD);
 
     int init ();
-    int setNode (int node);
-    int getNode ();
+    void poll ();
+    int send (char *buf, int len);
+    int recv (char *buf, int len);
 
     void attach (void(*fptr)() = NULL) {
         _func.attach(fptr);
@@ -75,15 +76,16 @@
         }
     }
 
-    void poll ();
-
-    int send (char *buf, int len);
-    int recv (char *buf, int len);
-
+    // ----- IM920_util.cpp -----
+    int setNode (int node);
+    int getNode ();
     int setCh (int ch);
+    int setPower (int pwr);
+    int setSpeed (int spd);
     int getRssi ();
     int sleep ();
     int wakeup ();
+    int test ();
 
     // ----- IM920_cmd.cpp -----
     int sendCommand(const char * cmd, Response res = RES_NULL, int timeout = DEFAULT_WAIT_RESP_TIMEOUT);
@@ -142,6 +144,8 @@
     int cmdSBRT (int n);
     int cmdDSRX ();
     int cmdENRX ();
+    int cmdEGRX ();
+    int cmdDGRX ();
 
     // ----- IM920_hal.cpp -----
     void setReset (bool flg);
--- a/IM920_cmd.cpp	Thu Jan 08 13:25:46 2015 +0000
+++ b/IM920_cmd.cpp	Thu Jan 29 06:16:10 2015 +0000
@@ -145,3 +145,7 @@
 int IM920::cmdENRX () {
     return sendCommand("ENRX");
 }
+
+int IM920::cmdEGRX () {
+    return sendCommand("EGRX");
+}
--- a/IM920_util.cpp	Thu Jan 08 13:25:46 2015 +0000
+++ b/IM920_util.cpp	Thu Jan 29 06:16:10 2015 +0000
@@ -1,10 +1,30 @@
 #include "IM920.h"
 
+int IM920::setNode (int node) {
+    _state.node = node;
+    return cmdSTNN(_state.node);
+}
+
+int IM920::getNode () {
+    cmdRDNN();
+    return _state.node;
+}
+
 int IM920::setCh (int ch) {
-    if (ch < 1 || ch > 15) return false;
+    if (ch < 1 || ch > 15) return -1;
     return cmdSTCH(ch);
 }
 
+int IM920::setPower (int pwr) {
+    if (pwr < 1 || pwr > 3) return -1;
+    return cmdSTPO(pwr);
+}
+
+int IM920::setSpeed (int spd) {
+    if (spd < 1 || spd > 2) return -1;
+    return cmdSTRT(spd);
+}
+
 int IM920::getRssi () {
     cmdRDRS();
     return _state.rssi;
@@ -25,6 +45,10 @@
     return cmdENRX();
 }
 
+int IM920::test () {
+    return cmdEGRX();
+}
+
 
 int IM920::x2i (char c) {
     if (c >= '0' && c <= '9') {