2

I am trying to get WiFi Direct (aka wifi p2p) to run on Android Things 1.0.1, Api version 27, Raspberry Pi 3. I am following this demo on Android Developers Demo web site.

The problem is the line:
mManager = (WifiP2pManager) getSystemService(Context.WIFI_P2P_SERVICE);

always returns null.

Questions:

1) How do I get this example to run? Does Wifi Direct run in Android Things?

2) Is there an alternative to WiFi direct that will allow the Raspberry Pi to connect to a Android tablet or iOS tablet running a browser, one that does not require a stand alone wifi router/hub?

3) Am I missing some reason that would prevent Wifi Direct from being implemented in the future?

fishjd
  • 1,617
  • 1
  • 18
  • 31
  • Possible duplicate of [WiFi P2P network in Android Things](https://stackoverflow.com/questions/47547864/wifi-p2p-network-in-android-things) – Andrii Omelchenko Jul 02 '18 at 10:04

1 Answers1

0

If what you want is the Android things to work as a web server, you can use nanoHttpd for it. But as far as I understand, the connection method and it being a server are quite unrelated questions.

You can see an example of nanoHttpd on Android things here: https://github.com/plattysoft/SmartPopcorn/tree/nanohttpd-api?files=1

shalafi
  • 3,926
  • 2
  • 23
  • 27
  • Correct, Thanks for your answer. The android app is using nanoHttpd, The important part of my question is 'Does WiFi Direct or some other tech allow me to connect to an Android Tablet?' – fishjd Jul 02 '18 at 13:46
  • What I have done myself is to create a REST API using nanoHttpd and then write a mobile app using retrofit. As long as you use the IP protocol, the lower layer is irrelevant. – shalafi Jul 02 '18 at 18:13
  • Shalifi, you are correct the lower level is irrelevant in most cases. The application runs in a secure environment with no WiFi and a WiFi router is not allowed. The app works great using Android Things, NanoHttpd and a WiFi router. How to eliminate the router? WiFi Direct would be the ideal solution, but it does not work. Setting the Raspberry Pi as hot spot doesn't work on Android Things either. – fishjd Jul 02 '18 at 20:48
  • We are deviating from the question, but have you considered using nearby instead? It's quite handy and it's designed to work as a mesh network with advertising and discovery mechanisms – shalafi Jul 03 '18 at 19:07
  • The truth is that we are deviating towards the question I would like an answer to. Which is: How to get WiFi Direct or WiFi Hot spot to work on Android Things? Google Nearby looks like it may work as a replacement but has many severe and painful limitations and requirements. – fishjd Jul 16 '18 at 14:48