Interplan IM920 library, 920MHz module
Dependents: IM920_sample IM920_SDlog IM920_sample IM920_sample3 ... more
IM920_util.cpp
00001 #include "IM920.h" 00002 00003 int IM920::setNode (int node) { 00004 _state.node = node; 00005 return cmdSTNN(_state.node); 00006 } 00007 00008 int IM920::getNode () { 00009 cmdRDNN(); 00010 return _state.node; 00011 } 00012 00013 int IM920::setCh (int ch) { 00014 if (ch < 1 || ch > 15) return -1; 00015 return cmdSTCH(ch); 00016 } 00017 00018 int IM920::setPower (int pwr) { 00019 if (pwr < 1 || pwr > 3) return -1; 00020 return cmdSTPO(pwr); 00021 } 00022 00023 int IM920::setSpeed (int spd) { 00024 if (spd < 1 || spd > 2) return -1; 00025 return cmdSTRT(spd); 00026 } 00027 00028 int IM920::getRssi () { 00029 cmdRDRS(); 00030 return _state.rssi; 00031 } 00032 00033 int IM920::sleep () { 00034 if (_state.status != STAT_NONE) return -1; 00035 00036 _state.status = STAT_SLEEP; 00037 return cmdDSRX(); 00038 } 00039 00040 int IM920::wakeup () { 00041 if (_state.status != STAT_SLEEP) return -1; 00042 00043 putUart('\r'); 00044 putUart('\n'); 00045 return cmdENRX(); 00046 } 00047 00048 int IM920::test () { 00049 return cmdEGRX(); 00050 } 00051 00052 00053 int IM920::x2i (char c) { 00054 if (c >= '0' && c <= '9') { 00055 return c - '0'; 00056 } else 00057 if (c >= 'A' && c <= 'F') { 00058 return c - 'A' + 10; 00059 } else 00060 if (c >= 'a' && c <= 'f') { 00061 return c - 'a' + 10; 00062 } 00063 return 0; 00064 } 00065 00066 char IM920::i2x (int i) { 00067 if (i >= 0 && i <= 9) { 00068 return i + '0'; 00069 } else 00070 if (i >= 10 && i <= 15) { 00071 return i - 10 + 'A'; 00072 } 00073 return 0; 00074 }
Generated on Sat Jul 16 2022 00:47:33 by 1.7.2