How to find the ssid name?

Do anyone have the sample code of how to find the ssid name if we didn’t input it all?

for example :
I want to find the ssid name that start with “Buffalo” and the full name is “Buffalo-xxxx”.
How can I write it?

you can try

wifi client scan |grep “Buffalo”

can i write it right this?

LE_FATAL_IF(LE_OK == le_wifiClient_Scan(),"SCAN SUCCESSED");
	AccessPointRefToConnectTo = le_wifiClient_GetFirstAccessPoint();
	if(le_wifiClient_GetSsid(AccessPointRefToConnectTo,ssidd,&ssids) == LE_OK){
		p1 = strstr((char*)ssidd,ssidkey);
		if(p1 == NULL){
			for(;;){
				AccessPointRefToConnectTo = le_wifiClient_GetFirstAccessPoint();
				if(le_wifiClient_GetSsid(AccessPointRefToConnectTo,ssidd,&ssids) == LE_OK){
					p1 = strstr((char*)ssidd,ssidkey);
					if(p1 != NULL){
						break;
					}
				}
			}
		}
	}

you can run and debug your code

Mar 17 13:47:44 swi-mdm9x28-wp user.emerg Legato: EMR | NAD[27523]/NADComponent T=main | wifi.c wifi_init() 487 | SCAN SUCCESSED
Mar 17 13:48:19 swi-mdm9x28-wp user.info Legato: INFO | supervisor[827]/supervisor T=main | proc.c proc_SigChildHandler() 2051 | Process ‘NAD’ (PID: 27523) has exited with exit code 1.
Mar 17 13:48:19 swi-mdm9x28-wp user.warn Legato: -WRN- | supervisor[827]/supervisor T=main | app.c app_SigChildHandler() 4015 | Process ‘NAD’ in app ‘NAD’ faulted: Ignored.
Mar 17 13:48:19 swi-mdm9x28-wp user.info Legato: INFO | supervisor[827]/supervisor T=main | app.c app_StopComplete() 4686 | app ‘NAD’ has stopped.
Mar 17 13:48:19 swi-mdm9x28-wp user.info Legato: INFO | supervisor[827]/supervisor T=main | apps.c DeactivateAppContainer() 374 | Application ‘NAD’ has stopped.

I think It error because of this line
AccessPointRefToConnectTo = le_wifiClient_GetFirstAccessPoint();

how can I do?

you can see how legato works with the wifi command and use the le_wifiClient_GetFirstAccessPoint()

got same error. How to fixed?

this the code i have write now

LE_FATAL_IF(LE_OK == le_wifiClient_Scan(),"SCAN SUCCESSED");
	if (NULL != (AccessPointRefToConnectTo = le_wifiClient_GetFirstAccessPoint())){
		//AccessPointRefToConnectTo = le_wifiClient_GetFirstAccessPoint();
		//p1 = strstr((char*)ssidd,ssidkey);
		LE_FATAL_IF(LE_OK != le_wifiClient_GetSsid(AccessPointRefToConnectTo,ssidd,&ssids),"ERROR");
		if(le_wifiClient_GetSsid(AccessPointRefToConnectTo,ssidd,&ssids) == LE_OK){
			p1 = strstr((char*)ssidd,ssidkey);
			LE_INFO("%s: %s: %s",ssidd,ssidkey,p1);
			if(p1 == NULL){
				for(;;){
					AccessPointRefToConnectTo = le_wifiClient_GetFirstAccessPoint();
					if(le_wifiClient_GetSsid(AccessPointRefToConnectTo,ssidd,&ssids) == LE_OK){
						p1 = strstr((char*)ssidd,ssidkey);
						LE_INFO("%s: %s: %s",ssidd,ssidkey,p1);
						if(p1 != NULL){
							break;
						}
					}
				}
			}
		}
	}
	else
	{
		LE_INFO("AccessPointRefToConnectTo NULL");
	}

why it is ok to use wifi command in console?

yes. I can use wifi client scan | grep “”
Screenshot from 2022-03-17 14-51-30

then that mean the code is working fine?

Mar 17 18:15:29 swi-mdm9x28-wp user.debug Legato:  DBUG | wifiService[872]/daemon T=main | le_wifiClient.c le_wifiClient_GetNextAccessPoint() 823 | Get next AP
Mar 17 18:15:29 swi-mdm9x28-wp user.debug Legato:  DBUG | wifiService[872]/daemon T=main | le_wifiClient.c IsScanRunning() 515 | IsScanRunning .0
Mar 17 18:15:29 swi-mdm9x28-wp user.debug Legato:  DBUG | wifiService[872]/daemon T=main | le_wifiClient.c le_wifiClient_GetNextAccessPoint() 840 | AP ref = 0x10000001
Mar 17 18:15:29 swi-mdm9x28-wp user.debug Legato:  DBUG | wifiService[872]/daemon T=main | le_wifiClient.c le_wifiClient_GetNextAccessPoint() 850 | AP ref = 0x10000001
Mar 17 18:15:29 swi-mdm9x28-wp user.debug Legato:  DBUG | wifiService[872]/daemon T=main | le_wifiClient.c le_wifiClient_GetSsid() 970 | AP ref 0x10000001
Mar 17 18:15:29 swi-mdm9x28-wp user.err Legato: =ERR= | wifiService[872]/daemon T=main | le_wifiClient.c le_wifiClient_GetSsid() 985 | SSID buffer length (13) is too small to contain SSID of length (19)

what “=ERR= | wifiService[872]/daemon T=main | le_wifiClient.c le_wifiClient_GetSsid() 985 | SSID buffer length (13) is too small to contain SSID of length (19)” mean?

you can see the source code here: