summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--digital/zigbit/common/uid.c38
-rw-r--r--digital/zigbit/common/uid.h23
2 files changed, 52 insertions, 9 deletions
diff --git a/digital/zigbit/common/uid.c b/digital/zigbit/common/uid.c
index 6ecc8ce9..9f8bff42 100644
--- a/digital/zigbit/common/uid.c
+++ b/digital/zigbit/common/uid.c
@@ -26,13 +26,27 @@
/* This function returns the UID of the device according to the mapping of F5 F6 F7 F8*/
#include "uid.h"
+#include <util/delay.h>
/* APBTeam static zigbit device list */
-static DeviceType_t apbeam_zigbit_table[APBTEAM_MAX_ZIGBIT_DEVICES] =
+static zigbit_definition_s apbeam_zigbit_table[APBTEAM_MAX_ZIGBIT_DEVICES] =
{
- DEVICE_TYPE_COORDINATOR,
- DEVICE_TYPE_END_DEVICE,
- DEVICE_TYPE_END_DEVICE
+ {0 ,DEVICE_TYPE_COORDINATOR ,ZIGBIT_BEACON},
+ {1 ,DEVICE_TYPE_ROUTER ,ZIGBIT_BEACON},
+ {2 ,DEVICE_TYPE_ROUTER ,ZIGBIT_BEACON},
+ {3 ,DEVICE_TYPE_ROUTER ,ZIGBIT_BEACON},
+ {4 ,DEVICE_TYPE_ROUTER ,ZIGBIT_NOT_DEFINED},
+ {5 ,DEVICE_TYPE_ROUTER ,ZIGBIT_NOT_DEFINED},
+ {6 ,DEVICE_TYPE_ROUTER ,ZIGBIT_NOT_DEFINED},
+ {7 ,DEVICE_TYPE_ROUTER ,ZIGBIT_NOT_DEFINED},
+ {8 ,DEVICE_TYPE_ROUTER ,ZIGBIT_NOT_DEFINED},
+ {9 ,DEVICE_TYPE_ROUTER ,ZIGBIT_NOT_DEFINED},
+ {10 ,DEVICE_TYPE_ROUTER ,ZIGBIT_NOT_DEFINED},
+ {11 ,DEVICE_TYPE_ROUTER ,ZIGBIT_NOT_DEFINED},
+ {12 ,DEVICE_TYPE_ROUTER ,ZIGBIT_NOT_DEFINED},
+ {13 ,DEVICE_TYPE_ROUTER ,ZIGBIT_NOT_DEFINED},
+ {14 ,DEVICE_TYPE_ROUTER ,ZIGBIT_DONGLE},
+ {15 ,DEVICE_TYPE_ROUTER ,ZIGBIT_DONGLE},
};
/* This function returns the UID of the device according to the mapping of F5 F6 F7 F8*/
@@ -46,6 +60,8 @@ uint16_t get_uid(void)
/* F4 -> F7 configured as input */
DDRF = 0x00;
+ _delay_ms(10);
+
if(PINF&0x20) //PINF5
value &= 0xF7;
@@ -59,14 +75,20 @@ uint16_t get_uid(void)
value &= 0xFE;
/* Nothing connected */
- if(PINF&0xFF)
- value &=0xF0;
-
+// if(PINF&0xFF)
+// value &=0xF0;
+
return value;
}
/* This function returns the device type */
DeviceType_t get_device_type(uint16_t uid)
{
- return apbeam_zigbit_table[uid];
+ return apbeam_zigbit_table[uid].type;
+}
+
+/* This function returns the device functionnaly */
+TFunctionnality get_device_functionnality(uint16_t uid)
+{
+ return apbeam_zigbit_table[uid].func;
}
diff --git a/digital/zigbit/common/uid.h b/digital/zigbit/common/uid.h
index c5a5c8f4..f3969b2e 100644
--- a/digital/zigbit/common/uid.h
+++ b/digital/zigbit/common/uid.h
@@ -23,11 +23,32 @@
*
* }}} */
-#define APBTEAM_MAX_ZIGBIT_DEVICES 3
+#ifndef _UID_H
+#define _UID_H
+#define APBTEAM_MAX_ZIGBIT_DEVICES 16
+
+typedef enum
+{
+ ZIGBIT_NOT_DEFINED,
+ ZIGBIT_BEACON,
+ ZIGBIT_DONGLE,
+} TFunctionnality;
+
+typedef struct
+{
+ uint16_t uid;
+ DeviceType_t type;
+ TFunctionnality func;
+} zigbit_definition_s;
/* This function returns the UID of the device according to the mapping of F5 F6 F7 F8*/
uint16_t get_uid(void);
/* This function returns the device type */
DeviceType_t get_device_type(uint16_t uid);
+
+/* This function returns the device functionnaly */
+TFunctionnality get_device_functionnality(uint16_t uid);
+
+#endif