Compare commits
	
		
			No commits in common. "a35c2340935415aa390d485bce4f10b52aa7b632" and "303ef23a48615b92b66cec55ad79de9358952c06" have entirely different histories.
		
	
	
		
			a35c234093
			...
			303ef23a48
		
	
		
@ -1 +0,0 @@
 | 
				
			|||||||
#define NEW_LINE "\r\n"
 | 
					 | 
				
			||||||
							
								
								
									
										68
									
								
								app/main.c
									
									
									
									
									
								
							
							
						
						
									
										68
									
								
								app/main.c
									
									
									
									
									
								
							@ -19,15 +19,13 @@
 | 
				
			|||||||
#include "lwip/netif.h"
 | 
					#include "lwip/netif.h"
 | 
				
			||||||
#include "FreeRTOS.h"
 | 
					#include "FreeRTOS.h"
 | 
				
			||||||
#include "FreeRTOSConfig.h"
 | 
					#include "FreeRTOSConfig.h"
 | 
				
			||||||
#include "common.h"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
tls_os_task_t nano_shell_task_handle = NULL;
 | 
					tls_os_task_t nano_shell_task_handle = NULL;
 | 
				
			||||||
tls_os_task_t nano_shell_server_task_handle = NULL;
 | 
					 | 
				
			||||||
extern s16 uart0_rx_callback(u16 len, void *user_data);
 | 
					extern s16 uart0_rx_callback(u16 len, void *user_data);
 | 
				
			||||||
extern s16 uart1_rx_callback(u16 len, void *user_data);
 | 
					extern s16 uart1_rx_callback(u16 len, void *user_data);
 | 
				
			||||||
extern int shell_printf(const char *format, ...);
 | 
					extern int shell_printf(const char *format, ...);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define NANO_SHELL_TASK_STK_SIZE 640
 | 
					#define NANO_SHELL_TASK_STK_SIZE 1024
 | 
				
			||||||
#define NANO_SHELL_SERVER_TASK_STK_SIZE 640
 | 
					#define NANO_SHELL_SERVER_TASK_STK_SIZE 640
 | 
				
			||||||
#define STATUS_LED WM_IO_PB_18
 | 
					#define STATUS_LED WM_IO_PB_18
 | 
				
			||||||
#define PWM_STATUS_LED WM_IO_PB_25
 | 
					#define PWM_STATUS_LED WM_IO_PB_25
 | 
				
			||||||
@ -47,47 +45,47 @@ void tls_netif_status_event_cb(u8 status)
 | 
				
			|||||||
	switch(status)
 | 
						switch(status)
 | 
				
			||||||
  	{
 | 
					  	{
 | 
				
			||||||
		case NETIF_WIFI_JOIN_SUCCESS:
 | 
							case NETIF_WIFI_JOIN_SUCCESS:
 | 
				
			||||||
			shell_printf("Evt : NETIF_WIFI_JOIN_SUCCESS"NEW_LINE);
 | 
								shell_printf("Evt : NETIF_WIFI_JOIN_SUCCESS\n");
 | 
				
			||||||
	  		break;
 | 
						  		break;
 | 
				
			||||||
		case NETIF_WIFI_JOIN_FAILED:
 | 
							case NETIF_WIFI_JOIN_FAILED:
 | 
				
			||||||
			shell_printf("Evt : NETIF_WIFI_JOIN_FAILED"NEW_LINE);
 | 
								shell_printf("Evt : NETIF_WIFI_JOIN_FAILED\n");
 | 
				
			||||||
	  		break;
 | 
						  		break;
 | 
				
			||||||
		case NETIF_WIFI_DISCONNECTED:
 | 
							case NETIF_WIFI_DISCONNECTED:
 | 
				
			||||||
			shell_printf("Evt : NETIF_WIFI_DISCONNECTED"NEW_LINE);
 | 
								shell_printf("Evt : NETIF_WIFI_DISCONNECTED\n");
 | 
				
			||||||
			pulse_rate = PULSE_SLOW;
 | 
								pulse_rate = PULSE_SLOW;
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		case NETIF_IP_NET_UP:
 | 
							case NETIF_IP_NET_UP:
 | 
				
			||||||
			shell_printf("Evt : NETIF_IP_NET_UP"NEW_LINE"ip addr : %v"NEW_LINE"netmask : %v"NEW_LINE"gateway : %v"NEW_LINE, netif->ip_addr.addr,
 | 
								shell_printf("Evt : NETIF_IP_NET_UP\nip addr : %v\nnetmask : %v\ngateway : %v\n", netif->ip_addr.addr,
 | 
				
			||||||
			netif->netmask.addr,
 | 
								netif->netmask.addr,
 | 
				
			||||||
			netif->gw.addr);
 | 
								netif->gw.addr);
 | 
				
			||||||
			pulse_rate = PULSE_FAST;
 | 
								pulse_rate = PULSE_FAST;
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		case NETIF_WIFI_SOFTAP_SUCCESS:
 | 
							case NETIF_WIFI_SOFTAP_SUCCESS:
 | 
				
			||||||
			shell_printf("Evt : NETIF_WIFI_SOFTAP_SUCCESS"NEW_LINE);
 | 
								shell_printf("Evt : NETIF_WIFI_SOFTAP_SUCCESS\n");
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		case NETIF_WIFI_SOFTAP_FAILED:
 | 
							case NETIF_WIFI_SOFTAP_FAILED:
 | 
				
			||||||
			shell_printf("Evt : NETIF_WIFI_SOFTAP_FAILED"NEW_LINE);
 | 
								shell_printf("Evt : NETIF_WIFI_SOFTAP_FAILED\n");
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		case NETIF_WIFI_SOFTAP_CLOSED:
 | 
							case NETIF_WIFI_SOFTAP_CLOSED:
 | 
				
			||||||
			shell_printf("Evt : NETIF_WIFI_SOFTAP_CLOSED"NEW_LINE);
 | 
								shell_printf("Evt : NETIF_WIFI_SOFTAP_CLOSED\n");
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		case NETIF_IP_NET2_UP:
 | 
							case NETIF_IP_NET2_UP:
 | 
				
			||||||
			shell_printf("Evt : NETIF_IP_NET2_UP"NEW_LINE"ip addr : %v"NEW_LINE"netmask : %v"NEW_LINE"gateway : %v"NEW_LINE, netif->next->ip_addr.addr,
 | 
								shell_printf("Evt : NETIF_IP_NET2_UP\nip addr : %v\nnetmask : %v\ngateway : %v\n", netif->next->ip_addr.addr,
 | 
				
			||||||
			netif->next->netmask.addr,
 | 
								netif->next->netmask.addr,
 | 
				
			||||||
			netif->next->gw.addr);
 | 
								netif->next->gw.addr);
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		case NETIF_IPV6_NET_UP:
 | 
							case NETIF_IPV6_NET_UP:
 | 
				
			||||||
			shell_printf("Evt : NETIF_IPV6_NET_UP"NEW_LINE);
 | 
								shell_printf("Evt : NETIF_IPV6_NET_UP\n");
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		default:
 | 
							default:
 | 
				
			||||||
			shell_printf("Evt : UNKNOWN"NEW_LINE);
 | 
								shell_printf("Evt : UNKNOWN\n");
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void touchsensor_cb(u32 status)
 | 
					void touchsensor_cb(u32 status)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	shell_printf("Touch detected : status(%u)"NEW_LINE, status);
 | 
						shell_printf("Touch detected : status(%u)\n", status);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void tls_gpio_irq_cb(void *arg)
 | 
					void tls_gpio_irq_cb(void *arg)
 | 
				
			||||||
@ -125,21 +123,6 @@ void user_main(void *param)
 | 
				
			|||||||
	tls_uart_rx_callback_register(TLS_UART_1, &(uart1_rx_callback), NULL);
 | 
						tls_uart_rx_callback_register(TLS_UART_1, &(uart1_rx_callback), NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	nano_shell_server_task_stack = tls_mem_alloc(sizeof(u32) * NANO_SHELL_SERVER_TASK_STK_SIZE);
 | 
						nano_shell_server_task_stack = tls_mem_alloc(sizeof(u32) * NANO_SHELL_SERVER_TASK_STK_SIZE);
 | 
				
			||||||
	if(nano_shell_server_task_stack != NULL)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		tls_os_status_t status = tls_os_task_create(
 | 
					 | 
				
			||||||
													&nano_shell_server_task_handle,
 | 
					 | 
				
			||||||
													"shll_srv",
 | 
					 | 
				
			||||||
													&(nano_shell_server_task),
 | 
					 | 
				
			||||||
													NULL,
 | 
					 | 
				
			||||||
													(void*) nano_shell_server_task_stack,
 | 
					 | 
				
			||||||
													NANO_SHELL_SERVER_TASK_STK_SIZE * sizeof(u32_t),
 | 
					 | 
				
			||||||
													62,
 | 
					 | 
				
			||||||
													0
 | 
					 | 
				
			||||||
												);
 | 
					 | 
				
			||||||
		if(status != TLS_OS_SUCCESS)
 | 
					 | 
				
			||||||
			shell_printf("Failed to create nano shell server task."NEW_LINE);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	nano_shell_task_stack = tls_mem_alloc(sizeof(u32) * NANO_SHELL_TASK_STK_SIZE);
 | 
						nano_shell_task_stack = tls_mem_alloc(sizeof(u32) * NANO_SHELL_TASK_STK_SIZE);
 | 
				
			||||||
	if(nano_shell_task_stack != NULL)
 | 
						if(nano_shell_task_stack != NULL)
 | 
				
			||||||
@ -156,9 +139,23 @@ void user_main(void *param)
 | 
				
			|||||||
		);
 | 
							);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	shell_printf("Registering netif callback."NEW_LINE);
 | 
						shell_printf("Registering netif callback.\n");
 | 
				
			||||||
	tls_netif_add_status_event(&(tls_netif_status_event_cb));
 | 
						tls_netif_add_status_event(&(tls_netif_status_event_cb));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						//Socket test
 | 
				
			||||||
 | 
						/*
 | 
				
			||||||
 | 
						char buffer[100] = "", *found = NULL;
 | 
				
			||||||
 | 
						struct sockaddr_in server = {
 | 
				
			||||||
 | 
														.sin_family = AF_INET,
 | 
				
			||||||
 | 
														.sin_addr.s_addr = INADDR_ANY,
 | 
				
			||||||
 | 
														.sin_port = htons(80)
 | 
				
			||||||
 | 
													};
 | 
				
			||||||
 | 
						struct sockaddr_in client;
 | 
				
			||||||
 | 
						socklen_t socklent = sizeof(client);
 | 
				
			||||||
 | 
						int listening_socket = socket(AF_INET, SOCK_STREAM, 0), client_socket;
 | 
				
			||||||
 | 
						bind(listening_socket, (struct sockaddr *)&server, sizeof(server));
 | 
				
			||||||
 | 
						listen(listening_socket, 1);*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for(;;)
 | 
						for(;;)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		tls_pwm_duty_set(3, pwm_led_duty_cycle);
 | 
							tls_pwm_duty_set(3, pwm_led_duty_cycle);
 | 
				
			||||||
@ -176,6 +173,17 @@ void user_main(void *param)
 | 
				
			|||||||
		pwm_led_duty_cycle+=fading_direction;
 | 
							pwm_led_duty_cycle+=fading_direction;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		tls_os_time_delay(pdMS_TO_TICKS(pulse_rate));
 | 
							tls_os_time_delay(pdMS_TO_TICKS(pulse_rate));
 | 
				
			||||||
 | 
							/*client_socket = accept(listening_socket, (struct sockaddr *)&client, &socklent);
 | 
				
			||||||
 | 
							shell_printf("Client got accepted\n");
 | 
				
			||||||
 | 
							while(recv(client_socket, buffer, 99, 0) > 0)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								if((found = strchr(buffer, '\r')) != NULL)
 | 
				
			||||||
 | 
									*found = '\0';
 | 
				
			||||||
 | 
								if(buffer[0])
 | 
				
			||||||
 | 
									shell_printf("Recv data : #%s#\n", buffer);
 | 
				
			||||||
 | 
								memset(buffer, 0, sizeof buffer);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							close(client_socket);*/
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -6,7 +6,6 @@
 | 
				
			|||||||
#include "FreeRTOS.h"
 | 
					#include "FreeRTOS.h"
 | 
				
			||||||
#include "task.h"
 | 
					#include "task.h"
 | 
				
			||||||
#include "lwip/netif.h"
 | 
					#include "lwip/netif.h"
 | 
				
			||||||
#include "common.h"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern int shell_printf(const char *format, ...);
 | 
					extern int shell_printf(const char *format, ...);
 | 
				
			||||||
extern int wm_printf(const char *fmt,...);
 | 
					extern int wm_printf(const char *fmt,...);
 | 
				
			||||||
@ -21,7 +20,7 @@ void tls_wifi_client_event_cb(u8 *mac, enum tls_wifi_client_event_type event)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  struct tls_sta_info_t *mac_addr = (struct tls_sta_info_t *)mac;
 | 
					  struct tls_sta_info_t *mac_addr = (struct tls_sta_info_t *)mac;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  shell_printf("Client event(%d), MAC : %M"NEW_LINE, event, mac_addr);
 | 
					  shell_printf("Client event(%d), MAC : %M\n", event, mac_addr);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void wifi_scan_result_cb(void)
 | 
					void wifi_scan_result_cb(void)
 | 
				
			||||||
@ -30,14 +29,14 @@ void wifi_scan_result_cb(void)
 | 
				
			|||||||
  u8 *buf = tls_mem_alloc(buffer_size);
 | 
					  u8 *buf = tls_mem_alloc(buffer_size);
 | 
				
			||||||
  if(buf == NULL)
 | 
					  if(buf == NULL)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    shell_printf("Failed to allocate result buffer"NEW_LINE);
 | 
					    shell_printf("Failed to allocate result buffer\n");
 | 
				
			||||||
    return;
 | 
					    return;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  struct tls_scan_bss_t *scan_result = (struct tls_scan_bss_t *)buf;
 | 
					  struct tls_scan_bss_t *scan_result = (struct tls_scan_bss_t *)buf;
 | 
				
			||||||
  struct tls_bss_info_t *station_list = scan_result->bss;
 | 
					  struct tls_bss_info_t *station_list = scan_result->bss;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  tls_wifi_get_scan_rslt(buf, buffer_size);
 | 
					  tls_wifi_get_scan_rslt(buf, buffer_size);
 | 
				
			||||||
  shell_printf("Found %u nearby station(s) - info size(%u/%u)"NEW_LINE,
 | 
					  shell_printf("Found %u nearby station(s) - info size(%u/%u)\n",
 | 
				
			||||||
  scan_result->count,
 | 
					  scan_result->count,
 | 
				
			||||||
  scan_result->length,
 | 
					  scan_result->length,
 | 
				
			||||||
  buffer_size);
 | 
					  buffer_size);
 | 
				
			||||||
@ -45,7 +44,7 @@ void wifi_scan_result_cb(void)
 | 
				
			|||||||
  for(u8 i = 0; i < scan_result->count; i++)
 | 
					  for(u8 i = 0; i < scan_result->count; i++)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    station_list[i].ssid[station_list[i].ssid_len] = '\0';
 | 
					    station_list[i].ssid[station_list[i].ssid_len] = '\0';
 | 
				
			||||||
    shell_printf("station %u :"NEW_LINE"SSID : %s"NEW_LINE"BSSID : %02X:%02X:%02X:%02X:%02X:%02X"NEW_LINE"RSSI : %d dB"NEW_LINE"Channel : %u"NEW_LINE"Max DR : %u Mbps"NEW_LINE"Mode %u"NEW_LINE"Auth :%u"NEW_LINE"WPS supported : %u"NEW_LINE NEW_LINE,
 | 
					    shell_printf("station %u :\nSSID : %s\nBSSID : %02X:%02X:%02X:%02X:%02X:%02X\nRSSI : %d dB\nChannel : %u\nMax DR : %u Mbps\nMode %u\nAuth :%u\nWPS supported : %u\n\n",
 | 
				
			||||||
    i,
 | 
					    i,
 | 
				
			||||||
    (char *)station_list[i].ssid,
 | 
					    (char *)station_list[i].ssid,
 | 
				
			||||||
    station_list[i].bssid[0], station_list[i].bssid[1], station_list[i].bssid[2], station_list[i].bssid[3], station_list[i].bssid[4], station_list[i].bssid[5],
 | 
					    station_list[i].bssid[0], station_list[i].bssid[1], station_list[i].bssid[2], station_list[i].bssid[3], station_list[i].bssid[4], station_list[i].bssid[5],
 | 
				
			||||||
@ -62,14 +61,14 @@ void wifi_scan_result_cb(void)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void tls_wifi_data_ext_recv_cb(u8* data, u32 data_len, struct tls_wifi_ext_t *ext)
 | 
					void tls_wifi_data_ext_recv_cb(u8* data, u32 data_len, struct tls_wifi_ext_t *ext)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  shell_printf("recv packet :"NEW_LINE"rssi : %d\nrate : %u"NEW_LINE, (s8)ext->rssi, ext->rx_rate);
 | 
					  shell_printf("recv packet :\nrssi : %d\nrate : %u\n", (s8)ext->rssi, ext->rx_rate);
 | 
				
			||||||
  for(u32 i = 0; i < data_len; i++)
 | 
					  for(u32 i = 0; i < data_len; i++)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    shell_printf("%02X", data[i]);
 | 
					    shell_printf("%02X", data[i]);
 | 
				
			||||||
    if(i % 30 == 0)
 | 
					    if(i % 30 == 0)
 | 
				
			||||||
      shell_printf(NEW_LINE);
 | 
					      shell_printf("\n");
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  shell_printf(NEW_LINE);
 | 
					  shell_printf("\n");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void tls_rtc_irq_cb(void *arg)
 | 
					void tls_rtc_irq_cb(void *arg)
 | 
				
			||||||
@ -77,7 +76,7 @@ void tls_rtc_irq_cb(void *arg)
 | 
				
			|||||||
  struct tm rtc_time;
 | 
					  struct tm rtc_time;
 | 
				
			||||||
  tls_get_rtc(&rtc_time);
 | 
					  tls_get_rtc(&rtc_time);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  shell_printf("rtc isr called"NEW_LINE"time is :"NEW_LINE"%d:%d:%d %d/%d/%d"NEW_LINE,
 | 
					  shell_printf("rtc isr called\ntime is :\n%d:%d:%d %d/%d/%d\n",
 | 
				
			||||||
  rtc_time.tm_hour,
 | 
					  rtc_time.tm_hour,
 | 
				
			||||||
  rtc_time.tm_min,
 | 
					  rtc_time.tm_min,
 | 
				
			||||||
  rtc_time.tm_sec,
 | 
					  rtc_time.tm_sec,
 | 
				
			||||||
@ -102,22 +101,22 @@ int _system(const shell_cmd_t *pcmd, int argc, char *const argv[])
 | 
				
			|||||||
#if configUSE_TRACE_FACILITY
 | 
					#if configUSE_TRACE_FACILITY
 | 
				
			||||||
      vTaskList(buf);
 | 
					      vTaskList(buf);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
      shell_printf(NEW_LINE"%s"NEW_LINE"buf_len : %d"NEW_LINE, buf, strlen(buf));
 | 
					      shell_printf("\n%s\nbuf_len : %d\n", buf, strlen(buf));
 | 
				
			||||||
      tls_mem_free(buf);
 | 
					      tls_mem_free(buf);
 | 
				
			||||||
      buf = NULL;
 | 
					      buf = NULL;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else if(strcmp(argv[1], "ram_usage") == 0)
 | 
					    else if(strcmp(argv[1], "ram_usage") == 0)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      shell_printf("Free OS heap : %u/%u byte(s)"NEW_LINE"tls heap size : %u"NEW_LINE, xPortGetFreeHeapSize(), configTOTAL_HEAP_SIZE, tls_mem_get_avail_heapsize());
 | 
					      shell_printf("Free OS heap : %u/%u byte(s)\ntls heap size : %u\n", xPortGetFreeHeapSize(), configTOTAL_HEAP_SIZE, tls_mem_get_avail_heapsize());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      shell_printf("Unknown %s action"NEW_LINE, argv[0]);
 | 
					      shell_printf("Unknown %s action\n", argv[0]);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    shell_printf("List of system actions :"NEW_LINE"list_task"NEW_LINE"ram_usage"NEW_LINE);
 | 
					    shell_printf("List of system actions :\nlist_task\nram_usage\n");
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  return 0;
 | 
					  return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -134,7 +133,7 @@ int _soft_ap(const shell_cmd_t *pcmd, int argc, char *const argv[])
 | 
				
			|||||||
  {
 | 
					  {
 | 
				
			||||||
    if(strcmp(argv[1], "state") == 0)
 | 
					    if(strcmp(argv[1], "state") == 0)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      shell_printf("SOFT AP state : %u"NEW_LINE, tls_wifi_softap_get_state());
 | 
					      shell_printf("SOFT AP state : %u\n", tls_wifi_softap_get_state());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else if(strcmp(argv[1], "create") == 0)
 | 
					    else if(strcmp(argv[1], "create") == 0)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
@ -144,7 +143,7 @@ int _soft_ap(const shell_cmd_t *pcmd, int argc, char *const argv[])
 | 
				
			|||||||
      tls_wifi_set_oneshot_flag(0);
 | 
					      tls_wifi_set_oneshot_flag(0);
 | 
				
			||||||
      tls_wifi_softap_destroy();
 | 
					      tls_wifi_softap_destroy();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      shell_printf("Registering client event callback"NEW_LINE);
 | 
					      shell_printf("Registering client event callback\n");
 | 
				
			||||||
      tls_wifi_softap_client_event_register(&(tls_wifi_client_event_cb));
 | 
					      tls_wifi_softap_client_event_register(&(tls_wifi_client_event_cb));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      strncpy((char *)ap_info.ssid, argv[2], 32);
 | 
					      strncpy((char *)ap_info.ssid, argv[2], 32);
 | 
				
			||||||
@ -168,23 +167,23 @@ int _soft_ap(const shell_cmd_t *pcmd, int argc, char *const argv[])
 | 
				
			|||||||
      ip_info.dnsname[0] = '\0';
 | 
					      ip_info.dnsname[0] = '\0';
 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
      int result = tls_wifi_softap_create(&ap_info, &ip_info);
 | 
					      int result = tls_wifi_softap_create(&ap_info, &ip_info);
 | 
				
			||||||
      shell_printf("Create AP with SSID : %s, key(%d) : %s -> %d"NEW_LINE, ap_info.ssid, ap_info.keyinfo.key_len, ap_info.keyinfo.key, result);
 | 
					      shell_printf("Create AP with SSID : %s, key(%d) : %s -> %d\n", ap_info.ssid, ap_info.keyinfo.key_len, ap_info.keyinfo.key, result);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else if(strcmp(argv[1], "destroy") == 0)
 | 
					    else if(strcmp(argv[1], "destroy") == 0)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      tls_wifi_softap_client_event_register(NULL);
 | 
					      tls_wifi_softap_client_event_register(NULL);
 | 
				
			||||||
      tls_wifi_set_oneshot_flag(0);
 | 
					      tls_wifi_set_oneshot_flag(0);
 | 
				
			||||||
      tls_wifi_softap_destroy();
 | 
					      tls_wifi_softap_destroy();
 | 
				
			||||||
      shell_printf("Stopping SOFT AP"NEW_LINE);
 | 
					      shell_printf("Stopping SOFT AP\n");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      shell_printf("Unknown %s action"NEW_LINE, argv[0]);
 | 
					      shell_printf("Unknown %s action\n", argv[0]);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    shell_printf("List of soft_ap actions :"NEW_LINE"state"NEW_LINE"create <SSID> <PWD>"NEW_LINE"destroy"NEW_LINE);
 | 
					    shell_printf("List of soft_ap actions :\nstate\ncreate <SSID> <PWD>\ndestroy\n");
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  return 0;
 | 
					  return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -199,43 +198,43 @@ int _station(const shell_cmd_t *pcmd, int argc, char *const argv[])
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
      if(tls_wifi_scan() == WM_SUCCESS)
 | 
					      if(tls_wifi_scan() == WM_SUCCESS)
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
        shell_printf("Scanning nearby stations..."NEW_LINE);
 | 
					        shell_printf("Scanning nearby stations...\n");
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      else
 | 
					      else
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
        shell_printf("Failed to start wifi scan"NEW_LINE);
 | 
					        shell_printf("Failed to start wifi scan\n");
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else if(strcmp(argv[1], "state") == 0)
 | 
					    else if(strcmp(argv[1], "state") == 0)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      shell_printf("Station state : %u"NEW_LINE, tls_wifi_get_state());
 | 
					      shell_printf("Station state : %u\n", tls_wifi_get_state());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else if(strcmp(argv[1], "connect") == 0)
 | 
					    else if(strcmp(argv[1], "connect") == 0)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      shell_printf("Connecting to %s with pwd : %s"NEW_LINE, argv[2], argv[3]);
 | 
					      shell_printf("Connecting to %s with pwd : %s\n", argv[2], argv[3]);
 | 
				
			||||||
      if(tls_wifi_connect((u8 *)argv[2], strlen(argv[2]), (u8 *)argv[3], strlen(argv[3])) == WM_SUCCESS)
 | 
					      if(tls_wifi_connect((u8 *)argv[2], strlen(argv[2]), (u8 *)argv[3], strlen(argv[3])) == WM_SUCCESS)
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
        shell_printf("Connecting..."NEW_LINE);
 | 
					        shell_printf("Connected\n");
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      else
 | 
					      else
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
        shell_printf("Failed to connect !"NEW_LINE);
 | 
					        shell_printf("Failed to connect !\n");
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else if(strcmp(argv[1], "disconnect") == 0)
 | 
					    else if(strcmp(argv[1], "disconnect") == 0)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      shell_printf("Disconnecting from current station"NEW_LINE);
 | 
					      shell_printf("Disconnecting from current station\n");
 | 
				
			||||||
      tls_wifi_set_oneshot_flag(0);
 | 
					      tls_wifi_set_oneshot_flag(0);
 | 
				
			||||||
      tls_wifi_disconnect();
 | 
					      tls_wifi_disconnect();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      shell_printf("Unknown %s action"NEW_LINE, argv[0]);
 | 
					      shell_printf("Unknown %s action\n", argv[0]);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    shell_printf("List of station actions :"NEW_LINE"scan"NEW_LINE"state"NEW_LINE"connect <SSID> <PWD>"NEW_LINE"disconnect"NEW_LINE);
 | 
					    shell_printf("List of station actions :\nscan\nstate\nconnect <SSID> <PWD>\ndisconnect\n");
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  return 0;
 | 
					  return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -244,7 +243,7 @@ int _cpu_temp(const shell_cmd_t *pcmd, int argc, char *const argv[])
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  int temperature = adc_temp();
 | 
					  int temperature = adc_temp();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  shell_printf("CPU temp is %d.%03d"NEW_LINE, temperature/1000, temperature%1000);
 | 
					  shell_printf("CPU temp is %d.%03d\n", temperature/1000, temperature%1000);
 | 
				
			||||||
  return 0;
 | 
					  return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -256,26 +255,26 @@ int _wifi(const shell_cmd_t *pcmd, int argc, char *const argv[])
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
      tls_wifi_softap_destroy();
 | 
					      tls_wifi_softap_destroy();
 | 
				
			||||||
      tls_wifi_disconnect();
 | 
					      tls_wifi_disconnect();
 | 
				
			||||||
      shell_printf("set one shot flg : %d"NEW_LINE,tls_wifi_set_oneshot_flag(0));
 | 
					      shell_printf("set one shot flg : %d\n",tls_wifi_set_oneshot_flag(0));
 | 
				
			||||||
      shell_printf("Stopping WIFI interface"NEW_LINE);
 | 
					      shell_printf("Stopping WIFI interface\n");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else if(strcmp(argv[1], "error") == 0)
 | 
					    else if(strcmp(argv[1], "error") == 0)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      shell_printf("Error : %s"NEW_LINE, tls_wifi_get_errinfo(tls_wifi_get_errno()));
 | 
					      shell_printf("Error : %s\n", tls_wifi_get_errinfo(tls_wifi_get_errno()));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else if(strcmp(argv[1], "promiscuous_on") == 0)
 | 
					    else if(strcmp(argv[1], "promiscuous_on") == 0)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      shell_printf("WiFi promiscuous on"NEW_LINE);
 | 
					      shell_printf("WiFi promiscuous on\n");
 | 
				
			||||||
      tls_wifi_data_ext_recv_cb_register(&(tls_wifi_data_ext_recv_cb));
 | 
					      tls_wifi_data_ext_recv_cb_register(&(tls_wifi_data_ext_recv_cb));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else if(strcmp(argv[1], "promiscuous_off") == 0)
 | 
					    else if(strcmp(argv[1], "promiscuous_off") == 0)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      shell_printf("WiFi promiscuous off"NEW_LINE);
 | 
					      shell_printf("WiFi promiscuous off\n");
 | 
				
			||||||
      tls_wifi_data_ext_recv_cb_register(NULL);
 | 
					      tls_wifi_data_ext_recv_cb_register(NULL);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else if(strcmp(argv[1], "mode") == 0)
 | 
					    else if(strcmp(argv[1], "mode") == 0)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      shell_printf("Mode is : %d"NEW_LINE, tls_wifi_get_oneshot_flag());
 | 
					      shell_printf("Mode is : %d\n", tls_wifi_get_oneshot_flag());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else if(strcmp(argv[1], "get_ip") == 0)
 | 
					    else if(strcmp(argv[1], "get_ip") == 0)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
@ -283,30 +282,30 @@ int _wifi(const shell_cmd_t *pcmd, int argc, char *const argv[])
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
      if(netif)
 | 
					      if(netif)
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
        shell_printf("netif 1"NEW_LINE"ip addr : %v"NEW_LINE"netmask : %v"NEW_LINE"gateway : %v"NEW_LINE, netif->ip_addr.addr,
 | 
					        shell_printf("netif 1\nip addr : %v\nnetmask : %v\ngateway : %v\n", netif->ip_addr.addr,
 | 
				
			||||||
			  netif->netmask.addr,
 | 
								  netif->netmask.addr,
 | 
				
			||||||
			  netif->gw.addr);
 | 
								  netif->gw.addr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(netif->next)
 | 
					        if(netif->next)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
          shell_printf("netif 2"NEW_LINE"ip addr : %v"NEW_LINE"netmask : %v"NEW_LINE"gateway : %v"NEW_LINE, netif->next->ip_addr.addr,
 | 
					          shell_printf("netif 2\nip addr : %v\nnetmask : %v\ngateway : %v\n", netif->next->ip_addr.addr,
 | 
				
			||||||
			    netif->next->netmask.addr,
 | 
								    netif->next->netmask.addr,
 | 
				
			||||||
			    netif->next->gw.addr);
 | 
								    netif->next->gw.addr);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      else
 | 
					      else
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
        shell_printf("No netif yet, connect to sta or create soft_ap !"NEW_LINE);
 | 
					        shell_printf("No netif yet, connect to sta or create soft_ap !\n");
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      shell_printf("Unknown %s action"NEW_LINE, argv[0]);
 | 
					      shell_printf("Unknown %s action\n", argv[0]);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    shell_printf("List of wifi actions :"NEW_LINE"off"NEW_LINE"error"NEW_LINE"promiscuous_on"NEW_LINE"promiscuous_off"NEW_LINE"mode"NEW_LINE"get_ip"NEW_LINE);
 | 
					    shell_printf("List of wifi actions :\noff\nerror\npromiscuous_on\npromiscuous_off\nmode\nget_ip\n");
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  return 0;
 | 
					  return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -317,7 +316,7 @@ int _wifi_sleep(const shell_cmd_t *pcmd, int argc, char *const argv[])
 | 
				
			|||||||
  {
 | 
					  {
 | 
				
			||||||
    if(strcmp(argv[1], "query") == 0)
 | 
					    if(strcmp(argv[1], "query") == 0)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      shell_printf("power saving : 0x%X, psm chip sleep : 0x%X"NEW_LINE,
 | 
					      shell_printf("power saving : 0x%X, psm chip sleep : 0x%X\n",
 | 
				
			||||||
      tls_wifi_get_psflag(),
 | 
					      tls_wifi_get_psflag(),
 | 
				
			||||||
      tls_wifi_get_psm_chipsleep_flag());
 | 
					      tls_wifi_get_psm_chipsleep_flag());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -327,13 +326,13 @@ int _wifi_sleep(const shell_cmd_t *pcmd, int argc, char *const argv[])
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      shell_printf("Unknown %s action"NEW_LINE, argv[0]);
 | 
					      shell_printf("Unknown %s action\n", argv[0]);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    shell_printf("List of wifi_sleep actions :"NEW_LINE"query"NEW_LINE"set"NEW_LINE);
 | 
					    shell_printf("List of wifi_sleep actions :\nquery\nset\n");
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  return 0;
 | 
					  return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -345,29 +344,29 @@ int _pmu(const shell_cmd_t *pcmd, int argc, char *const argv[])
 | 
				
			|||||||
    if(strcmp(argv[1], "sleep") == 0)
 | 
					    if(strcmp(argv[1], "sleep") == 0)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      u32 duration = strtoul(argv[2], NULL, 10);
 | 
					      u32 duration = strtoul(argv[2], NULL, 10);
 | 
				
			||||||
      shell_printf("Going to sleep mode for %u s"NEW_LINE, duration);
 | 
					      shell_printf("Going to sleep mode for %u s\n", duration);
 | 
				
			||||||
      tls_pmu_timer0_start(duration);
 | 
					      tls_pmu_timer0_start(duration);
 | 
				
			||||||
      tls_pmu_sleep_start();
 | 
					      tls_pmu_sleep_start();
 | 
				
			||||||
      shell_printf("Waking up out of sleep mode"NEW_LINE);
 | 
					      shell_printf("Waking up out of sleep mode\n");
 | 
				
			||||||
      tls_pmu_timer0_stop();
 | 
					      tls_pmu_timer0_stop();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else if(strcmp(argv[1], "standby") == 0)
 | 
					    else if(strcmp(argv[1], "standby") == 0)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      u32 duration = strtoul(argv[2], NULL, 10);
 | 
					      u32 duration = strtoul(argv[2], NULL, 10);
 | 
				
			||||||
      shell_printf("Going to standby mode for %u s"NEW_LINE, duration);
 | 
					      shell_printf("Going to standby mode for %u s\n", duration);
 | 
				
			||||||
      tls_pmu_timer0_start(duration);
 | 
					      tls_pmu_timer0_start(duration);
 | 
				
			||||||
      tls_pmu_standby_start();
 | 
					      tls_pmu_standby_start();
 | 
				
			||||||
      shell_printf("Waking up out of standby mode"NEW_LINE);
 | 
					      shell_printf("Waking up out of standby mode\n");
 | 
				
			||||||
      tls_pmu_timer0_stop();
 | 
					      tls_pmu_timer0_stop();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      shell_printf("Unknown %s action"NEW_LINE, argv[0]);
 | 
					      shell_printf("Unknown %s action\n", argv[0]);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    shell_printf("List of pmu actions :"NEW_LINE"sleep <duration(s)>"NEW_LINE"standby <duration(s)>"NEW_LINE);
 | 
					    shell_printf("List of pmu actions :\nsleep <duration(s)>\nstandby <duration(s)>\n");
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  return 0;
 | 
					  return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -381,7 +380,7 @@ int _rtc(const shell_cmd_t *pcmd, int argc, char *const argv[])
 | 
				
			|||||||
      struct tm rtc_time;
 | 
					      struct tm rtc_time;
 | 
				
			||||||
      tls_get_rtc(&rtc_time);
 | 
					      tls_get_rtc(&rtc_time);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      shell_printf("rtc time is :"NEW_LINE"%d:%d:%d %d/%d/%d"NEW_LINE,
 | 
					      shell_printf("rtc time is :\n%d:%d:%d %d/%d/%d\n",
 | 
				
			||||||
      rtc_time.tm_hour,
 | 
					      rtc_time.tm_hour,
 | 
				
			||||||
      rtc_time.tm_min,
 | 
					      rtc_time.tm_min,
 | 
				
			||||||
      rtc_time.tm_sec,
 | 
					      rtc_time.tm_sec,
 | 
				
			||||||
@ -400,7 +399,7 @@ int _rtc(const shell_cmd_t *pcmd, int argc, char *const argv[])
 | 
				
			|||||||
      rtc_time.tm_mon  = strtoul(argv[6], NULL, 10);
 | 
					      rtc_time.tm_mon  = strtoul(argv[6], NULL, 10);
 | 
				
			||||||
      rtc_time.tm_year  = strtoul(argv[7], NULL, 10);
 | 
					      rtc_time.tm_year  = strtoul(argv[7], NULL, 10);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      shell_printf("Setting rtc to :"NEW_LINE"%d:%d:%d %d/%d/%d"NEW_LINE"isr callback registered !"NEW_LINE,
 | 
					      shell_printf("Setting rtc to :\n%d:%d:%d %d/%d/%d\nisr callback registered !\n",
 | 
				
			||||||
      rtc_time.tm_hour,
 | 
					      rtc_time.tm_hour,
 | 
				
			||||||
      rtc_time.tm_min,
 | 
					      rtc_time.tm_min,
 | 
				
			||||||
      rtc_time.tm_sec,
 | 
					      rtc_time.tm_sec,
 | 
				
			||||||
@ -422,7 +421,7 @@ int _rtc(const shell_cmd_t *pcmd, int argc, char *const argv[])
 | 
				
			|||||||
      rtc_time.tm_mon  = strtoul(argv[6], NULL, 10);
 | 
					      rtc_time.tm_mon  = strtoul(argv[6], NULL, 10);
 | 
				
			||||||
      rtc_time.tm_year  = strtoul(argv[7], NULL, 10);
 | 
					      rtc_time.tm_year  = strtoul(argv[7], NULL, 10);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      shell_printf("Setting rtc alarm to :"NEW_LINE"%d:%d:%d %d/%d/%d"NEW_LINE,
 | 
					      shell_printf("Setting rtc alarm to :\n%d:%d:%d %d/%d/%d\n",
 | 
				
			||||||
      rtc_time.tm_hour,
 | 
					      rtc_time.tm_hour,
 | 
				
			||||||
      rtc_time.tm_min,
 | 
					      rtc_time.tm_min,
 | 
				
			||||||
      rtc_time.tm_sec,
 | 
					      rtc_time.tm_sec,
 | 
				
			||||||
@ -434,12 +433,12 @@ int _rtc(const shell_cmd_t *pcmd, int argc, char *const argv[])
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      shell_printf("Unknown %s action"NEW_LINE, argv[0]);
 | 
					      shell_printf("Unknown %s action\n", argv[0]);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    shell_printf("List of rtc actions :"NEW_LINE"get"NEW_LINE"set <h> <m> <s> <d> <m> <y>"NEW_LINE"alarm <h> <m> <s> <d> <m> <y>"NEW_LINE);
 | 
					    shell_printf("List of rtc actions :\nget\nset <h> <m> <s> <d> <m> <y>\nalarm <h> <m> <s> <d> <m> <y>\n");
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  return 0; 
 | 
					  return 0; 
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -450,30 +449,30 @@ int _bluetooth(const shell_cmd_t *pcmd, int argc, char *const argv[])
 | 
				
			|||||||
  {
 | 
					  {
 | 
				
			||||||
    if(strcmp(argv[1], "enable") == 0)
 | 
					    if(strcmp(argv[1], "enable") == 0)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      //shell_printf("Enabling bluetooth : %d"NEW_LINE, demo_bt_enable());
 | 
					      //shell_printf("Enabling bluetooth : %d\n", demo_bt_enable());
 | 
				
			||||||
      shell_printf("Enabling bluetooth test"NEW_LINE);
 | 
					      shell_printf("Enabling bluetooth test\n");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else if(strcmp(argv[1], "disable") == 0)
 | 
					    else if(strcmp(argv[1], "disable") == 0)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      //shell_printf("Disabling bluetooth : %d"NEW_LINE, demo_bt_destroy());
 | 
					      //shell_printf("Disabling bluetooth : %d\n", demo_bt_destroy());
 | 
				
			||||||
      shell_printf("Disabling bluetooth test"NEW_LINE);
 | 
					      shell_printf("Disabling bluetooth test\n");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else if(strcmp(argv[1], "start_demo") == 0)
 | 
					    else if(strcmp(argv[1], "start_demo") == 0)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      shell_printf("Starting demo : %d"NEW_LINE"Use a BLE app to find the device"NEW_LINE, demo_ble_server_on());
 | 
					      shell_printf("Starting demo : %d\nUse a BLE app to find the device\n", demo_ble_server_on());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else if(strcmp(argv[1], "stop_demo") == 0)
 | 
					    else if(strcmp(argv[1], "stop_demo") == 0)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      shell_printf("Stopping demo : %d"NEW_LINE, demo_ble_server_off());
 | 
					      shell_printf("Stopping demo : %d\n", demo_ble_server_off());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      shell_printf("Unknown %s action"NEW_LINE, argv[0]);
 | 
					      shell_printf("Unknown %s action\n", argv[0]);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    shell_printf("List of bluetooth actions :"NEW_LINE"enable"NEW_LINE"disable"NEW_LINE"start_demo"NEW_LINE"stop_demo"NEW_LINE);
 | 
					    shell_printf("List of bluetooth actions :\nenable\ndisable\nstart_demo\nstop_demo\n");
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  return 0; 
 | 
					  return 0; 
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -481,40 +480,40 @@ int _bluetooth(const shell_cmd_t *pcmd, int argc, char *const argv[])
 | 
				
			|||||||
NANO_SHELL_ADD_CMD(system,
 | 
					NANO_SHELL_ADD_CMD(system,
 | 
				
			||||||
                   _system,
 | 
					                   _system,
 | 
				
			||||||
                   "Query system information",
 | 
					                   "Query system information",
 | 
				
			||||||
                   "  Use this command to get system information"NEW_LINE);
 | 
					                   "  Use this command to get system information\r\n");
 | 
				
			||||||
NANO_SHELL_ADD_CMD(reset,
 | 
					NANO_SHELL_ADD_CMD(reset,
 | 
				
			||||||
                   _reset,
 | 
					                   _reset,
 | 
				
			||||||
                   "Reset the system",
 | 
					                   "Reset the system",
 | 
				
			||||||
                   "  Use this command reset the system"NEW_LINE);
 | 
					                   "  Use this command reset the system\r\n");
 | 
				
			||||||
NANO_SHELL_ADD_CMD(soft_ap,
 | 
					NANO_SHELL_ADD_CMD(soft_ap,
 | 
				
			||||||
                   _soft_ap,
 | 
					                   _soft_ap,
 | 
				
			||||||
                   "Command to control SOFT AP",
 | 
					                   "Command to control SOFT AP",
 | 
				
			||||||
                   "  Use this command to control the SOFT AP subsystem"NEW_LINE);
 | 
					                   "  Use this command to control the SOFT AP subsystem\r\n");
 | 
				
			||||||
NANO_SHELL_ADD_CMD(station,
 | 
					NANO_SHELL_ADD_CMD(station,
 | 
				
			||||||
                   _station,
 | 
					                   _station,
 | 
				
			||||||
                   "Command to control STATION mode",
 | 
					                   "Command to control STATION mode",
 | 
				
			||||||
                   "  Use this command to connect to a WiFi access point"NEW_LINE);
 | 
					                   "  Use this command to connect to a WiFi access point\r\n");
 | 
				
			||||||
NANO_SHELL_ADD_CMD(wifi,
 | 
					NANO_SHELL_ADD_CMD(wifi,
 | 
				
			||||||
                   _wifi,
 | 
					                   _wifi,
 | 
				
			||||||
                   "Command to control WIFI interface",
 | 
					                   "Command to control WIFI interface",
 | 
				
			||||||
                   "  Use this command to control the WIFI interface"NEW_LINE);
 | 
					                   "  Use this command to control the WIFI interface\r\n");
 | 
				
			||||||
NANO_SHELL_ADD_CMD(cpu_temp,
 | 
					NANO_SHELL_ADD_CMD(cpu_temp,
 | 
				
			||||||
                   _cpu_temp,
 | 
					                   _cpu_temp,
 | 
				
			||||||
                   "Command to read the CPU temperature",
 | 
					                   "Command to read the CPU temperature",
 | 
				
			||||||
                   "  Use this command to read the CPU temperature"NEW_LINE);
 | 
					                   "  Use this command to read the CPU temperature\r\n");
 | 
				
			||||||
NANO_SHELL_ADD_CMD(wifi_sleep,
 | 
					NANO_SHELL_ADD_CMD(wifi_sleep,
 | 
				
			||||||
                   _wifi_sleep,
 | 
					                   _wifi_sleep,
 | 
				
			||||||
                   "Command to control WiFi sleep",
 | 
					                   "Command to control WiFi sleep",
 | 
				
			||||||
                   "  Use this command to control WiFi sleep feature"NEW_LINE);
 | 
					                   "  Use this command to control WiFi sleep feature\r\n");
 | 
				
			||||||
NANO_SHELL_ADD_CMD(pmu,
 | 
					NANO_SHELL_ADD_CMD(pmu,
 | 
				
			||||||
                   _pmu,
 | 
					                   _pmu,
 | 
				
			||||||
                   "Command to control the power management unit",
 | 
					                   "Command to control the power management unit",
 | 
				
			||||||
                   "  Use this command to control power management unit feature"NEW_LINE);
 | 
					                   "  Use this command to control power management unit feature\r\n");
 | 
				
			||||||
NANO_SHELL_ADD_CMD(rtc,
 | 
					NANO_SHELL_ADD_CMD(rtc,
 | 
				
			||||||
                   _rtc,
 | 
					                   _rtc,
 | 
				
			||||||
                   "Command to query and set up the rtc",
 | 
					                   "Command to query and set up the rtc",
 | 
				
			||||||
                  "  Use this command to interact with the rtc module"NEW_LINE);
 | 
					                  "  Use this command to interact with the rtc module\n");
 | 
				
			||||||
NANO_SHELL_ADD_CMD(bluetooth,
 | 
					NANO_SHELL_ADD_CMD(bluetooth,
 | 
				
			||||||
                   _bluetooth,
 | 
					                   _bluetooth,
 | 
				
			||||||
                   "Command to control bluetooth functionality",
 | 
					                   "Command to control bluetooth functionality",
 | 
				
			||||||
                  "  Use this command to interact use bluetooth"NEW_LINE);
 | 
					                  "  Use this command to interact use bluetooth\n");
 | 
				
			||||||
 | 
				
			|||||||
@ -64,8 +64,6 @@ int shell_getc(char *ch)
 | 
				
			|||||||
    return 1;
 | 
					    return 1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool got_linefeed = false;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void low_level_write_char(char ch)
 | 
					void low_level_write_char(char ch)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    (void)sendchar((int)ch);
 | 
					    (void)sendchar((int)ch);
 | 
				
			||||||
 | 
				
			|||||||
@ -1,119 +1,6 @@
 | 
				
			|||||||
#include "string.h"
 | 
					 | 
				
			||||||
#include "lwip/netif.h"
 | 
					 | 
				
			||||||
#include "wm_include.h"
 | 
					 | 
				
			||||||
#include "FreeRTOS.h"
 | 
					 | 
				
			||||||
#include "FreeRTOSConfig.h"
 | 
					 | 
				
			||||||
#include "nano_shell_server_task.h"
 | 
					#include "nano_shell_server_task.h"
 | 
				
			||||||
#include "common.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
extern int shell_printf(const char *format, ...);
 | 
					 | 
				
			||||||
extern void network_rx_callback(u16 len, char *data);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int nano_shell_srv_sock = 0, client_sock = 0;
 | 
					 | 
				
			||||||
const char greeting_buffer[] = "\r\n"
 | 
					 | 
				
			||||||
             " _   _                     ____  _          _ _\r\n"
 | 
					 | 
				
			||||||
             "| \\ | | __ _ _ __   ___   / ___|| |__   ___| | |\r\n"
 | 
					 | 
				
			||||||
             "|  \\| |/ _` | '_ \\ / _ \\  \\___ \\| '_ \\ / _ \\ | |\r\n"
 | 
					 | 
				
			||||||
             "| |\\  | (_| | | | | (_) |  ___) | | | |  __/ | |\r\n"
 | 
					 | 
				
			||||||
             "|_| \\_|\\__,_|_| |_|\\___/  |____/|_| |_|\\___|_|_|\r\n"
 | 
					 | 
				
			||||||
             "\r\n"
 | 
					 | 
				
			||||||
             "Welcome to Nano-Shell remote access\r\n"
 | 
					 | 
				
			||||||
             "\r\n"
 | 
					 | 
				
			||||||
             " * Source:    https://github.com/lebinlv/nano-shell\r\n"
 | 
					 | 
				
			||||||
             " * Copyright: (c) Liber 2020\r\n"
 | 
					 | 
				
			||||||
             "\r\n";
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
void network_write(char c)
 | 
					void network_write(char c)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    if(client_sock > 0)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        if(send(client_sock, &c, 1, 0) < 0)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            shell_printf("Failed to send data to client - errno(%d)."NEW_LINE, errno);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void nano_shell_server_task(void* param)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    (void)param;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    bool setup_error = false;
 | 
					 | 
				
			||||||
    char recv_buffer[256] = "";
 | 
					 | 
				
			||||||
    //We setup the listening socket :
 | 
					 | 
				
			||||||
    struct sockaddr_in nano_shell_srv_addr = { .sin_family = AF_INET, .sin_addr.s_addr = INADDR_ANY, .sin_port = htons(NANO_SHELL_SERVER_PORT)}, client_addr;
 | 
					 | 
				
			||||||
    socklen_t sockaddr_in_len = sizeof(struct sockaddr_in);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if((nano_shell_srv_sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        shell_printf("Failed to create nano_shell listening socket."NEW_LINE);
 | 
					 | 
				
			||||||
        setup_error = true;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if(bind(nano_shell_srv_sock, (struct sockaddr *) &nano_shell_srv_addr, sockaddr_in_len) < 0)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        shell_printf("Failed to bind nano_shell listening socket to addr."NEW_LINE);
 | 
					 | 
				
			||||||
        setup_error = true;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    //We only wait for one connection at a time because the nano_shell is not multi user anyway
 | 
					 | 
				
			||||||
    if(listen(nano_shell_srv_sock, 0) < 0)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        shell_printf("Failed to mark nano_shell_sock as a listening socket."NEW_LINE);
 | 
					 | 
				
			||||||
        setup_error = true;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if(setup_error)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        for(;;)
 | 
					 | 
				
			||||||
            tls_os_time_delay(portMAX_DELAY);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    for(;;)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        if((client_sock = accept(nano_shell_srv_sock, (struct sockaddr *)&client_addr, &sockaddr_in_len)) < 0)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            shell_printf("Failed to accept incoming connection."NEW_LINE);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if(send(client_sock, greeting_buffer, sizeof greeting_buffer, 0) < 0)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            shell_printf("Failed to send greetings to client - errno(%d)."NEW_LINE, errno);
 | 
					 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
        for(;client_sock > 0;)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            int result = recv(client_sock, recv_buffer, 255, 0);
 | 
					 | 
				
			||||||
            if(result < 0)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                shell_printf("Failed to receive data from client - errno(%d)."NEW_LINE"Closing connection."NEW_LINE, errno);
 | 
					 | 
				
			||||||
                if(close(client_sock) < 0)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    shell_printf("Failed to close socket - errno(%d)."NEW_LINE, errno);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                client_sock = 0;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            else if(result == 0)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                shell_printf("Client disconnected."NEW_LINE);
 | 
					 | 
				
			||||||
                if(close(client_sock) < 0)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    shell_printf("Failed to close socket - errno(%d)."NEW_LINE, errno);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                client_sock = 0;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            else //We pass the received data to the nano shell process
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                //Need to remove the \n at the end
 | 
					 | 
				
			||||||
                char *pos = strchr(recv_buffer, '\r');
 | 
					 | 
				
			||||||
                if(pos)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    *pos = '\n';
 | 
					 | 
				
			||||||
                    result = pos + 1 - recv_buffer;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                network_rx_callback(result, recv_buffer);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }  
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -1,3 +0,0 @@
 | 
				
			|||||||
#define NANO_SHELL_SERVER_PORT 21 
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void nano_shell_server_task(void* param);
 | 
					 | 
				
			||||||
@ -835,33 +835,6 @@ typedef QueueHandle_t SemaphoreHandle_t;
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
#define xSemaphoreGetMutexHolder( xSemaphore ) xQueueGetMutexHolder( ( xSemaphore ) )
 | 
					#define xSemaphoreGetMutexHolder( xSemaphore ) xQueueGetMutexHolder( ( xSemaphore ) )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * semphr.h
 | 
					 | 
				
			||||||
 * @code{c}
 | 
					 | 
				
			||||||
 * UBaseType_t uxSemaphoreGetCount( SemaphoreHandle_t xSemaphore );
 | 
					 | 
				
			||||||
 * @endcode
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * If the semaphore is a counting semaphore then uxSemaphoreGetCount() returns
 | 
					 | 
				
			||||||
 * its current count value.  If the semaphore is a binary semaphore then
 | 
					 | 
				
			||||||
 * uxSemaphoreGetCount() returns 1 if the semaphore is available, and 0 if the
 | 
					 | 
				
			||||||
 * semaphore is not available.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
#define uxSemaphoreGetCount( xSemaphore ) uxQueueMessagesWaiting( ( QueueHandle_t ) ( xSemaphore ) )
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * semphr.h
 | 
					 | 
				
			||||||
 * @code{c}
 | 
					 | 
				
			||||||
 * UBaseType_t uxSemaphoreGetCountFromISR( SemaphoreHandle_t xSemaphore );
 | 
					 | 
				
			||||||
 * @endcode
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * If the semaphore is a counting semaphore then uxSemaphoreGetCountFromISR() returns
 | 
					 | 
				
			||||||
 * its current count value.  If the semaphore is a binary semaphore then
 | 
					 | 
				
			||||||
 * uxSemaphoreGetCountFromISR() returns 1 if the semaphore is available, and 0 if the
 | 
					 | 
				
			||||||
 * semaphore is not available.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
#define uxSemaphoreGetCountFromISR( xSemaphore ) uxQueueMessagesWaitingFromISR( ( QueueHandle_t ) ( xSemaphore ) )
 | 
					 | 
				
			||||||
#endif /* SEMAPHORE_H */
 | 
					#endif /* SEMAPHORE_H */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -515,7 +515,7 @@ tls_os_status_t tls_os_task_resume_from_isr(tls_os_task_t task)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
u16 tls_os_sem_get_count(tls_os_sem_t *sem)
 | 
					u16 tls_os_sem_get_count(tls_os_sem_t *sem)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    return (u16)uxSemaphoreGetCount((xQUEUE *)sem);
 | 
					    return (u16)xSemaphoreGetCount((xQUEUE *)sem);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user