SDK Script led.are

led.are
/* DESC: This script can be used to set a LED
 * Copyright (C) 2012 NetModule AG, Switzerland
 */
 
LED = 0; /* use first LED */
 
ret = nb_led_acquire(LED);
if (ret == -1) {
    printf("unable to acquire led%d, retrying...\n", LED);
 
    nb_led_release(LED);
    ret = nb_led_acquire(LED);
    if (ret == -1) {
        printf("stil unable to acquire led%d, exiting\n", LED);
        exit(1);
    }
}
 
ret = nb_led_set(LED, LED_SOLID | LED_COLOR_RED);
if (ret != -1) {
    printf("led%d is now set to solid red\n", LED);
    sleep(5);
}
ret = nb_led_set(LED, LED_OFF);
if (ret != -1) {
    printf("led%d is now set to off\n", LED);
    sleep(1);
}
 
nb_led_release(LED);
printf("led%d has been released\n", LED);
 
exit(0);