void p2p_role(struct p2p *p, int flag) { FILE *pf=NULL; memset( p->cmd, 0x00, CMD_SZ ); sprintf( p->cmd, "iwpriv %s p2p_get role > status.txt", p->ifname); system( p->cmd ); pf = fopen( "./status.txt", "r" ); if ( pf ) { while( !feof( pf ) ){ memset( p->parse, 0x00, CMD_SZ ); fgets( p->parse, CMD_SZ, pf ); if( strncmp( p->parse, "Role", 4) == 0 ) { p->role = atoi( &p->parse[ 5 ] ); if(flag==1){ p->p2p_get=1; sprintf( p->print_line, "Role=%s", naming_role(p->role)); } break; } } fclose( pf ); } }
void ui_screen(struct p2p *p) { system("clear"); printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); printf("****************************************************************************************************\n"); printf("* P2P UI TEST v0.5 *\n"); printf("****************************************************************************************************\n"); printf("* Enable: %-89s*\n", naming_enable(p->enable)); printf("* Intent: %2d *\n", p->intent); printf("* Status: %-89s*\n", naming_status(p->status)); printf("* Role: %-91s*\n", naming_role(p->role)); printf("* WPS method: %-85s*\n", naming_wpsinfo(p->wps_info)); printf("* PIN code: %08d *\n", p->pin); printf("* Device name: %-84s*\n", p->dev_name); printf("* Peer device address: %-76s*\n", p->peer_devaddr); printf("* Peer interface address: %-73s*\n", p->peer_ifaddr); printf("* *\n"); printf("* e) Wi-Fi Direct Enable/Disable *\n"); printf("* i) Intent ( The degree to be Group Owner/SoftAP ) *\n"); printf("* a) Scan Wi-Fi Direct devices *\n"); printf("* m) Peer device address you want to test *\n"); printf("* p) Provision discovery *\n"); printf("* c) Input PIN codes *\n"); printf("* w) WPS method *\n"); printf("* n) Group owner negotiation *\n"); printf("* x) Start wpa_supplicant/hostapd *\n"); printf("* h) Set operation channel | t) Set SoftAP ssid *\n"); printf("* r) Get Current P2P Role | s) Get Current P2P Status *\n"); printf("* d) Set device name | l) Set Listen channel *\n"); printf("* f) Reflash Current State | q) Quit *\n"); printf("****************************************************************************************************\n"); if(p->p2p_get==0) { printf("* *\n"); } else if(p->p2p_get==1) { printf("*%-98s*\n", p->print_line); } printf("****************************************************************************************************\n"); if( ( p->show_scan_result == 1 ) && ( p->have_p2p_dev == 1 ) ) //if( (p->have_p2p_dev == 1) && (p->enable >= P2P_ROLE_DEVICE) && ( p->wpsing == 0 ) && (p->status >= P2P_STATE_LISTEN && p->status <= P2P_STATE_FIND_PHASE_SEARCH) ) { scan_result(p); } else { int i=0; for(i = 0; i < SCAN_POOL_NO + 1; i++ ) printf("* *\n"); } printf("****************************************************************************************************\n"); p->show_scan_result = 0; }