Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: mDot.h
- Revision:
- 11:d8464345e1f1
- Parent:
- 10:27dafba9fe19
- Child:
- 12:54f9cac9d690
diff -r 27dafba9fe19 -r d8464345e1f1 mDot.h
--- a/mDot.h Wed Dec 02 15:19:12 2015 -0600
+++ b/mDot.h Thu Jan 07 12:07:28 2016 -0600
@@ -134,8 +134,8 @@
};
enum FrequencyBands {
- FB_868,
- FB_915
+ FB_868, // EU868
+ FB_915 // US915
};
enum FrequencySubBands {
@@ -196,10 +196,10 @@
} rssi_stats;
typedef struct {
- int8_t last;
- int8_t min;
- int8_t max;
- int8_t avg;
+ int16_t last;
+ int16_t min;
+ int16_t max;
+ int16_t avg;
} snr_stats;
typedef struct {
@@ -556,12 +556,12 @@
bool getAesEncryption();
/** Get RSSI stats
- * @returns rssi_stats struct containing last, min, max, and avg RSSI
+ * @returns rssi_stats struct containing last, min, max, and avg RSSI in dB
*/
rssi_stats getRssiStats();
/** Get SNR stats
- * @returns snr_stats struct containing last, min, max, and avg SNR
+ * @returns snr_stats struct containing last, min, max, and avg SNR in cB
*/
snr_stats getSnrStats();
@@ -625,16 +625,41 @@
/** Set TX data rate
* data rates affect maximum payload size
- * @param dr SF_7 - SF_12 for Europe, SF_7 - SF_10 for United States
+ * @param dr SF_7 - SF_12|DR0-DR7 for Europe, SF_7 - SF_10 | DR0-DR4 for United States
* @returns MDOT_OK if success
*/
int32_t setTxDataRate(const uint8_t& dr);
/** Get TX data rate
- * @returns current TX data rate (SF_7 - SF_12)
+ * @returns current TX data rate (DR0-DR15)
*/
uint8_t getTxDataRate();
+
+ /** Get data rate spreading factor and bandwidth
+ * EU868 Datarates
+ * ---------------
+ * DR0 - SF12BW125
+ * DR1 - SF11BW125
+ * DR2 - SF10BW125
+ * DR3 - SF9BW125
+ * DR4 - SF8BW125
+ * DR5 - SF7BW125
+ * DR6 - SF7BW250
+ * DR7 - FSK
+ *
+ * US915 Datarates
+ * ---------------
+ * DR0 - SF10BW125
+ * DR1 - SF9BW125
+ * DR2 - SF8BW125
+ * DR3 - SF7BW125
+ * DR4 - SF8BW500
+ *
+ * @returns spreading factor and bandwidth
+ */
+ std::string getDateRateDetails(uint8_t rate);
+
/** Set TX power
* power affects maximum range
* @param power 2 dBm - 20 dBm
@@ -647,6 +672,17 @@
*/
uint32_t getTxPower();
+ /** Get configured gain of installed antenna
+ * @returns gain of antenna in dBi
+ */
+ int8_t getAntennaGain();
+
+ /** Set configured gain of installed antenna
+ * @param gain -127 dBi - 128 dBi
+ * @returns MDOT_OK if success
+ */
+ int32_t setAntennaGain(int8_t gain);
+
/** Enable/disable TX waiting for rx windows
* when enabled, send calls will block until a packet is received or RX timeout
* @param enable set to true if expecting responses to transmitted packets
@@ -748,18 +784,18 @@
* @param deepsleep if true go into deep sleep mode (lowest power, all memory and registers are lost, peripherals turned off)
* else go into sleep mode (low power, memory and registers are maintained, peripherals stay on)
*
- * in sleep mode, the device can be woken up on any of the XBEE pins or by the RTC alarm
+ * in sleep mode, the device can be woken up on an XBEE_DI (2-8) pin or by the RTC alarm
* in deepsleep mode, the device can only be woken up using the WKUP pin (PA0, XBEE_DIO7) or by the RTC alarm
*/
void sleep(const uint32_t& interval, const uint8_t& wakeup_mode = RTC_ALARM, const bool& deepsleep = true);
/** Set wake pin
- * @param pin the pin to use to wake the device from sleep mode
+ * @param pin the pin to use to wake the device from sleep mode XBEE_DI (2-8)
*/
void setWakePin(const PinName& pin);
/** Get wake pin
- * @returns the pin to use to wake the device from sleep mode
+ * @returns the pin to use to wake the device from sleep mode XBEE_DI (2-8)
*/
PinName getWakePin();
@@ -777,15 +813,89 @@
*/
bool readUserBackupRegister(uint32_t reg, uint32_t& data);
- /******************************************
- * THESE FEATURES ARE NOT FULLY IMPLEMENTED
- *****************************************/
- // get/set adaptive data rate
- // configure data rates and power levels based on signal to noise information from gateway
- // true == adaptive data rate is on
- // set function returns MDOT_OK if success
- int32_t setAdr(const bool& on);
- bool getAdr();
+ // Save user file data to flash
+ // file - name of file max 30 chars
+ // data - data of file
+ // size - size of file
+ bool saveUserFile(const char* file, void* data, uint32_t size);
+
+ // Append user file data to flash
+ // file - name of file max 30 chars
+ // data - data of file
+ // size - size of file
+ bool appendUserFile(const char* file, void* data, uint32_t size);
+
+ // Read user file data from flash
+ // file - name of file max 30 chars
+ // data - data of file
+ // size - size of file
+ bool readUserFile(const char* file, void* data, uint32_t size);
+
+ // Move a user file in flash
+ // file - name of file
+ // new_name - new name of file
+ bool moveUserFile(const char* file, const char* new_name);
+
+ // Delete user file data from flash
+ // file - name of file max 30 chars
+ bool deleteUserFile(const char* file);
+
+ // Open user file in flash, max of 4 files open concurrently
+ // file - name of file max 30 chars
+ // mode - combination of FM_APPEND | FM_TRUNC | FM_CREAT |
+ // FM_RDONLY | FM_WRONLY | FM_RDWR | FM_DIRECT
+ // returns - mdot_file struct, fd field will be a negative value if file could not be opened
+ mDot::mdot_file openUserFile(const char* file, int mode);
+
+ // Seek an open file
+ // file - mdot file struct
+ // offset - offset in bytes
+ // whence - where offset is based SEEK_SET, SEEK_CUR, SEEK_END
+ bool seekUserFile(mDot::mdot_file& file, size_t offset, int whence);
+
+ // Read bytes from open file
+ // file - mdot file struct
+ // data - mem location to store data
+ // length - number of bytes to read
+ // returns - number of bytes written
+ int readUserFile(mDot::mdot_file& file, void* data, size_t length);
+
+ // Write bytes to open file
+ // file - mdot file struct
+ // data - data to write
+ // length - number of bytes to write
+ // returns - number of bytes written
+ int writeUserFile(mDot::mdot_file& file, void* data, size_t length);
+
+ // Close open file
+ // file - mdot file struct
+ bool closeUserFile(mDot::mdot_file& file);
+
+ // List user files stored in flash
+ std::vector<mDot::mdot_file> listUserFiles();
+
+ // Move file into the firmware upgrade path to be flashed on next boot
+ // file - name of file
+ bool moveUserFileToFirmwareUpgrade(const char* file);
+
+ // get current statistics
+ // Join Attempts, Join Fails, Up Packets, Down Packets, Missed Acks
+ mdot_stats getStats();
+
+ // reset statistics
+ // Join Attempts, Join Fails, Up Packets, Down Packets, Missed Acks
+ void resetStats();
+
+ // Convert pin number 2-8 to pin name DIO2-DI8
+ static PinName pinNum2Name(uint8_t num);
+
+ // Convert pin name DIO2-DI8 to pin number 2-8
+ static uint8_t pinName2Num(PinName name);
+
+ // Convert pin name DIO2-DI8 to string
+ static std::string pinName2Str(PinName name);
+
+ uint64_t crc64(uint64_t crc, const unsigned char *s, uint64_t l);
/*************************************************************************
* The following functions are only used by the AT command application and
@@ -871,89 +981,16 @@
int32_t setWakeMode(const uint8_t& delay);
uint8_t getWakeMode();
- // Save user file data to flash
- // file - name of file max 30 chars
- // data - data of file
- // size - size of file
- bool saveUserFile(const char* file, void* data, uint32_t size);
-
- // Append user file data to flash
- // file - name of file max 30 chars
- // data - data of file
- // size - size of file
- bool appendUserFile(const char* file, void* data, uint32_t size);
-
- // Read user file data from flash
- // file - name of file max 30 chars
- // data - data of file
- // size - size of file
- bool readUserFile(const char* file, void* data, uint32_t size);
-
- // Move a user file in flash
- // file - name of file
- // new_name - new name of file
- bool moveUserFile(const char* file, const char* new_name);
-
- // Delete user file data from flash
- // file - name of file max 30 chars
- bool deleteUserFile(const char* file);
-
- // Open user file in flash, max of 4 files open concurrently
- // file - name of file max 30 chars
- // mode - combination of FM_APPEND | FM_TRUNC | FM_CREAT |
- // FM_RDONLY | FM_WRONLY | FM_RDWR | FM_DIRECT
- // returns - mdot_file struct, fd field will be a negative value if file could not be opened
- mDot::mdot_file openUserFile(const char* file, int mode);
-
- // Seek an open file
- // file - mdot file struct
- // offset - offset in bytes
- // whence - where offset is based SEEK_SET, SEEK_CUR, SEEK_END
- bool seekUserFile(mDot::mdot_file& file, size_t offset, int whence);
+ /******************************************
+ * THESE FEATURES ARE NOT FULLY IMPLEMENTED
+ *****************************************/
- // Read bytes from open file
- // file - mdot file struct
- // data - mem location to store data
- // length - number of bytes to read
- // returns - number of bytes written
- int readUserFile(mDot::mdot_file& file, void* data, size_t length);
-
- // Write bytes to open file
- // file - mdot file struct
- // data - data to write
- // length - number of bytes to write
- // returns - number of bytes written
- int writeUserFile(mDot::mdot_file& file, void* data, size_t length);
-
- // Close open file
- // file - mdot file struct
- bool closeUserFile(mDot::mdot_file& file);
-
- // List user files stored in flash
- std::vector<mDot::mdot_file> listUserFiles();
-
- // Move file into the firmware upgrade path to be flashed on next boot
- // file - name of file
- bool moveUserFileToFirmwareUpgrade(const char* file);
-
- // get current statistics
- // Join Attempts, Join Fails, Up Packets, Down Packets, Missed Acks
- mdot_stats getStats();
-
- // reset statistics
- // Join Attempts, Join Fails, Up Packets, Down Packets, Missed Acks
- void resetStats();
-
- // Convert pin number 2-8 to pin name DIO2-DI8
- static PinName pinNum2Name(uint8_t num);
-
- // Convert pin name DIO2-DI8 to pin number 2-8
- static uint8_t pinName2Num(PinName name);
-
- // Convert pin name DIO2-DI8 to string
- static std::string pinName2Str(PinName name);
-
- uint64_t crc64(uint64_t crc, const unsigned char *s, uint64_t l);
+ // get/set adaptive data rate
+ // configure data rates and power levels based on signal to noise information from gateway
+ // true == adaptive data rate is on
+ // set function returns MDOT_OK if success
+ int32_t setAdr(const bool& on);
+ bool getAdr();
// MTS_RADIO_DEBUG_COMMANDS
@@ -982,9 +1019,18 @@
// deprecated - use getWakeTimeout
uint16_t getSerialReceiveTimeout();
+ void setWakeupCallback(void (*function)(void));
+
+ template<typename T>
+ void setWakeupCallback(T *object, void (T::*member)(void)) {
+ _wakeup_callback.attach(object, member);
+ }
+
private:
mdot_stats _stats;
+ FunctionPointer _wakeup_callback;
+
};
#endif