Galaxy Note 2: LED Notifications [requires root]

1,191 views
Skip to first unread message

TomL

unread,
Dec 18, 2012, 4:59:33 AM12/18/12
to tas...@googlegroups.com
Wow, that is some fine reverse engineering.

Tom

GermainZ

unread,
Dec 18, 2012, 10:43:32 AM12/18/12
to tas...@googlegroups.com
Doesn't echo / sleep / echo / sleep work?

On Monday, December 17, 2012 9:02:27 PM UTC+2, Gregory Smith wrote:

What I was unable to do:
Pulsing unique colors
Blinking through multiple colors
Blinking less than 500ms

TomL

unread,
Dec 18, 2012, 10:48:11 AM12/18/12
to tas...@googlegroups.com
If the display is off long enough, then the Android OS will suspend the shell script, so the blinking stops.  I think the led_blink virtual device periodically wakes the phone just enough to blink the led.

Sadly, I checked my GB phone, and it doesn't support this.  Ah well.

Tom

GermainZ

unread,
Dec 18, 2012, 10:51:19 AM12/18/12
to tas...@googlegroups.com
I use the same method (shell scripts, echo/sleep/echo/sleep) for this: forum.xda-developers.com/showthread.php?t=1958939
Works great. Keep device awake is needed, obviously.

bdanders

unread,
Dec 19, 2012, 10:42:24 AM12/19/12
to tas...@googlegroups.com
Yup, works fine on my rooted SGS3 running CM10. How is this better than the LED notification functions built into Tasker? I guess because it can be done without a notification?

On Monday, December 17, 2012 2:02:27 PM UTC-5, Gregory Smith wrote:
There are two primary directories which lend access to the notification LEDs on the face of the phone. One permits you to turn on and off the LEDs, but is extremely inconsistent while the phone is locked and loops seem to break. The other allows you to make real use of the blinking function on the LEDs.

Failure:
The first is actually a set of three:
/sys/class/leds/led_b/
/sys/class/leds/led_g/
/sys/class/leds/led_r/ 
Each of these directories has a set of files which are related to the individual R, G, and B LEDs that make the LED Notification light:
blink
brightness
delay_off
delay_on
max_brightness
uevent
I didn't have much luck with any of these aside from "brightness" which when echoed a value 0-255 will turn on the LED.
I tried and failed to create a functioning loop to turn on and off the LED, because Tasker tended to stall the loop when the phone would lock.

Success!
However, the second "virtual" directory has given me excellent results:
/sys/devices/virtual/sec/led/
This directory has the following set of files:
led_b
led_blink
led_br_lev
led_g
led_lowpower
led_pattern
led_r
uevent
led_r, led_g, and led_b operate the same as the previously mentioned "brightness" where echoing a value 0-255 will set turn on/off the LED (0 = off, 1-255 = level of brightness).
led_pattern, has gotten attention on the XDA thread (http://forum.xda-developers.com/showthread.php?t=1803130) has an assortment of default patterns:
0 - Off
1 - Solid Red
2 - Fast Blinking Red
3 - Slow Blinking Blue
4 - Slow Blinking Red
5 - Blinking Green
6 - Solid Blue
7 - Pulsing Blue
What I wanted, however, was access to the blinking LED so I could set up unique colors and speeds for my LED notifications. led_blink is where that information is passed, but it is not so straightforward.
I cannot remember where I first found the information which discussed the hex value which you echo to led_blink, but that's what steered me best in the direction which landed me here.
echoing 0xff0000 sets the notification LED to solid red. The "ff" represents 100 on a scale from 0 to 100 of brightness. As such, it is assumed the first two numbers of the hex sequence set the brightness for the red, the second two set green, and the final 2 set the brightness value of blue.
I tested an assortment of combinations to create colors:
0xff8080 - white
0xff1500 - orange
0x005000 - green
0x004515 - turquoise
0x000000 - off
Some further guessing and I discovered that separating a two more numbers with spaces would yield the time on in milliseconds and time off in milliseconds for the blink:
0x005000 500 1000 - green on for half a second off for a full second, repeating.
0x004515 1000 5000 - turquoise on for 1 second, off for five seconds, repeating.

Basically, I was able to set up contexts for notifications from specific apps to cue the LED to be a specific color by echoing a shell command with Use Root checked.
Missed Calls (white flashing)
echo 0xff8080 500 500 > /sys/devices/virtual/sec/led/led_blink
Received SMS (yellow flashing)
echo 0x953005 500 500 > /sys/devices/virtual/sec/led/led_blink
Turn off flashing LED after 10:00pm or when device is unlocked or when you clear a notification while the screen is locked:
 echo 0x000000 0 0 > /sys/devices/virtual/sec/led/led_blink

What I was unable to do:
Pulsing unique colors
Blinking through multiple colors
Blinking less than 500ms

I hope this helps someone else out there. I Googled for a long time and couldn't find any better documentation for the Note 2. Can anyone with a rooted SGS3 confirm that these methods work the same?

If anyone actually wants to know the profiles/contexts and tasks I used with which methods, ask and I'll put something together.

bdanders

unread,
Dec 19, 2012, 5:33:22 PM12/19/12
to tas...@googlegroups.com
Ok, I take back my questioning the purpose of this, it's a lot more versatile than the built in task. Thanks for doing to work to figure it out.

On my SGS3 I can set the blink rate to as fast as I want, although setting the on time to less than 20 starts to really hinder the brightness of the light. On for 20 ms and off for 50 makes for a pretty urgent looking alert.

Wayne Trevena

unread,
Dec 20, 2012, 7:39:54 AM12/20/12
to tas...@googlegroups.com
Any chance someone can post an example script guys or how to for Tasker?

Maybe even upload a script to import and work out/play with?

Thanks.

bdanders

unread,
Dec 20, 2012, 9:18:27 AM12/20/12
to tas...@googlegroups.com
I think he did a pretty good job describing exactly what to do in the first post. Use a "Run Shell" task and execute (with root):


echo 0x953005 500 500 > /sys/devices/virtual/sec/led/led_blink

Change the color and timing values to suit whatever you want to do. The individual implementation requirements will all depend on what you want to do with it.

Evan Willner

unread,
Jan 22, 2013, 2:54:18 PM1/22/13
to tas...@googlegroups.com
This is great - and I think I can do some neat stuff with it.

The only issue is that I can not seem to create the file.  I think it has something to do with the partition being mounted ro, and it would need to be rw.  I have been trying to search for the proper command syntax and just can't seem to get it right.  I would think that I need a "Run Shell" task containing "mount -o rw,remount /system" (and execute with root), but that does not work.  Any ideas as to what I am doing wrong?

Thanks,

bdanders

unread,
Jan 22, 2013, 3:40:05 PM1/22/13
to tas...@googlegroups.com
It might be a dumb question, but you are trying to run the shell with root permission, yes?

Evan Willner

unread,
Jan 22, 2013, 3:41:21 PM1/22/13
to tas...@googlegroups.com
Yes I am executing with root.

TomL

unread,
Jan 22, 2013, 4:09:21 PM1/22/13
to tas...@googlegroups.com
You can't create that file if it doesn't exist. If that file isn't there, then it's not a feature that's available on your phone/os.

Tom

Gregory Smith

unread,
Jan 22, 2013, 4:14:02 PM1/22/13
to tas...@googlegroups.com
This is specific to the SG Note 2 running the Touchwiz interface, and I assume it'll work on the SGS3, since they have similar architecture, though I have not tested it. If you're not running a Note 2 or S3, I doubt it will work.

Evan Willner

unread,
Jan 22, 2013, 4:14:15 PM1/22/13
to tas...@googlegroups.com
I got it working.  I changed the format of the command to "mount -o remount,rw /system", but I am not sure that this was the fix.

I think it is more likely that the cut and past command that  I used somehow inserted some character that looked to me like a space, but was not actually a space.

Thanks for the help.

bdanders

unread,
Jan 22, 2013, 4:30:03 PM1/22/13
to tas...@googlegroups.com
Just for the record, it does work on the SGS3 and not just Touchwiz. I've used on Cyanogenmod 10 and 10.1 so far.

Max Hodgson

unread,
Jan 22, 2013, 4:31:46 PM1/22/13
to tas...@googlegroups.com
On 22 January 2013 21:30, bdanders <the.bryce...@gmail.com> wrote:
Just for the record, it does work on the SGS3 and not just Touchwiz. I've used on Cyanogenmod 10 and 10.1 so far.


Works on my standard JB Rom rooted S3.

Gregory Smith

unread,
Jan 22, 2013, 4:43:33 PM1/22/13
to tas...@googlegroups.com, m...@mjhodgson.com
bdanders, Max, thanks for the confirmations.

Sokudo

unread,
Mar 30, 2013, 11:30:46 PM3/30/13
to tas...@googlegroups.com
I know, this is a slightly old thread, but has anyone using this method found that turning the LED off is a problem?  Right now I'm using the echo script to turn on the LEDs for SMS and Calls, but using the echo again with black (as suggested) in another task to turn off the lights doesn't work; they only turn off once they've timed themselves out.  I notice someone mentioned doing echo/sleep/echo: how was this done, and might it work better?
echo 0x953005 500 500 > /sys/devices/virtual/sec/led/led_blink
Turn off flashing LED after 10:00pm or when device is unlocked or when you clear a notification while the screen is locked:
 echo 0x000000 0 0 > /sys/devices/virtual/sec/led/led_blink

What I was unable to do:
Pulsing unique colors
Blinking through multiple colors
Blinking less than 500ms

I hope this helps someone else out there. I Googled for a long time and couldn't find any better documentation for the Note 2. Can anyone with a rooted SGS3 confirm that these methods work the same?
Reply all
Reply to author
Forward
0 new messages