I need to create a program who communicate with direct wifi between a litle card and a android. I have done a "iw list" and i got : Supported interface modes: * IBSS * managed * AP * monitor * P2P-client * P2P-GO So, normally, that should do it. I have found this web-site : https://w1.fi/wpa_supplicant/devel/index.html to use wpa_applicant in a c code. So, I used like they said wpa_ctrl.c CODE:
#include <stdio.h>
#include "direct.h"
#include "wpa_ctrl.h"
#include <string.h>
void function_test_call(char *msg, size_t len)
{
printf("message callback %s\n", msg);
printf("len callback %d\n", len);
}
int main()
{
struct wpa_ctrl *wpa_path;
const char *path = "/var/run/wpa_supplicant/wlan0";
wpa_path = (void*)0;
wpa_path = wpa_ctrl_open(path);
if (wpa_path)
{
printf("youpi\n");
}
else
{
printf("pas youpi\n");
return (1);
}
char response[1024];
size_t size_buf = 0;
int ret = wpa_ctrl_request(wpa_path, "PING",
4, response, &size_buf, function_test_call);
printf("ret value %d\n", ret);
printf("response size %d\n", size_buf);
printf("reponse : %s\n", response);
return (0);
}
this is what's append when i run : youpi ret value 0 response size 0 reponse :
So the connection is ok, but the REQUEST ping should be PONG or i got nothing. Please help me :)