summaryrefslogtreecommitdiff
path: root/io-module/mtac_lora.c
diff options
context:
space:
mode:
authorJesse Gilles <jgilles@multitech.com>2015-02-25 15:05:56 -0600
committerJesse Gilles <jgilles@multitech.com>2015-02-25 15:05:56 -0600
commit1a06d05dad8eb53ba8bfb4cf45d92041b226b813 (patch)
tree74fda3d1bd4a37a16630c7f48de2457ff26f5ff3 /io-module/mtac_lora.c
parentae93c853b5edd59059581c5a49a99a7326e4b31b (diff)
downloadmts-io-1a06d05dad8eb53ba8bfb4cf45d92041b226b813.tar.gz
mts-io-1a06d05dad8eb53ba8bfb4cf45d92041b226b813.tar.bz2
mts-io-1a06d05dad8eb53ba8bfb4cf45d92041b226b813.zip
Add MTAC-LORA-1.0, EUI for accessory card eeprom1.1.1
Diffstat (limited to 'io-module/mtac_lora.c')
-rw-r--r--io-module/mtac_lora.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/io-module/mtac_lora.c b/io-module/mtac_lora.c
index b546003..8616d21 100644
--- a/io-module/mtac_lora.c
+++ b/io-module/mtac_lora.c
@@ -23,8 +23,10 @@ static char* lora_gpio_pin_name_by_attr_name(const char* name, int port) {
// 1 product-id
// 1 device-id
// 1 hw-version
+// 1 eui
+// 1 reset
// NULL
-static size_t ap_lora_attrs_size = 6;
+static size_t ap_lora_attrs_size = 8;
static bool lora_setup(enum ap port) {
int i;
@@ -35,6 +37,7 @@ static bool lora_setup(enum ap port) {
char buf[32];
struct kobj_attribute* attr;
struct attribute **attrs;
+ int lora_hw_version;
log_info("loading LORA accessory card in port %d", port);
@@ -73,18 +76,30 @@ static bool lora_setup(enum ap port) {
return false;
}
- sprintf(buf, "reset");
- attr = create_attribute(buf, MTS_ATTR_MODE_RW);
- if (! attr) {
- log_error("failed to create attribute [%s] for LORA in port %d", buf, port);
+ if (strncmp(ap_eeprom[port_index].hw_version, HW_VERSION_MTAC_LORA_0_0, strlen(HW_VERSION_MTAC_LORA_0_0)) == 0)
+ lora_hw_version = MTAC_LORA_0_0;
+ else if (strncmp(ap_eeprom[port_index].hw_version, HW_VERSION_MTAC_LORA_1_0, strlen(HW_VERSION_MTAC_LORA_1_0)) == 0)
+ lora_hw_version = MTAC_LORA_1_0;
+ else {
+ log_error("Unknown hw-version in port %d", port);
return false;
}
- attr->show = mts_attr_show_ap_gpio_pin;
- attr->store = mts_attr_store_ap_gpio_pin;
- attrs[index++] = &attr->attr;
+
+ // add reset line attribute for MTAC_LORA_0_0
+ if (lora_hw_version == MTAC_LORA_0_0) {
+ sprintf(buf, "reset");
+ attr = create_attribute(buf, MTS_ATTR_MODE_RW);
+ if (! attr) {
+ log_error("failed to create attribute [%s] for LORA in port %d", buf, port);
+ return false;
+ }
+ attr->show = mts_attr_show_ap_gpio_pin;
+ attr->store = mts_attr_store_ap_gpio_pin;
+ attrs[index++] = &attr->attr;
+ }
// add attributes for eeprom contents
- if (! ap_add_product_info_attributes(port, MTAC_LORA_0_0, attrs, &index)) {
+ if (! ap_add_product_info_attributes(port, lora_hw_version, attrs, &index)) {
log_error("failed to add product info attributes for LORA in port %d", port);
return false;
}