DSL Connection Count and LED Status

I have a BT HH5A running v18.06.1 with ADSL2+ connected. I have a little issue that I want to get resolved. It's not really an issue but more like some info how to do it.

Well the situation is, initially the dsl_control startup script was around 97 and I moved it up around 50 so that ADSL loads faster. If I move it down after LEDs' script then green:wifi LED lighs up when DSL starts to sync. But right now no LED lights up when it is syncing. I would like to change the default LED that lights up when DSL is syncing. Is there a way to change this behavior? How can I do this?

Secondly, I would like to know how many times DSL has disconnected and resynced again? Any simple way to achieve this? I dont really want it shown in LuCI, although that will be much better if it gets shown with DSL stats, but using SSH to access the count is also okay.

Thanks

The init sequence numbers are there for a reason, to ensure proper dependency ordering, unless you know why it's safe for you to order it earlier beyond "so that ADSL loads faster", it's a very bad idea to change it. Besides that, booting might take 20s-30s, while link training takes between 2-3 minutes - the ~5s (maybe) gained by ordering dsl_control won't really help you there anyways.

1 Like

I understand your concerns but still I carefully selected the appropriate position for the dsl_control script and it works great. The only thing that is not available is a simple status LED to see when the DSL is synchronizing, in case of a connection drop or resync. I also have a TP-Link TD-W8980 and its status LED works out of box and there's nothing you need to do, so I would like to have something like that for BT HomeHub 5A. If you can point me towards something helpful, that will be great.

  • If you honestly want your lights to behave exactly as the OEM firmware, I'd advise you to revert to OEM.
  • The other option is to see if the OEM offers their source code to the public, then you can then look at how they're programmed "out-of-the-box" - as you say
  • Ask OEM support - see if they will tell you
  • Lastly, perhaps your OEM firmware is base on OpenWrt, and you can look at its filesystem

Well if I wanted to go back to stock I wouldn't need to ask this in the forum here. By the term 'out-of-box' I meant in OpenWrt Tplink TD-W8980 the DSL light behaves in the same way as stock firmware. So I would just like to know if it's possible to change some options or files (if any) to make an LED flash when DSL is syncing to ISPs network.

I didnt say go [permanently] back to stock. ASK THEM OR INQUIRE ON THE FIRMWARE, simple.

I understand what you meant, that's why I made the suggestion.

I told you how to discover what you need, above. But it seems you're somehow under the impression that I said permanently go back to OEM firmware. So, to be clear, I do think it may be possible to accomplish what you wish.

But, you're asking us to guess - when you can look at the OEM firmware for you answers.

1 Like

I really don't get why it would make any significant change. If I look at a stock /etc/rc.d/, I can see no entries at or after S50 that would delay startup in any noticeable manner. If you have some aftermarket package there that delays the boot process, I would lean to move that one back to 99 instead of moving system relevant entries forward.

Also, and please someone CMIIW, /etc/hotplug.d/dsl/dsl_led.sh does not depend on /etc/init.d/led having been run, it accesses the LED configuration directly. So it's entirely possible you mucked up something more fundamental while fiddling with the boot order.

1 Like

A hotplug script in /etc/hotplug.d/dsl/, something in this manner:

#!/bin/sh

if [ "$DSL_NOTIFICATION_TYPE" = "DSL_INTERFACE_STATUS" ] && [ ""$DSL_INTERFACE_STATUS" = "UP" ]; then

# line went up, do something to count here

fi

(untested and obviously incomplete)

1 Like

Well this is the final piece of the puzzle I actually needed to make it work. I was searching here and there but couldn't really find anything to help make it work. Now I can start to fiddle around and see where it gets me.

No I haven't done anything with it plus everything works as it was working before changing the boot order. I'm not sure if you have used a HH5A but it's status LED for DSL doesn't work. I was able to set it up in LEDs configuration but it only turns on when the DSL gets connected because of the netdev trigger.

Update: A little update on the LED issue, I think along the way I may have changed the LED name in the LED config for DSL LED. It should have been named led_dsl while now it was named dsl and in the above file mentioned by @takimata I saw that it was looking for led_dsl in the config so it's working now. Thanks for that.

Just out of sheer curiosity, what do you have between/after S50 that delays the boot process so much it actually makes a difference to move the DSL initialization forward? On a default system there's only miniscule tasks left after S50.

I use OpenVPN with my router but I dont use VPN for all of the traffic just a part of it and for that I am using VPN-Policy-Routing (which is fairly a new package).

This package, kind of, delays boot process and keeps the boot in an ongoing state until it finds WAN/Internet. So I have already moved it to S99 but I also wanted to make the internet connect a little bit early and let the DSL sync to ISP while the router is booting up.

I know it doesnt make much difference, maybe 5 seconds or so and also I was curious to see how things work in the boot order and so I changed DSL order and moved it up to S50 invoking it after the Network and ATM bridge. So it basically syncs while the router tries to boot up and then connects to internet when the boot is complete.

I created a script according to your snippet and gave it execute permissions.
The script is:

#!/bin/sh

count_file=/tmp/dsl-count.txt

if [ "$DSL_NOTIFICATION_TYPE" = "DSL_INTERFACE_STATUS" ] && [ "$DSL_INTERFACE_STATUS" = "UP" ]
then

	local count;
	# line went up, do something to count here
	if [ -f "$count_file" ]
	then
	{
		# get the last count and add increment
		count=cat $count_file
		count=$(($count + 1))
	}
	else
	{
		touch /tmp/dsl-count.txt
		count=1
	}
	fi
	# write count to file and log it
	$count > /tmp/dsl-count.txt
	logger daemon-notice: DSL line is UP and connection count is: $count

fi
exit 0

Now I am not sure if the script is working or maybe it does not get called up. Do I just have to keep this script in /etc/hotplug.d/dsl/ or do something else with it?

Update: For some reason the script is not working inside the IF statement. The script itself gets called but it doesnt enter the IF statement at all. Even when the status is UP. I put logger "daemon.notice: DSL notification type is: $DSL_NOTIFICATION_TYPE and DSL Interface Status is: $DSL_INTERFACE_STATUS" command in there to see if the script gets called and this is what I get if I put the command before the IF statement.

Fri Jan 18 21:11:39 2019 user.notice root: daemon.notice: DSL notification type is: DSL_INTERFACE_STATUS and DSL Interface Status is: UP

Is there anything wrong with my script?

"local" must be inside a function, the script will exit with an error.

is missing an "echo" in front. Your script will continue to execute but throw an error, and obviously not work correctly.

These are just the obvious errors. You can easily debug your script by calling it using

# DSL_NOTIFICATION_TYPE=DSL_INTERFACE_STATUS DSL_INTERFACE_STATUS=UP sh /etc/hotplug.d/dsl/your-script.sh

and get errors displayed.

1 Like

I was finally able to make it work. The script I used is below:

#! /bin/sh

count_file="/tmp/dsl-count" &> /dev/null
count=""

if [ "$DSL_NOTIFICATION_TYPE" = "DSL_INTERFACE_STATUS" ] && [ "$DSL_INTERFACE_STATUS" = "UP" ]
then
{
        # line went up, do something to count here
        if [ -f "$count_file" ]
        then
        {
                # get the last count and add increment
                count=$(cat $count_file)
                count=$(($count + 1))
        }
        else
        {
                touch $count_file
                chmod 0777 $count_file
                count=1
        }
        fi
        # write count to file and log it
        echo $count > $count_file
}
fi

The script creates a temporary file to store DSL connection drops/reconnects so the file gets lost after a reboot and new file is created the next time it runs. I was not able to write to the file after running the script once so I had to set 0777 permissions after creating the file. Hopefully it can help someone else in the future. Many thanks to everyone.

Is it possible to integrate this Connection Count into LuCI? I see @jow listed at the top of index.htm and it also includes details about DSL stats being added to the overview page through lucistat. But one thing that I don't know is where is the actual html page also where can I edit the lucistat and add the corresponding entry. I think I'll need to submit a pull request but I'm not even familiar with Lua or Html. Can someone point me to the right direction? Thanks

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.