直接贴代码:
void AnalysisCommand::setSSID()
{
printf("----------SetSSID----------\n");
char ssid[64] = {0};
char passworld[64] = {0};
int retval = g_configuretable.GetSSID(ssid);
int retval2 = g_configuretable.GetPassword(passworld);
if(!retval&&!retval2)
{
char creat_conf[128]={0};
char add_network[128]={0};
char cmd_ssid[128] = {0};
char cmd_pwd[128] = {0};
char shut_wpa[128] = {0};
char start_wpa[128] = {0};
char select_network[128]={0};
sprintf(creat_conf,"echo \"ctrl_interface=/var/run/wpa_supplicant\" > /wpa.conf");
sprintf(add_network,"wpa_cli add_network");
sprintf(cmd_ssid,"wpa_cli set_network 0 ssid \\\"%s\\\"",ssid);
if( strlen(passworld)!=0)
{
sprintf(cmd_pwd,&