Permalink
Browse files

wmbus-repeater: add a new mode to retain the Amber wireless USB adapt…

…er mode
  • Loading branch information...
1 parent 1f47fe6 commit ff541238597bbf3a46f44416ce9551d8a3edbae8 @ffainelli committed Oct 19, 2012
View
@@ -5,7 +5,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=wmbus-repeater
-PKG_RELEASE:=3
+PKG_RELEASE:=4
include $(INCLUDE_DIR)/package.mk
@@ -1,4 +1,4 @@
config wmbus-repeater
option device "/dev/ttyUSB0"
option interface "eth0"
- option mode "S1" # S1, S2, T1meter, T1other, T2meter, T2other
+ option mode "S1" # S1, S2, T1meter, T1other, T2meter, T2other, retain
@@ -12,6 +12,8 @@ start_service() {
config_get device $section device
config_get iface $section interface
+ [ -z $mode ] && mode="retain"
+
$NAME -d $device -i $iface $mode &
}
@@ -54,6 +54,7 @@ tWMBUS_MODE mapStringToWMbusMode(const char *mode)
if(!strcasecmp(mode, "T1other")) return mode_T1other;
if(!strcasecmp(mode, "T2meter")) return mode_T2meter;
if(!strcasecmp(mode, "T2other")) return mode_T2other;
+ if(!strcasecmp(mode, "retain")) return mode_retain;
return mode_unknown;
}
@@ -112,7 +113,10 @@ int amber_open(const char *devname, const char *szWMbusMode)
obuf[3] = 0x46; // cfg register
obuf[4] = 0x01; // len
obuf[5] = wmbus_mode; // mode
- amber_write_command(obuf, 6);
+ if (wmbus_mode != mode_retain)
+ amber_write_command(obuf, 6);
+ else
+ printf("Not changing adapter mode\n");
sleep(1);
tcflush(cfg_fd, TCIFLUSH); // kill cmd reply
@@ -25,7 +25,8 @@ typedef enum
mode_T1meter = 0x05,
mode_T1other = 0x06,
mode_T2meter = 0x07,
- mode_T2other = 0x08
+ mode_T2other = 0x08,
+ mode_retain = 0xff
} tWMBUS_MODE;
int amber_open(const char *devname, const char *mode);
@@ -117,7 +117,7 @@ static time_t send_timed_buffers(void)
static int usage(const char *name)
{
printf("Usage: %s -d <device path> <wM-Bus mode>\n", name);
- printf(" wM-Bus mode can be: S1, S2, T1meter, T1other, T2meter, T2other\n");
+ printf(" wM-Bus mode can be: S1, S2, T1meter, T1other, T2meter, T2other, retain\n");
return -1;
}

0 comments on commit ff54123

Please sign in to comment.