diff --git a/ami_tool/Makefile b/ami_tool/Makefile index ff74b3e26..f7d3a17c8 100644 --- a/ami_tool/Makefile +++ b/ami_tool/Makefile @@ -24,7 +24,7 @@ MAKE_FLAGS += TARGET="$(target)" define Package/ami CATEGORY:=Utilities - DEPENDS:= +luci +libubox +ubus + DEPENDS:= +libuci +libubox +ubus TITLE:=Asterisk management interface listener endef diff --git a/asterisk-1.8.x-mod/Makefile b/asterisk-1.8.x-mod/Makefile index 14065f0f9..7ce1a6967 100644 --- a/asterisk-1.8.x-mod/Makefile +++ b/asterisk-1.8.x-mod/Makefile @@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=asterisk18-mod PKG_VERSION:=1.8.10.1 -PKG_SOURCE_VERSION:=4f7537d7eb602f5fda9b61627f50a5442fc93377 +PKG_SOURCE_VERSION:=02833e56ae32b258a9b1508315ab6f3e8a839d32 PKG_SOURCE_PROTO:=git ifeq ($(CONFIG_PACKAGE_bcmkernel),y) PKG_SOURCE_URL:=git@ihgsp.inteno.se:asterisk-aa @@ -195,7 +195,7 @@ endef define Package/asterisk18-mod-chan-mobile $(call Package/asterisk18-mod/Default) TITLE:=Mobile channel support - DEPENDS:= asterisk18-mod +bluez-libs + DEPENDS:= asterisk18-mod +bluez endef define Package/asterisk18-mod-chan-mobile/description diff --git a/bcmkernel/416030.mk b/bcmkernel/416030.mk index 903be50c7..e3dd228af 100644 --- a/bcmkernel/416030.mk +++ b/bcmkernel/416030.mk @@ -15,12 +15,11 @@ PKG_RELEASE:=$(BRCM_SDK_VERSION) PKG_SOURCE_URL:=git@iopsys.inteno.se:bcmkernel-4.16L.03 PKG_SOURCE_PROTO:=git -PKG_SOURCE_VERSION:=dac270de1d80552e7bc39a8dc8980532948eba81 +PKG_SOURCE_VERSION:=c4c9a8a4408fa7bed4d47c3f159d0d6ef306abaa PKG_SOURCE:=$(PKG_NAME)-$(BRCM_SDK_VERSION)-$(PKG_SOURCE_VERSION).tar.gz PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) - include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/image.mk include $(INCLUDE_DIR)/kernel.mk diff --git a/bcmkernel/Makefile b/bcmkernel/Makefile index a5358f593..d7ce7af4b 100644 --- a/bcmkernel/Makefile +++ b/bcmkernel/Makefile @@ -40,5 +40,10 @@ PKG_VERSION:=none include $(INCLUDE_DIR)/package.mk endif +# hack to be able to compile just the userspace part. +# TOPDIR=$PWD make -C package/bcmkernel userspace +userspace: + $(call Build/Compile/Default, userspace) + $(eval $(call BuildPackage,bcmkernel)) diff --git a/dectmngr/Makefile b/dectmngr/Makefile index 3f814b97d..431325888 100644 --- a/dectmngr/Makefile +++ b/dectmngr/Makefile @@ -8,14 +8,14 @@ include $(TOPDIR)/rules.mk PKG_RELEASE:=1 -PKG_VERSION:=1.0.23 +PKG_VERSION:=1.0.22 ifeq ($(CONFIG_PACKAGE_bcmkernel),y) PKG_SOURCE_URL:=git@iopsys.inteno.se:dectmngr.git else PKG_SOURCE_URL:=http://ihgsp.inteno.se/git/dectmngr.git endif PKG_SOURCE_PROTO:=git -PKG_SOURCE_VERSION:=5f6f0608b59484d76c6331279cc50104be5d8a95 +PKG_SOURCE_VERSION:=30b15dc5533c1dcdea89fb245e9521a7abc4c8e0 PKG_NAME:=dectmngr diff --git a/dectmngr/files/etc/config/dect b/dectmngr/files/etc/config/dect new file mode 100755 index 000000000..23628de49 --- /dev/null +++ b/dectmngr/files/etc/config/dect @@ -0,0 +1,3 @@ +config dect 'dect' + option 'radio' '0' + diff --git a/ice-client/Makefile b/ice-client/Makefile index 6546de666..edd45bcfb 100644 --- a/ice-client/Makefile +++ b/ice-client/Makefile @@ -15,15 +15,15 @@ export PLATFORM_INCLUDE:=platforms/iopsys/build.mk export DATE:=$(shell date +%Y-%m-%d-%H-%M-%S) export LOGIN:=$(shell whoami) -BASE_PKG_VERSION:=3.2.0 -PKG_RELEASE:=RC1 +BASE_PKG_VERSION:=3.2.1 +PKG_RELEASE:=RC5 PKG_VERSION:=$(BASE_PKG_VERSION)-$(PKG_RELEASE)_$(DATE)_$(LOGIN) export PKG_VERSION ###########################--RELEASE--################################ PKG_SOURCE_URL:=ssh://git@iopsys.inteno.se/ice-client.git -PKG_SOURCE_VERSION:=1f95ce3d1eff1b2403a2357d0fa45063e56ff5e2 +PKG_SOURCE_VERSION:=3d30f42c057d2c120bce66c7c028a2238c7a5ccc PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(BASE_PKG_VERSION) PKG_SOURCE:=$(PKG_NAME)-$(BASE_PKG_VERSION)-$(PKG_RELEASE).tar.gz @@ -884,6 +884,78 @@ fi exit 0 endef +# torrent +define Package/ice-client-torrent + $(call Package/ice-client/Default) + TITLE:=torrent + DEPENDS+= +boost-system +# boost Boost C++ source libraries (header-only) +# boost-chrono Boost C++ source libraries (chrono) +# boost-date_time Boost C++ source libraries (date_time) +# boost-filesystem Boost C++ source libraries (filesystem) +# boost-graph Boost C++ source libraries (graph) +# boost-iostreams Boost C++ source libraries (iostreams) +# boost-locale Boost C++ source libraries (locale) +# boost-math Boost C++ source libraries (math) +# boost-program_options Boost C++ source libraries (program_options) +# boost-python Boost C++ source libraries (python) +# boost-random Boost C++ source libraries (random) +# boost-regex Boost C++ source libraries (regex) +# boost-serialization Boost C++ source libraries (serialization) +# boost-signals Boost C++ source libraries (signals) +# boost-timer Boost C++ source libraries (timer) +#boost-wave Boost C++ source libraries (wave) + +endef + +define Package/ice-client-torrent/description +torrent module for ice-client +endef + +define Package/ice-client-torrent/prerm +#!/bin/sh +if [ -z "$${IPKG_INSTROOT}" ]; then + if [ ! -f "/tmp/ice.pid" ] ; then exit 0 ; fi + PROC_ID=$$(cat /tmp/ice.pid) + PROC_EXISTS=$$(/usr/bin/pgrep -P $${PROC_ID}) + if [ -n "$$PROC_EXISTS" ]; then + read -t 1 <>/tmp/cfout + echo "system moduleRemove topic=torrentMgr" > /tmp/cfin + fi +fi +exit 0 +endef + +define Package/ice-client-torrent/preinst +#!/bin/sh +if [ -z "$${IPKG_INSTROOT}" ]; then + if [ ! -f "/tmp/ice.pid" ] ; then exit 0 ; fi + PROC_ID=$$(cat /tmp/ice.pid) + PROC_EXISTS=$$(/usr/bin/pgrep -P $${PROC_ID}) + if [ -n "$$PROC_EXISTS" ]; then + read -t 1 <>/tmp/cfout + echo "system moduleRemove topic=torrentMgr" > /tmp/cfin + fi +fi +exit 0 +endef + +define Package/ice-client-torrent/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_BUILD_DIR)/core/lib/torrentService.so.1.0.1 $(1)/usr/lib +endef + +define Package/ice-client-torrent/postinst +#!/bin/sh +if [ -z "$${IPKG_INSTROOT}" ]; then + read -t 1 <>/tmp/cfout + if [ -f /tmp/ice.pid ]; then + echo "system moduleAdd file=torrentService.so.1.0.1" package="ice-client-torrent" > /tmp/cfin + fi +fi +exit 0 +endef + # This line executes the necessary commands to compile our program. # The above define directives specify all the information needed, but this # line calls BuildPackage which in turn actually uses this information to @@ -903,4 +975,3 @@ $(eval $(call BuildPackage,ice-client-rework)) $(eval $(call BuildPackage,ice-client-sip)) $(eval $(call BuildPackage,ice-client-monitor)) $(eval $(call BuildPackage,ice-client-torrent)) -$(eval $(call BuildPackage,ice-client-gigaset)) diff --git a/luci/luci/Makefile b/luci/luci/Makefile index f815bf27b..ca99646dc 100644 --- a/luci/luci/Makefile +++ b/luci/luci/Makefile @@ -2,8 +2,8 @@ include $(TOPDIR)/rules.mk PKG_BRANCH:=svn-0.11 PKG_NAME:=luci -PKG_VERSION:=inteno-1.0.169 -PKG_SOURCE_VERSION:=e5300da360d4ecfa050cc3fb3e3be8e962b36023 +PKG_VERSION:=inteno-1.0.177 +PKG_SOURCE_VERSION:=3ff56917cb976de42ebeab9bf8c049f45183ff04 PKG_SOURCE_PROTO:=git ifeq ($(CONFIG_PACKAGE_bcmkernel),y) diff --git a/peripheral_manager/src/Makefile.am b/peripheral_manager/src/Makefile.am index a2dae9fb8..cd238779e 100644 --- a/peripheral_manager/src/Makefile.am +++ b/peripheral_manager/src/Makefile.am @@ -18,6 +18,7 @@ peripheral_manager_SOURCES = \ src/button.c \ src/sim_button.c \ src/catv.c \ + src/catv_monitor.c \ src/catv.h \ src/smbus.c \ src/smbus.h \ diff --git a/peripheral_manager/src/src/catv.c b/peripheral_manager/src/src/catv.c index cb7a48a91..e64eb211a 100644 --- a/peripheral_manager/src/src/catv.c +++ b/peripheral_manager/src/src/catv.c @@ -996,7 +996,7 @@ static int catv_set_filter_method(struct ubus_context *ubus_ctx, struct ubus_obj enum { STATUS_RF_ENABLE }; -static const struct blobmsg_policy enable_policy[] = { +static const struct blobmsg_policy set_enable_policy[] = { [STATUS_RF_ENABLE] = { .name = "enable", .type = BLOBMSG_TYPE_STRING }, }; @@ -1020,9 +1020,9 @@ static int catv_set_enable_method(struct ubus_context *ubus_ctx, struct ubus_obj struct blob_attr *msg) { struct blob_buf b; - struct blob_attr *tb[ARRAY_SIZE(enable_policy)]; + struct blob_attr *tb[ARRAY_SIZE(set_enable_policy)]; - blobmsg_parse(enable_policy, ARRAY_SIZE(enable_policy) , tb, blob_data(msg), blob_len(msg)); + blobmsg_parse(set_enable_policy, ARRAY_SIZE(set_enable_policy) , tb, blob_data(msg), blob_len(msg)); if (tb[STATUS_RF_ENABLE]) { @@ -1217,7 +1217,6 @@ static int catv_get_all_method(struct ubus_context *ubus_ctx, struct ubus_object { struct blob_buf b; int ret = 0; - memset(&b, 0, sizeof(b)); blob_buf_init (&b, 0); @@ -1280,8 +1279,8 @@ static const struct ubus_method catv_methods[] = { { .name = "alarm", .handler = catv_get_alarm_method }, { .name = "get-all", .handler = catv_get_all_method }, - { .name = "set-filter", .handler = catv_set_filter_method }, - { .name = "set-enable", .handler = catv_set_enable_method }, + UBUS_METHOD("set-filter", catv_set_filter_method, filter_policy), + UBUS_METHOD("set-enable", catv_set_enable_method, set_enable_policy), { .name = "save", .handler = catv_save_method }, }; diff --git a/peripheral_manager/src/src/catv_monitor.c b/peripheral_manager/src/src/catv_monitor.c new file mode 100644 index 000000000..b6c0699bc --- /dev/null +++ b/peripheral_manager/src/src/catv_monitor.c @@ -0,0 +1,242 @@ +#include +#include "log.h" + +#include "server.h" + +#include "libubus.h" +#include +#include +#include "ucix.h" + +typedef enum { + STATE_OFF, + STATE_OK, + STATE_NOTICE, + STATE_ALERT, + STATE_ERROR, +}state_t; + +state_t state; + +static struct ubus_context *ubus_ctx; +static char *ubus_socket; + +#define CATV_MONITOR_TIME (1000 * 10) /* 10 sec in ms */ + +void catv_monitor_init(struct server_ctx *s_ctx); +void catv_monitor_set_socket(char *socket_name); + +static void set_led(state_t state); +static int is_enabled(void); + +static void catv_monitor_handler(struct uloop_timeout *timeout); +struct uloop_timeout catv_monitor_timer = { .cb = catv_monitor_handler }; + +static void +catv_status_cb(struct ubus_request *req, int type, struct blob_attr *msg) +{ + struct blob_attr *cur; + uint32_t rem; + const char *data; + + rem = blob_len(msg); + + __blob_for_each_attr(cur, blob_data(msg), rem) { + if (!strcmp("RF enable", blobmsg_name(cur))) { + data = blobmsg_data(cur); + if (!strncasecmp("on", data, 2)) + *(int*)req->priv = 1; + return; + } + } + *(int*)req->priv = 0; + return; +} + +static int is_enabled(void) +{ + uint32_t id; + struct blob_buf b; + int enabled = 0; + int ret; + + if (ubus_lookup_id(ubus_ctx, "catv", &id)) { + DBG(1, "Failed to look up catv object\n"); + return 0; + } + + memset(&b, 0, sizeof(struct blob_buf)); + blob_buf_init(&b, 0); + + ret = ubus_invoke(ubus_ctx, id, "status", b.head, catv_status_cb, &enabled, 3000); + + if (ret) + DBG(1,"catv_monitor: ret = %s", ubus_strerror(ret)); + + return enabled; +} + +static void +catv_vpd_cb(struct ubus_request *req, int type, struct blob_attr *msg) +{ + struct blob_attr *cur; + uint32_t rem; + const char *data = "-inf"; + + rem = blob_len(msg); + + /* no response */ + if ( rem == 0 ) { + state = STATE_ERROR; + return; + } + + __blob_for_each_attr(cur, blob_data(msg), rem) { + if (!strcmp("VPD", blobmsg_name(cur))) { + data = blobmsg_data(cur); + } + } + + /* no cable */ + if (!strcmp("-inf", data)) { + state = STATE_ERROR; + } +} + +static void +catv_alarm_cb(struct ubus_request *req, int type, struct blob_attr *msg) +{ + struct blob_attr *cur; + uint32_t rem; + const char *data = "-inf"; + + rem = blob_len(msg); + + /* no response */ + if ( rem == 0 ) { + state = STATE_ERROR; + return; + } + + __blob_for_each_attr(cur, blob_data(msg), rem) { + if (!strcasecmp("Alarm VPD HI", blobmsg_name(cur))) { + data = blobmsg_data(cur); + /* if on */ + if (!strcmp("on", data)) { + state = STATE_ALERT; + } + }else if (!strcasecmp("Alarm VPD LO", blobmsg_name(cur))) { + data = blobmsg_data(cur); + /* if on */ + if (!strcmp("on", data)) { + state = STATE_ALERT; + } + }else if (!strcasecmp("Warning VPD HI", blobmsg_name(cur))) { + data = blobmsg_data(cur); + /* if on */ + if (!strcmp("on", data)) { + state = STATE_NOTICE; + } + }else if (!strcasecmp("Warning VPD LO", blobmsg_name(cur))) { + data = blobmsg_data(cur); + /* if on */ + if (!strcmp("on", data)) { + state = STATE_NOTICE; + } + } + } +} + + +static void catv_monitor_handler(struct uloop_timeout *timeout) +{ + uint32_t id; + struct blob_buf b; + int ret; + + /* start to set new state to OK */ + /* then checks turn on different errors */ + state = STATE_OK; + + if (is_enabled()) { + + if (ubus_lookup_id(ubus_ctx, "catv", &id)) { + DBG(1, "Failed to look up catv object\n"); + return; + } + + memset(&b, 0, sizeof(struct blob_buf)); + blob_buf_init(&b, 0); + + /* first check alarms, they set notice/alert if present */ + ret = ubus_invoke(ubus_ctx, id, "alarm", b.head, catv_alarm_cb, 0, 3000); + if (ret) + DBG(1,"ret = %s", ubus_strerror(ret)); + + /* then check cable in, it sets Error,*/ + ret = ubus_invoke(ubus_ctx, id, "vpd", b.head, catv_vpd_cb, 0, 3000); + if (ret) + DBG(1,"ret = %s", ubus_strerror(ret)); + }else + state = STATE_OFF; + + set_led(state); + + uloop_timeout_set(&catv_monitor_timer, CATV_MONITOR_TIME); +} + +static void set_led(state_t lstate) +{ + uint32_t id; + struct blob_buf b; + int ret; + static state_t old_state = -1; + + if ( lstate == old_state ) + return; + old_state = lstate; + + memset(&b, 0, sizeof(struct blob_buf)); + blob_buf_init(&b, 0); + + switch (lstate) { + case STATE_OFF: + blobmsg_add_string(&b, "state", "off"); break; + case STATE_OK: + blobmsg_add_string(&b, "state", "ok"); break; + case STATE_NOTICE: + blobmsg_add_string(&b, "state", "notice"); break; + case STATE_ALERT: + blobmsg_add_string(&b, "state", "alert"); break; + case STATE_ERROR: + blobmsg_add_string(&b, "state", "error"); break; + } + + if (ubus_lookup_id(ubus_ctx, "led.ext", &id)) { + DBG(1, "Failed to look up led.ext object\n"); + return; + } + + ret = ubus_invoke(ubus_ctx, id, "set", b.head, NULL, 0, 3000); + + if ( ret ) + DBG(1,"catv_moitor: set led failed [%s]", ubus_strerror(ret)); +} + +void catv_monitor_init(struct server_ctx *s_ctx) +{ + ubus_ctx = ubus_connect(ubus_socket); + if (!ubus_ctx) { + syslog(LOG_ERR,"catv monitor: Failed to connect to ubus\n"); + return; + } + + /* start monitor timer */ + uloop_timeout_set(&catv_monitor_timer, CATV_MONITOR_TIME); +} + +void catv_monitor_set_socket(char *socket_name) +{ + if (socket_name) + ubus_socket = strdup(socket_name); +} diff --git a/peripheral_manager/src/src/led.c b/peripheral_manager/src/src/led.c index 50d55714e..a9db31634 100644 --- a/peripheral_manager/src/src/led.c +++ b/peripheral_manager/src/src/led.c @@ -7,6 +7,7 @@ static struct blob_buf bblob; typedef enum { LED_OFF, LED_OK, + LED_EOK, LED_NOTICE, LED_ALERT, LED_ERROR, @@ -29,15 +30,15 @@ typedef enum { /* Names for led_action_t */ static const char * const fn_actions[LED_ACTION_MAX] = -{ "off", "ok", "notice", "alert", "error", "custom"}; +{ "off", "ok", "eok", "notice", "alert", "error", "custom"}; -#define LED_FUNCTIONS 17 +#define LED_FUNCTIONS 20 static const char* const led_functions[LED_FUNCTIONS] = { "dsl", "wifi", "wps", "lan", "status", "dect", "tv", "usb", "wan", "internet", "voice1", "voice2", "eco", "gbe", "ext", "wan_phy_speed", - "wan_phy_link" }; + "wan_phy_link","gbe_phy_speed","gbe_phy_link","cancel" }; /* Names for led_state_t */ static const char* const led_states[LED_STATES_MAX] = @@ -227,30 +228,36 @@ static void dump_led(void) led_states[led->state]); }}}}} -static void set_function_led(const char* fn_name, const char* action) { +/* return 0 = OK, -1 = error */ +static int set_function_led(const char* fn_name, const char* action) { int led_idx = get_index_by_name(led_functions, LED_FUNCTIONS , fn_name); int act_idx = get_index_by_name(fn_actions , LED_ACTION_MAX, action ); if(led_idx == -1) { syslog(LOG_WARNING, "called over ubus with non valid led name [%s]", fn_name); - return; + return -1; } if(act_idx == -1) { syslog(LOG_WARNING, "called over ubus with non valid action [%s] for led [%s]", action, fn_name); - return; + return -1; } - leds[led_idx].state = act_idx; - if ( leds[led_idx].actions[act_idx].name != NULL ) { struct led *led; + + leds[led_idx].state = act_idx; + list_for_each_entry(led, &leds[led_idx].actions[act_idx].led_list, list) { if (led->drv){ led->drv->func->set_state(led->drv, led->state); } } - }else + }else { syslog(LOG_WARNING, "led set on [%s] has no valid [%s] handler registered.", fn_name, action); + return -1; + } + + return 0; } enum { @@ -276,9 +283,13 @@ static int led_set_method(struct ubus_context *ubus_ctx, struct ubus_object *obj state = blobmsg_data(tb[LED_STATE]); DBG(1,"set led [%s]->[%s]", fn_name, state); // syslog(LOG_INFO, "Led %s method: %s state %s", fn_name, method, state); - set_function_led(fn_name, state); - }else + if (set_function_led(fn_name, state) ){ + return UBUS_STATUS_NO_DATA; + } + }else { DBG(1,"(%s) not implemented",method); + return UBUS_STATUS_NO_DATA; + } return 0; } @@ -340,7 +351,7 @@ static int leds_set_method(struct ubus_context *ubus_ctx, struct ubus_object *ob DBG(1,"led global state set to [%s] wanted [%s]", leds_states[global_state], state); }else - syslog(LOG_WARNING, "Unknown attribute [%s]", blob_data(msg)); + syslog(LOG_WARNING, "Unknown attribute [%s]", (char *)blob_data(msg)); return 0; } @@ -396,6 +407,9 @@ static struct ubus_object led_objects[LED_OBJECTS] = { { .name = "led.ext", .type = &led_object_type, .methods = led_methods, .n_methods = ARRAY_SIZE(led_methods), }, { .name = "led.wan_phy_speed", .type = &led_object_type, .methods = led_methods, .n_methods = ARRAY_SIZE(led_methods), }, { .name = "led.wan_phy_link", .type = &led_object_type, .methods = led_methods, .n_methods = ARRAY_SIZE(led_methods), }, + { .name = "led.gbe_phy_speed", .type = &led_object_type, .methods = led_methods, .n_methods = ARRAY_SIZE(led_methods), }, + { .name = "led.gbe_phy_link", .type = &led_object_type, .methods = led_methods, .n_methods = ARRAY_SIZE(led_methods), }, + { .name = "led.cancel", .type = &led_object_type, .methods = led_methods, .n_methods = ARRAY_SIZE(led_methods), }, }; diff --git a/peripheral_manager/src/src/log.h b/peripheral_manager/src/src/log.h index 86f1b4a16..f4d1c37df 100644 --- a/peripheral_manager/src/src/log.h +++ b/peripheral_manager/src/src/log.h @@ -1,6 +1,7 @@ #ifndef LOG_H #define LOG_H /* Use this */ +#include extern int debug_level; diff --git a/peripheral_manager/src/src/peripheral_manager.c b/peripheral_manager/src/src/peripheral_manager.c index 8b59e7442..4521eedda 100644 --- a/peripheral_manager/src/src/peripheral_manager.c +++ b/peripheral_manager/src/src/peripheral_manager.c @@ -23,6 +23,8 @@ static const char *config_file = "hw"; static char *ubus_socket; +void catv_monitor_set_socket(char *); + void print_usage(char *prg_name); void print_usage(char *prg_name) { @@ -137,9 +139,9 @@ int main(int argc, char **argv) exit(EXIT_FAILURE); } /* Close out the standard file descriptors */ - //close(STDIN_FILENO); - //close(STDOUT_FILENO); - //close(STDERR_FILENO); + close(STDIN_FILENO); + close(STDOUT_FILENO); + close(STDERR_FILENO); } /* open configuration file */ @@ -163,6 +165,8 @@ int main(int argc, char **argv) } ubus_add_uloop(ubus_ctx); + catv_monitor_set_socket(ubus_socket); + server_start(uci_ctx, ubus_ctx); ubus_free(ubus_ctx); diff --git a/peripheral_manager/src/src/server.c b/peripheral_manager/src/src/server.c index caa5ccbfb..de5892843 100644 --- a/peripheral_manager/src/src/server.c +++ b/peripheral_manager/src/src/server.c @@ -16,6 +16,8 @@ void sim_button_init(struct server_ctx *); void gpio_led_init(struct server_ctx *); void gpio_button_init(struct server_ctx *); +void catv_monitor_init(struct server_ctx *); + struct catv_handler *catv_h; struct sfp_handler *sfp_h; @@ -52,6 +54,8 @@ void server_start(struct uci_context *uci_ctx, struct ubus_context *ubus_ctx) catv_ubus_populate(catv_h, ubus_ctx); } + catv_monitor_init(&server); + DBG(1, "give control to uloop main loop."); uloop_run(); } diff --git a/peripheral_manager/src/src/sfp.c b/peripheral_manager/src/src/sfp.c index 7d8d1bccf..c77919b01 100644 --- a/peripheral_manager/src/src/sfp.c +++ b/peripheral_manager/src/src/sfp.c @@ -973,7 +973,7 @@ static int sfp_ddm_get_rx_pwr(struct blob_buf *b, int raw) /* NOTE: There's only a single word to read. It's unclear how to get several values. However, typically, rx_pwr[2,3,4] are zero. */ - if (sfp_ddm.rx_pwr[i] != 0.0) { + if (sfp_ddm.rx_pwr[i] > 0.0 || sfp_ddm.rx_pwr[i] < 0.0) { /* sfp_ddm.rx_pwr[i] != 0.0 */ if (!sfp_ddm_read_ui(&v, 104)) return 0; x += v*sfp_ddm.rx_pwr[i]; @@ -1011,7 +1011,7 @@ static int sfp_ddm_get_all_method(struct ubus_context *ubus_ctx, struct ubus_obj memset(&b, 0, sizeof(struct blob_buf)); blob_buf_init (&b, 0); - sfp_ddm_get_temperature(&b, 0); + //sfp_ddm_get_temperature(&b, 0); sfp_ddm_get_voltage(&b, 0); sfp_ddm_get_current(&b, 0); sfp_ddm_get_tx_pwr(&b, 0); @@ -1044,7 +1044,7 @@ static struct ubus_object_type sfp_rom_type = static const struct ubus_method sfp_ddm_methods[] = { { .name = "get-rx-pwr", .handler = sfp_ddm_get_rx_pwr_method }, { .name = "get-tx-pwr", .handler = sfp_ddm_get_tx_pwr_method }, - { .name = "get-temperature", .handler = sfp_ddm_get_temperature_method }, + //{ .name = "get-temperature", .handler = sfp_ddm_get_temperature_method }, { .name = "get-current", .handler = sfp_ddm_get_current_method }, { .name = "get-voltage", .handler = sfp_ddm_get_voltage_method }, { .name = "get-all", .handler = sfp_ddm_get_all_method }, diff --git a/questd/src/arping.c b/questd/src/arping.c index e5c7d68fa..24bcdbb4e 100644 --- a/questd/src/arping.c +++ b/questd/src/arping.c @@ -102,7 +102,7 @@ recv_pack(char *buf, int len, struct sockaddr_ll *FROM) bool -arping(char *targetIP, char *device) +arping(char *targetIP, char *device, int toms) { struct sockaddr_in saddr; struct ifreq ifr; @@ -150,7 +150,6 @@ arping(char *targetIP, char *device) struct sockaddr_ll from; socklen_t alen = sizeof(from); bool connected = false; - long tmo = 500000; int cc = -1; fd_set read_fds, write_fds, except_fds; @@ -161,7 +160,7 @@ arping(char *targetIP, char *device) struct timeval timeout; timeout.tv_sec = 0; - timeout.tv_usec = tmo; + timeout.tv_usec = toms * 1000; if (select(sock_fd + 1, &read_fds, &write_fds, &except_fds, &timeout) == 1) { @@ -173,8 +172,5 @@ arping(char *targetIP, char *device) close(sock_fd); - if (!connected) - recalc_sleep_time(true, tmo); - return connected; } diff --git a/questd/src/questd.c b/questd/src/questd.c index 66bac3112..01502e822 100644 --- a/questd/src/questd.c +++ b/questd/src/questd.c @@ -347,20 +347,32 @@ handle_client(Client *clnt) } static bool -wireless_sta(Client *clnt) +wireless_sta(Client *clnt, Detail *dtl) { FILE *stainfo; char cmnd[64]; char line[128]; int i = 0; bool there = false; + char tab[16]; + int ret, tmp; for (i = 0; wireless[i].device; i++) { - sprintf(cmnd, "wlctl -i %s sta_info %s 2>/dev/null | grep ASSOCIATED", wireless[i].vif, clnt->macaddr); + sprintf(cmnd, "wlctl -i %s sta_info %s 2>/dev/null", wireless[i].vif, clnt->macaddr); if ((stainfo = popen(cmnd, "r"))) { - if(fgets(line, sizeof(line), stainfo) != NULL) { - there = true; - strncpy(clnt->wdev, wireless[i].vif, sizeof(clnt->wdev)); + while(fgets(line, sizeof(line), stainfo) != NULL) + { + remove_newline(line); + if(sscanf(line, "%sstate: AUTHENTICATED ASSOCIATED AUTHORIZED", tab)) { + there = true; + strncpy(clnt->wdev, wireless[i].vif, sizeof(clnt->wdev)); + } + ret = sscanf(line, "\t idle %d seconds", &(dtl->idle)); + ret = sscanf(line, "\t in network %d seconds", &(dtl->in_network)); + ret = sscanf(line, "\t tx total bytes: %ld\n", &(dtl->tx_bytes)); + ret = sscanf(line, "\t rx data bytes: %ld", &(dtl->rx_bytes)); + ret = sscanf(line, "\t rate of last tx pkt: %d kbps - %d kbps", &tmp, &(dtl->tx_rate)); + ret = sscanf(line, "\t rate of last rx pkt: %d kbps", &(dtl->rx_rate)); } pclose(stainfo); } @@ -382,6 +394,7 @@ populate_clients() char mask[64]; int i; bool there; + int toms = 1000; memset(clients_new, '\0', sizeof(clients)); @@ -396,10 +409,10 @@ populate_clients() clients[cno].exists = true; clients[cno].dhcp = true; handle_client(&clients[cno]); - if((clients[cno].connected = wireless_sta(&clients[cno]))) + if((clients[cno].connected = wireless_sta(&clients[cno], &details[cno]))) clients[cno].wireless = true; - else - clients[cno].connected = arping(clients[cno].hostaddr, clients[cno].device); + else if(!(clients[cno].connected = arping(clients[cno].hostaddr, clients[cno].device, toms))) + recalc_sleep_time(true, toms); cno++; } } @@ -434,10 +447,10 @@ populate_clients() if(clients[cno].local) { clients[cno].exists = true; clients[cno].dhcp = false; - if((clients[cno].connected = wireless_sta(&clients[cno]))) + if((clients[cno].connected = wireless_sta(&clients[cno], &details[cno]))) clients[cno].wireless = true; - else - clients[cno].connected = arping(clients[cno].hostaddr, clients[cno].device); + else if(!(clients[cno].connected = arping(clients[cno].hostaddr, clients[cno].device, toms))) + recalc_sleep_time(true, toms); cno++; } } @@ -484,6 +497,7 @@ populate_clients6() char line[512]; int cno = 0; int iaid, ts, id, length; + int toms = 500; if ((hosts6 = fopen("/tmp/hosts/6relayd", "r"))) { while(fgets(line, sizeof(line), hosts6) != NULL) @@ -495,8 +509,8 @@ populate_clients6() if (sscanf(line, "# %s %s %d %s %d %x %d %s", clients6[cno].device, clients6[cno].duid, &iaid, clients6[cno].hostname, &ts, &id, &length, clients6[cno].ip6addr)) { clients6[cno].exists = true; clear_macaddr(); - if(!(clients6[cno].connected = ndisc (clients6[cno].hostname, clients6[cno].device, 0x8, 1, 500))) - recalc_sleep_time(true, 500000); + if(!(clients6[cno].connected = ndisc (clients6[cno].hostname, clients6[cno].device, 0x8, 1, toms))) + recalc_sleep_time(true, toms); sprintf(clients6[cno].macaddr, get_macaddr()); if(clients6[cno].connected && wireless_sta6(&clients6[cno])) clients6[cno].wireless = true; @@ -679,6 +693,12 @@ router_dump_clients(struct blob_buf *b) blobmsg_add_u8(b, "wireless", clients[i].wireless); if(clients[i].wireless) { blobmsg_add_string(b, "wdev", clients[i].wdev); + blobmsg_add_u32(b, "idle", details[i].idle); + blobmsg_add_u32(b, "in_network", details[i].in_network); + blobmsg_add_u64(b, "tx_bytes", details[i].tx_bytes); + blobmsg_add_u64(b, "rx_bytes", details[i].rx_bytes); + blobmsg_add_u32(b, "tx_rate", details[i].tx_rate); + blobmsg_add_u32(b, "rx_rate", details[i].rx_rate); } blobmsg_close_table(b, t); num++; @@ -709,6 +729,12 @@ router_dump_connected_clients(struct blob_buf *b) blobmsg_add_u8(b, "wireless", clients[i].wireless); if(clients[i].wireless) { blobmsg_add_string(b, "wdev", clients[i].wdev); + blobmsg_add_u32(b, "idle", details[i].idle); + blobmsg_add_u32(b, "in_network", details[i].in_network); + blobmsg_add_u64(b, "tx_bytes", details[i].tx_bytes); + blobmsg_add_u64(b, "rx_bytes", details[i].rx_bytes); + blobmsg_add_u32(b, "tx_rate", details[i].tx_rate); + blobmsg_add_u32(b, "rx_rate", details[i].rx_rate); } blobmsg_close_table(b, t); num++; @@ -740,6 +766,12 @@ router_dump_network_clients(struct blob_buf *b, char *net) blobmsg_add_u8(b, "wireless", clients[i].wireless); if(clients[i].wireless) { blobmsg_add_string(b, "wdev", clients[i].wdev); + blobmsg_add_u32(b, "idle", details[i].idle); + blobmsg_add_u32(b, "in_network", details[i].in_network); + blobmsg_add_u64(b, "tx_bytes", details[i].tx_bytes); + blobmsg_add_u64(b, "rx_bytes", details[i].rx_bytes); + blobmsg_add_u32(b, "tx_rate", details[i].tx_rate); + blobmsg_add_u32(b, "rx_rate", details[i].rx_rate); } blobmsg_close_table(b, t); num++; @@ -826,6 +858,12 @@ router_dump_stas(struct blob_buf *b) if(strstr(clients[i].device, "br-")) blobmsg_add_string(b, "bridge", clients[i].device); blobmsg_add_string(b, "wdev", clients[i].wdev); + blobmsg_add_u32(b, "idle", details[i].idle); + blobmsg_add_u32(b, "in_network", details[i].in_network); + blobmsg_add_u64(b, "tx_bytes", details[i].tx_bytes); + blobmsg_add_u64(b, "rx_bytes", details[i].rx_bytes); + blobmsg_add_u32(b, "tx_rate", details[i].tx_rate); + blobmsg_add_u32(b, "rx_rate", details[i].rx_rate); blobmsg_close_table(b, t); num++; } @@ -866,6 +904,12 @@ router_dump_wireless_stas(struct blob_buf *b, char *wname, bool vif) blobmsg_add_string(b, "bridge", clients[i].device); if(!vif) blobmsg_add_string(b, "wdev", clients[i].wdev); + blobmsg_add_u32(b, "idle", details[i].idle); + blobmsg_add_u32(b, "in_network", details[i].in_network); + blobmsg_add_u64(b, "tx_bytes", details[i].tx_bytes); + blobmsg_add_u64(b, "rx_bytes", details[i].rx_bytes); + blobmsg_add_u32(b, "tx_rate", details[i].tx_rate); + blobmsg_add_u32(b, "rx_rate", details[i].rx_rate); blobmsg_close_table(b, t); num++; } diff --git a/questd/src/questd.h b/questd/src/questd.h index 2cfbb16b6..ccd262895 100644 --- a/questd/src/questd.h +++ b/questd/src/questd.h @@ -25,6 +25,16 @@ typedef struct { const char *network; } Wireless; +typedef struct { + int idle; + int in_network; + long tx_bytes; + long rx_bytes; + int tx_rate; + int rx_rate; + int rssi; +} Detail; + typedef struct { bool exists; bool local;