framework/src/st_things/things_stack/utils/things_network.c
//--------------------------------------------------------------------------------
/**
 * Function definition for get ap list from globally stored scan list.
 * When things want to get the ap scan results that time this api is call and send
 * the result to the things.
 */
Function definition for get ap list from globally stored scan list.
When things want to get the ap scan results that time this api is call and send
the result to the things.
Function definition for get ap list from globally stored scan list . When things want to get the ap scan results that time this api is call and send the result to the things .
int things_get_ap_list(access_point_info_s** p_info, int* p_count)
{
	if (p_info == NULL || p_count == NULL) {
		THINGS_LOG_E(TAG, "Can't Call GetAPSearchList(p_info=0x%X, p_count=0x%X).", p_info, p_count);
		return 0;
	}
	pthread_mutex_lock(&g_ap_list_mutex);
	*p_count = g_wifi_count;
	access_point_info_s *wifi_scan_iter = g_wifi_scan_info;
	access_point_info_s *pinfo = NULL;
	access_point_info_s *p_last_info = NULL;
	while (wifi_scan_iter != NULL) {
		if (wifi_scan_iter->e_ssid != NULL) {
			pinfo = (access_point_info_s*)things_malloc(sizeof(access_point_info_s));
			pinfo->next = NULL;
			snprintf(pinfo->e_ssid, WIFIMGR_SSID_LEN, "%s", wifi_scan_iter->e_ssid);	
			snprintf(pinfo->bss_id, WIFIMGR_MACADDR_STR_LEN, "%s", wifi_scan_iter->bss_id);	
			snprintf(pinfo->signal_level, MAX_LEVEL_SIGNAL, "%d", wifi_scan_iter->signal_level);	
			snprintf(pinfo->sec_type, MAX_TYPE_SEC, "%s", wifi_scan_iter->sec_type);		
			snprintf(pinfo->enc_type, MAX_TYPE_ENC, "%s", wifi_scan_iter->enc_type);		
			if (*p_info == NULL) {
				*p_info = pinfo;
			} else {
				p_last_info->next = pinfo;
			}
			p_last_info = pinfo;
		}
		wifi_scan_iter = wifi_scan_iter->next;
	}
	pthread_mutex_unlock(&g_ap_list_mutex);
	return 1;
}
int things_get_ap_list ( access_point_info_s * * p_info , int * p_count ) { if ( p_info == NULL || p_count == NULL ) { THINGS_LOG_E ( TAG , " " , p_info , p_count ) ; return 0 ; } pthread_mutex_lock ( & g_ap_list_mutex ) ; * p_count = g_wifi_count ; access_point_info_s * wifi_scan_iter = g_wifi_scan_info ; access_point_info_s * pinfo = NULL ; access_point_info_s * p_last_info = NULL ; while ( wifi_scan_iter != NULL ) { if ( wifi_scan_iter -> e_ssid != NULL ) { pinfo = ( access_point_info_s * ) things_malloc ( sizeof ( access_point_info_s ) ) ; pinfo -> next = NULL ; snprintf ( pinfo -> e_ssid , WIFIMGR_SSID_LEN , " " , wifi_scan_iter -> e_ssid ) ; snprintf ( pinfo -> bss_id , WIFIMGR_MACADDR_STR_LEN , " " , wifi_scan_iter -> bss_id ) ; snprintf ( pinfo -> signal_level , MAX_LEVEL_SIGNAL , " " , wifi_scan_iter -> signal_level ) ; snprintf ( pinfo -> sec_type , MAX_TYPE_SEC , " " , wifi_scan_iter -> sec_type ) ; snprintf ( pinfo -> enc_type , MAX_TYPE_ENC , " " , wifi_scan_iter -> enc_type ) ; if ( * p_info == NULL ) { * p_info = pinfo ; } else { p_last_info -> next = pinfo ; } p_last_info = pinfo ; } wifi_scan_iter = wifi_scan_iter -> next ; } pthread_mutex_unlock ( & g_ap_list_mutex ) ; return 1 ; }
Function definition for get ap list from globally stored scan list.
Function definition for get ap list from globally stored scan list .
// Copy the total wifi count list from global stored value. // Copy the starting location of wifi scan list from global stored list. // Copy the globally scan result into p_info list. // Create dynamic memory for pinfo list. // Set the ssid. // Set the mac address. // Set the signal level. // Set the sec type. // Set the enc type. // Move to the 2nd element of the list.