mirror of
				https://github.com/Telecominfraproject/wlan-ap.git
				synced 2025-10-31 02:17:58 +00:00 
			
		
		
		
	WIFI-1934-LED-Turnoff
This Patch will add support to turnoff LEDs of the AP through cloud command Signed-off-by: Nagendrababu <nagendrababu.bonkuri@connectus.ai>
This commit is contained in:
		 Nagendrababu
					Nagendrababu
				
			
				
					committed by
					
						 Rick Sommerville
						Rick Sommerville
					
				
			
			
				
	
			
			
			 Rick Sommerville
						Rick Sommerville
					
				
			
						parent
						
							b9e54ac20e
						
					
				
				
					commit
					547fb36d78
				
			
							
								
								
									
										3
									
								
								feeds/wlan-ap/opensync/files/bin/wlan_ap_led.sh
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										3
									
								
								feeds/wlan-ap/opensync/files/bin/wlan_ap_led.sh
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							| @@ -2,3 +2,6 @@ | |||||||
|  |  | ||||||
| #Blink AP's LED | #Blink AP's LED | ||||||
| /usr/opensync/tools/ovsh insert Node_Config module:="led" key:="led_blink" value:="on" | /usr/opensync/tools/ovsh insert Node_Config module:="led" key:="led_blink" value:="on" | ||||||
|  |  | ||||||
|  | #Turnoff AP's LED | ||||||
|  | /usr/opensync/tools/ovsh insert Node_Config module:="led" key:="led_off" value:="off" | ||||||
|   | |||||||
| @@ -325,6 +325,18 @@ int available_led_check(char *led_name) | |||||||
| 	} | 	} | ||||||
| 	return 0; | 	return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | static void set_led_config(char *trigger_name, char *key, char* value, char* led_string, char* led_section) | ||||||
|  | { | ||||||
|  | 	blob_buf_init(&b, 0); | ||||||
|  | 	blobmsg_add_string(&b, "sysfs", led_string); | ||||||
|  | 	blobmsg_add_string(&b, "trigger", trigger_name); | ||||||
|  | 	blobmsg_add_string(&b, "value", value); | ||||||
|  | 	blobmsg_add_string(&b, "key", key); | ||||||
|  | 	blob_to_uci_section(uci, "system", led_section, "led", b.head, &led_param, NULL); | ||||||
|  | 	return; | ||||||
|  | } | ||||||
|  |  | ||||||
| static void led_handler(int type, | static void led_handler(int type, | ||||||
| 			struct schema_Node_Config *old, | 			struct schema_Node_Config *old, | ||||||
| 			struct schema_Node_Config *conf) | 			struct schema_Node_Config *conf) | ||||||
| @@ -343,7 +355,7 @@ static void led_handler(int type, | |||||||
| 	switch (type) { | 	switch (type) { | ||||||
| 	case OVSDB_UPDATE_NEW: | 	case OVSDB_UPDATE_NEW: | ||||||
| 	case OVSDB_UPDATE_MODIFY: | 	case OVSDB_UPDATE_MODIFY: | ||||||
| 		if (!strcmp(conf->key, "led_blink")) | 		if (!strcmp(conf->key, "led_blink") || !strcmp(conf->key, "led_off")) | ||||||
| 		{ | 		{ | ||||||
| 			if (glob("/sys/class/leds/*", GLOB_NOSORT, NULL, &gl)) | 			if (glob("/sys/class/leds/*", GLOB_NOSORT, NULL, &gl)) | ||||||
| 				return; | 				return; | ||||||
| @@ -352,12 +364,12 @@ static void led_handler(int type, | |||||||
| 				sscanf(sysled,"/%[^/]/%[^/]/%[^/]/%s", sys, class, leds, led_string); | 				sscanf(sysled,"/%[^/]/%[^/]/%[^/]/%s", sys, class, leds, led_string); | ||||||
| 				sscanf(led_string,"%[^:]:%[^:]:%s",ap_name, color, led_section); | 				sscanf(led_string,"%[^:]:%[^:]:%s",ap_name, color, led_section); | ||||||
| 				if(available_led_check(led_section)) { | 				if(available_led_check(led_section)) { | ||||||
| 					blob_buf_init(&b, 0); | 					if(!strcmp(conf->key, "led_blink")) { | ||||||
| 					blobmsg_add_string(&b, "sysfs", led_string); | 						set_led_config("heartbeat", conf->key, conf->value, led_string, led_section); | ||||||
| 					blobmsg_add_string(&b, "value", "on"); | 					} | ||||||
| 					blobmsg_add_string(&b, "key", conf->key ); | 					else if(!strcmp(conf->key, "led_off")) { | ||||||
| 					blobmsg_add_string(&b, "trigger", "heartbeat"); | 						set_led_config("none", conf->key, conf->value, led_string, led_section); | ||||||
| 					blob_to_uci_section(uci, "system", led_section, "led", b.head, &led_param, NULL); | 					} | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user