Class to communicate with ELV(R) MAX! wireless devices with RFM22B-Modules. Based on Library RF22. Initial version unable to send! Only receive! See http://mbed.org/users/charly/notebook/reading-a-max-wireless-window-sensor-with-rfm22-an/

Dependents:   RF22_MAX_test_Send

Revision:
0:565a81d6f278
Child:
1:6321e6784ada
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RF22Max.h	Sun Sep 15 19:33:56 2013 +0000
@@ -0,0 +1,54 @@
+#ifndef RF22Max_h
+#define RF22Max_h
+
+#include "mbed.h"
+#include <RF22.h>
+
+// define DEBUG if you want to see bufer-output on pc (defined in main)
+#ifdef DEBUG
+extern Serial pc;
+#endif
+
+#define lengthof(x) (sizeof(x) / sizeof(*x))
+
+class RF22Max : public RF22
+{
+public:
+// a message from the max!-Device
+typedef struct {
+    uint8_t    len;                //message-length
+    uint8_t    cnt;                //message-counter
+    uint8_t    flags;              // ??
+    uint8_t    type;               //message-type
+    char       type_str[50];       // type in text
+    uint32_t   frm_adr;            // unique address of device
+    uint32_t   to_adr;             // unique address of device
+    uint8_t    groupid;            //groupid
+    uint8_t    payload[50];        // data
+    uint16_t   crc;                // crc fro the message
+    char       state[50];          // state of the device: open, closed, auto, eco,...
+    char       battery_state[50];  // Battery-state of the device : good, low
+} max_message;
+
+RF22Max(PinName slaveSelectPin, PinName mosi, PinName miso, PinName sclk, PinName interrupt);
+
+boolean init();
+
+boolean recv(uint8_t* buf, uint8_t* len);
+
+boolean recv_max(RF22Max::max_message* message);
+
+private:
+
+#ifdef DEBUG
+void printHex(uint8_t *buf, size_t len, bool nl);
+#endif
+
+uint16_t calc_crc_step(uint8_t crcData, uint16_t crcReg);
+
+uint16_t calc_crc(uint8_t *buf, size_t len);
+
+
+}; // end class RF22Max
+
+#endif