The pfSense Store

Author Topic: Possible Wrap LED Solution  (Read 7225 times)

0 Members and 1 Guest are viewing this topic.

Offline ealvar

  • Newbie
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Possible Wrap LED Solution
« on: December 21, 2005, 03:55:58 pm »
Well, I've been fiddling around with my WRAP and PFSense and I noticed that only the first LED does anything.

After looking around a bit I found an easy way to control the LED functions.

echo 1 > /dev/led/led2     <- Turns LED 2 on
echo 0 > /dev/led/led2     <- Turns LED 2 off
echo fx> /dev/led/led2     <- Flashes LED 2 at intervals where x=1-9.  1 is fastest 9 is slowest.

The question I have is how to use this functionality.

I've been mucking around trying to figure out where I can use this information to turn on the 2nd LED when a PPPOE connection is established.

Is this useful info at all?

E

Offline hoba

  • Administrator
  • Hero Member
  • *****
  • Posts: 5837
  • Karma: +3/-0
  • What was the problem to this solution again?
    • View Profile
    • pfSense
Re: Possible Wrap LED Solution
« Reply #1 on: December 21, 2005, 04:08:27 pm »
Indeed it is! Thanks for that hint  ;D

Offline ealvar

  • Newbie
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: Possible Wrap LED Solution
« Reply #2 on: December 21, 2005, 04:11:09 pm »
Ok...

So, is it possible to turn on LED 2 when PPPOE is established?

I'm an intermediate linux guy, not a BSD guy... where's the PPPOE script?

;)

E

Offline sullrich

  • Hero Member
  • *****
  • Posts: 5110
  • Karma: +3/-0
    • View Profile
    • pfSense
Re: Possible Wrap LED Solution
« Reply #3 on: December 21, 2005, 04:28:50 pm »
Look in /usr/local/sbin/ppp-linkup IIRC

Offline ealvar

  • Newbie
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: Possible Wrap LED Solution
« Reply #4 on: December 21, 2005, 04:31:09 pm »
Cool!

Now I need to figure out how to remount the filesystem RW.

Thanks,

E

Offline sullrich

  • Hero Member
  • *****
  • Posts: 5110
  • Karma: +3/-0
    • View Profile
    • pfSense
Re: Possible Wrap LED Solution
« Reply #5 on: December 21, 2005, 04:31:34 pm »
Run /etc/rc.conf_mount_rw

Offline MdeWendt

  • Jr. Member
  • **
  • Posts: 32
  • Karma: +0/-0
    • View Profile
Re: Possible Wrap LED Solution
« Reply #6 on: December 22, 2005, 01:21:05 am »
Hello E,

very good work. Do you find a way to read out the switch of the WRAP board?



Martin

Offline jonr800

  • Newbie
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Possible Wrap LED Solution
« Reply #7 on: January 04, 2006, 01:43:33 am »
Well I coded up a few PHP scripts to take advantage of the LED's. They're very rough.  I'm sure for some of the things I could pull from the config.xml, but that just seemed like a lot of work / extra overhead.

The following will ping your gateway and something else of your choice.  If both return a ping LED 2 gets lit.  If the GW returns a ping but the other IP does not (internet down), then it flashes LED2.  Otherwise LED 2 get turned off.
Code: [Select]
#!/usr/local/bin/php -q
<?php
  $gateway 
"xxx.xxx.xxx.xxx";
  $external "yahoo.com";

  $gwping=exec("/sbin/ping -c 1 -i 1 $gateway");
  $extping=exec("/sbin/ping -c 1 -i 1 $external");

  if(strlen($gwping)>&& strlen($extping)>1)
  {
    exec("/bin/echo 1 > /dev/led/led2");
  }
  else
  {
    if(strlen($gwping)>&& strlen($extping)<=1)
      exec("/bin/echo f5 > /dev/led/led2");
    else
      exec("/bin/echo 0 > /dev/led/led2");
  }
?>

The next one tests for how many pptp users are connected.  If there are users connected then it turns LED3 on.  I was debating having it flash faster for more users, but meh.
Code: [Select]
#!/usr/local/bin/php -q
<?php
  exec
("/sbin/ifconfig -a"$a);
  $pptpusers 0;

  foreach($a as $val)
  {
    if(preg_match("/^ng.*UP/"$val))
      $pptpusers++;
  }

  if($pptpusers 0)
    exec("echo 1 > /dev/led/led3");
  else
    exec("echo 0 > /dev/led/led3");

?>

I set cron to run these every few minutes.

Offline hoba

  • Administrator
  • Hero Member
  • *****
  • Posts: 5837
  • Karma: +3/-0
  • What was the problem to this solution again?
    • View Profile
    • pfSense
Re: Possible Wrap LED Solution
« Reply #8 on: January 04, 2006, 02:06:29 am »
Nice, there are a lot of things to think about to be used with the LEDs. As the soekris only has 1 LED (which is labeled Error I think) we might want to have one LED indicating non acknowledged alerts in 1.1. However, the wrap has more LEDs and assigning different functions to these might be handy too (like dropdowns in the gui what which LED is indicating).

Feel free to make further suggestions and codesnippets here:
http://forum.pfsense.org/index.php?topic=398.0

Offline sullrich

  • Hero Member
  • *****
  • Posts: 5110
  • Karma: +3/-0
    • View Profile
    • pfSense
Re: Possible Wrap LED Solution
« Reply #9 on: January 04, 2006, 11:24:33 am »
This is pretty neat, but can you extend this a little more and make it work with config.xml ?   If so, I'll commit.

Offline jonr800

  • Newbie
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Possible Wrap LED Solution
« Reply #10 on: January 04, 2006, 01:38:35 pm »
I know I can get it to pull the gateway from config.xml for the inernet connection test.  Should I add an entry in config.xml for the external site or just leave it yahoo?  I guess a DNS server would also work.

I only have my WRAP for a few days this week before it's shipped off to a client.  Having a lot of fun with it though. :)