WiFi P2P network in Android Things - bluetooth

I would like to create a P2P WiFi network using Android Things (5.1) and a couple of Raspberry Pi 3 or alternatively using Bluetooth. I followed the guide in the Android Developer section https://developer.android.com/guide/topics/connectivity/wifip2p.html, so my MainActivity looks like:
private class MainActtivity {
private WifiP2pManager mManager;
....
#Override
public void onCreate(Bundle savedInstances) {
mManager = (WifiP2pManager)
getSystemService(Context.WIFI_P2P_SERVICE);
....
}
}
However when I try to run the app, with WiFI enabled, the SystemServiceRegistry shows a message stating No service published for: wifip2p and the WifiP2pManager is not retrieved.
How can I solve this issue? Does anybody know if it is possible to create a WiFi P2P network using WiFi Direct and Android Things?

As of now (Android things stable release 1.0) WifiP2P is not supported on RPI3B,Hence try to use Google NearBy 2.0 API as alternative I think it will satisfy your need.

Related

Azure Speech Recognition not detecting microphone SPXERR_MIC_NOT_FOUND

I have a small sample application to test speech recog. It works in some machines but not in other machines. In my dev environment where I first installed the necessary packages, it all worked 100% with no issues. But, my team mates are unable to get it working with the installation of our software that has this code in it. We have mixed environments where in some cases we are using Remote Desktop with the application running on the remote machine (so with the device integration via RDP). And also locally without RDP. It does not detect the mic in both cases. Windows detects the mic. The recorder app works and testing all works so we know the mic is being recognized by windows.
However, the speech SDK does not recognize it.
I have tried 2 ways. First ,with using the FromDefaultMicrophoneInput But with that not working, i changed it to FromMicrophoneInput instead and specifed the microphone ID.
Using NAudio to enumerate the microphones, the mic is detected and listed:
var enumerator = new MMDeviceEnumerator();
string specifiedMicID = string.Empty;
foreach (var endpoint in
enumerator.EnumerateAudioEndPoints(DataFlow.Capture, DeviceState.Active))
{
if (endpoint.FriendlyName != this.MicName)
continue;
else
{
specifiedMicID = endpoint.ID;
break;
}
}
audioConfig = AudioConfig.FromMicrophoneInput(specifiedMicID);
But, when trying to instantiate the SpeechRecognizer with that audio config:
using (var recognizer = new SpeechRecognizer(config, audioConfig))
{
...
}
We get the SPXERR_MIC_NOT_FOUND. Even thought it is clearly there and working in all other cases in windows and with Naudio detecting it fine.
Any ideas what is going on here?
Thank youj.
Are you creating a UWP application? If so, you'll need to retrieve the audio device IDs differently:
var devices = await DeviceInformation.FindAllAsync(DeviceClass.AudioCapture);
foreach (var device in devices)
{
Console.WriteLine($"{device.Name}, {device.Id}\n");
}
Please refer to the documentation here for more information:
https://learn.microsoft.com/en-us/azure/cognitive-services/speech-service/how-to-select-audio-input-devices#audio-device-ids-on-uwp
If you're still having issues, we'd need to get the SDK logs to debug further. Instructions on how to turn on logging can be found here:
https://learn.microsoft.com/en-us/azure/cognitive-services/speech-service/how-to-use-logging

How to programmatically open the Bluetooth settings in iOS 10

I'm trying to access the Bluetooth settings through my application using swift.how can access bluetooth setting?
Xcode version - 8.0
swift - 2.3
iOS - 10
func openBluetooth(){
let url = URL(string: "App-Prefs:root=Bluetooth") //for bluetooth setting
let app = UIApplication.shared
app.openURL(url!)
}
Swift 3.0: working up to iOS 10
Note: This URL is "private API". The app will be rejected by App Store reviewers if used.
You will not be able to use the solution by #Siddharth jain. The Problem: The app will be rejected by Apple with a warning that you should never use non-public APIs anymore. Otherwise, you could risk your developer program.
As far as I know, all you can do is open the iPhone settings in general (or get lead to your app settings if there are some. To do so you need the following code
guard let url = URL(string: UIApplication.openSettingsURLString) else {
// Handling errors that should not happen here
return
}
let app = UIApplication.shared
app.open(url)
By this, you will always get a URL you can use without any problems with apple review.
Until now you cannot access to bluetooth settings from your app from iOS 10.
you can see the following link to keep your mind at peace.
https://forums.developer.apple.com/message/146658#146658
Opening the Settings app from another app
Now that iOS 15 seemed to have broken auto-reconnect for known Bluetooth devices (other than audio gadgets), it's extremely annoying. If someone finds a solution, App Store-safe or not, I'm all ears.

Connect Wifi in MS Universal windows app?

We know an iOS app can connect to Wifi with CaptiveNetwork reference. As described in some related post: Connect WiFi Network via App.
Is there any similar library to help a Windows app to view exising wifi around and get connected?
Yes. There's the Windows.Devices.Wifi namespace. (Details here https://msdn.microsoft.com/en-us/library/windows/apps/windows.devices.wifi.aspx?f=255&MSPPError=-2147217396 )
It offers Methods to list networks and a method called ConnectAsync() to connect. I once coded a sample here (it also covers other stuff): https://github.com/DanielMeixner/w10demoking/blob/master/Windows10DemoKing/wifi.xaml.cs
The magic lines of code are
using Windows.Devices.WiFi;
// create network adatper instance (see sample code in link above) ...
var nw = nwAdapter.NetworkReport.AvailableNetworks.Where(y => y.Ssid.ToLower() == "myssid").FirstOrDefault();
await nwAdapter.ConnectAsync(nw, WiFiReconnectionKind.Automatic);

Resolve mDNS .local URL in browser address bar

I am trying to run a HTTP server in my LAN and want to access it by using a browser on another desktop machine. As I do not like typing the IP address and port manually I tried setting up a mDNS using jmDNS.
String type = "_http._tcp.local.";
jmdns = JmDNS.create();
jmdns.addServiceListener(type, listener = new ServiceListener() {
#Override
public void serviceResolved(ServiceEvent ev) {
Log.d(LogTag.SERVER, "Service resolved: " + ev.getInfo().getQualifiedName() + " port:"
+ ev.getInfo().getPort());
}
#Override
public void serviceRemoved(ServiceEvent ev) {
Log.d(LogTag.SERVER, "Service removed: " + ev.getName());
}
#Override
public void serviceAdded(ServiceEvent event) {
// Required to force serviceResolved to be called again (after the first search)
jmdns.requestServiceInfo(event.getType(), event.getName(), 1);
}
});
serviceInfo = ServiceInfo.create(type, NAME, PORT, "test service");
jmdns.registerService(serviceInfo);
The mDNS entry shows up on ZeroConf Browser app just fine. The server is reachable by IP and port just fine.
On Windows 7 typing the name with the .local TLD (= http://roseblade.local/) into any address bar (Firefox, Chrome, Safari, IE) does not do much and from what my research shows is pretty much a futile task anyway. I installed Apple Bonjour but that only help running Hobbyist Software's Bonjour Browser.
As far as Linux goes I tried the same with elemantaryOS and Midori but that also did not work.
OSX or iOS is currently not available to me.
How can I get the resolution of the .local address to work in my browser (Firefox, Chrome, whatever on Linux, OSX or Windows7)? Am I doing something wrong? At this point I would just like to verify that mDNS can work like that on a system.
Pointers to material on the issue are also appreciated.
mDNS and Bonjour can be a little confusing because they actually encompass a few different functionalities. Service discovery, which I believe is what you have implemented, is one. Resolving an address--which is what you're looking for--is separate, and needs to be solved separately. Once you have address resolution working, you can point your service discovery at the DNS records provided by your resolver.
mDNS address resolution works by multicasting a DNS query over the network. By binding to a UDP port, listening for queries, and answering them, you can provide DNS records to mDNS clients. To do this, you can use an existing mDNS server like avahi-daemon, or, if you need custom functionality or integration with your application, implement one using something like Node.js's multicast-dns.
However, in my experience, this has been rather flakey. Some network configurations interfere with mDNS resolution, as do some OSes (eg. iOS 8, see the whole debate around discoveryd vs. mDNSResponder).

finding location in codename1

I'm following this tutorial for finding locations on my j2me device. In the default codename1 mechanism, it tries to find it out through GPS. But my phone doesn't have it. So it opens the bluetooth connect screen. I'm using the following code.
com.codename1.location.LocationManager.getLocationManager().getCurrentLocationSync();
In the tutorial mentioned, we could change the retrieval mechanism to CELL-ID or Network, by doing the following.
//Specify the retrieval method to Online/Cell-ID
int[] methods = {(Location.MTA_ASSISTED | Location.MTE_CELLID | Location.MTE_SHORTRANGE | Location.MTY_NETWORKBASED)};
// Retrieve the location provider
provider = LocationUtil.getLocationProvider(methods, null);
Is there any way we could do a similar stuff in codename1 ??
We don't support other methods in J2ME devices at this point in time. You can use native interfaces to implement it.

Resources