I’m trying to add a local service from android like below:
val record: Map<String, String> = mapOf(
"buddyname" to "John Doe${(Math.random() * 1000).toInt()}",
"available" to "visible"
)
val serviceInfo = WifiP2pDnsSdServiceInfo.newInstance("android","app",record)
mManager.addLocalService(mChannel,serviceInfo,actionListener)
And trying to discover the service from wpa_cli in (RASPBERRY PI OS) linux using the below command:
p2p_serv_disc_req 00:00:00:00:00:00 02000001
Response:
5f9…(Some Identifier for Request)
But this returns a identifier that can be used to cancel the request. I’ve seen online in the examples wpa_cli returns events showing the response for the request. I’ve tried control sockets with python but still receiving the same response.
I want to receive the service advertised in android in the linux ideally from a python script.
Both the devices are able to discover each other, Correct me if I’m wrong but I’m assuming the there is no prior connection required to fetch the available services for WiFi Direct.
Thank you in advance.
Any help is appreciated.
Attaching Python Script:
import os
import select
import socket
interface = "wlan0"
wpa_send_path = "/run/wpa_supplicant/"+interface
wpa_recv_path = "/tmp/wpa_ctrl_{pid}-{count}".format(pid=os.getpid(), count=1)
soc = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM, 0)
soc.bind(wpa_recv_path)
soc.connect(wpa_send_path)
soc.send(b"ATTACH")
print("> P2P FIND")
soc.send(b"P2P_FIND")
# Start receiving events
message_count = 0
while message_count < 5:
print("<", soc.recv(4096).decode().strip())
print("> P2P ")
soc.send(b"P2P_SERV_DISC_REQ ce:9f:7a:92:98:60 02000001")
message_count += 1
print("> DEATTACH")
soc.send(b"DEATTACH")
print("<", soc.recv(4096).decode().strip())