Can an Android app present itself as a (virtual) Matter device? - google-smart-home

Is it possible to create an Android app that presents itself as a Matter device? e.g. a thermometer. Any sample code?

An android app probably can’t do this, as it cannot stay on and listen to external communications on demand all the time. You can look for solutions to run a local server on the android system and implement a virtual device that way.

Related

Run ReactJS based application on ipad Mini

I have created a React Application with multiple frontends, I need to run that on my ipad Mini so that I can demo that it works on it. How can I do it, please advise?
I have tried using the IP configuration but to no avail.
First solution (approximate)
You can open such a view called device mode in a browser (chrome example). But keep in mind: This is only intended as a first-order approximation of how your page would look and feel like on another device. It is just being simulated and not guaranteed to be exactly the same. Chrome does support iPad Mini previews.
Second solution (accurate)
You would need to use your computers IP address in your local network and make sure that your device is on the same network as your computer.
On Linux and Mac you can check your IP with ifconfig and ipconfig on Windows. Once you know the IP address of your computer and your react dev server is running on port 3000 you can access your app with:
http://{IP_ADDRESS}:3000

iOS Sockets library listen support

I am finding some conflicting articles, some are old, about CN1 not having Sockets but I see the library com.codename1.io.Socket. I have seen some articles saying it works on Android as well but not iOS. I need the capability to listen on a socket on iOS and was hoping to use an internal library. The shannah/CN1Sockets project doesn't appear to support listening.
From 2014, https://www.codenameone.com/blog/sockets-multiline-trees.html , and lists non iOS support. Any update on this?
Codova/Phonegap does have a few libraries and someone implements Chrome's TCP/UDP API for it as well.
Server sockets are very problematic across platforms as the iOS implementation is radically different from the Android implementation and a bit challenging to implement using the listen paradigm.
It's probably possible to implement server sockets on iOS but because there wasn't much demand and this required some work we chose not to do it. It's also not very useful ans phones move around/change networks. You won't get a stable IP to work against anyway. A better way would be to initiate communication from the client and then communicate back. Notice you won't be able to use a server socket in a background process in iOS anyway as the process will be killed when sent to background!
The only Cordova implementation I found is this: https://github.com/MobileChromeApps/cordova-plugin-chrome-apps-sockets-tcpServer
You can probably use that with native interfaces or just use it as a baseline for a pull request to implement server sockets on iOS but again it's very unlikely that what you are trying to do with server sockets won't work due to iOS limitations.

Is there any framework to allow P2P communication via phone?

I want to build an app that allow P2P communication(send message, exchange files), I build the app with phonegap, since I want my app cross platform.
I know WebRTC allow real-time communication, but browsers doesn't support it very well. I also found Websocket plugin for phonegap, this satisfied part of my requirement, I can use this send message, but if I use websocket to send files from A to B, I guess all traffic will go through my server, it a pressure for server and I don't want my server carry so much traffic. I can't make a peer to peer connection between A and B.
Is there anyway to make a P2P communication on phone? Any workaround solution is also welcome.
You can do peer to peer connections using Flash or the recent WebRTC. Currently these are the only options you can use to do so, as WebSockets will only connect to a server.
As Flash is not supported by most phones (only Android < 4.0 has support), you can only use WebRTC. But WebRTC is only available on Chrome Beta for now, so you'll still have a cross platform app that will not work in most platforms/devices.
You will have to go through server (WebSockets or HTTP) to increase the number of devices you can cover.
You can use Boost asio sockets to build you own P2P app. but you need to build it for Android NDK and IOS.
Please do take a look at these links before you get into a conclusion
Official "Boost library" Support for Android and iOS?
Limitations to using (Boost) Asio with Android NDK
http://beta.boost.org/development/tests/trunk/developer/summary.html
http://www.codeproject.com/Tips/555070/Boost-vs-OSX-iOS-XCode
Hope it helps
On WebRTC you can use RTCDataChannel, in my experience, on chrome, using this involves writing a lot of code around reliability as the packets arrive out of order or not at all if sent too quickly.
However I think as the WebRTC spec evolves this will improve with implementation.
Use this for generating a RTCDataChannel enabled peerconnection:
var localpeer = new webkitRTCPeerConnection(localConfig,{ 'optional': [{'RtpDataChannels': true }] });

Google hangout desktop application flow

I am creating a screensharing application that would work in a similar manner like Google Hangout Screen Shares, and I'd like to know how the Google Talk plugin (used for Screen Shares) spawns child processes and uses a dynamic port range.
I am creating a background running application that user will have to install, and which talks with browser like how they describe here, http://www.codeproject.com/Articles/36517/Communicating-from-the-Browser-to-a-Desktop-Applic
But when I look at googleTalkPlugin, which is responsible for google hangout screen sharing, I saw that there are a lot of processes running, and whenever I open a new browser, a new talk plugin for that browser starts, as child service.
Here are some snapshots
and when I noticed the port used by googleTalkPlugin, I came to know its dynamic! If you saw the above link, the Browser Desktop communication is on static port.
I am very interested in knowing, how do I use dynamic port numbers? Also, should I create child process for every browser?
Or something better?
The reason there is a separate child process for each browser is that the Google Talk application is implemented as a browser plugin. Each browser has a Google Talk plugin installed and doesn't know about the other browsers, their plugins or their subprocesses. Each browser will launch the plugins that it has installed and, as Eduard mentioned in the comments, some plugins are started in a separate process. This isn't behavior that is special about Google Talk, it is behavior you will see with most plugins. If you implement your application as a browser plugin you will have the same behavior. If you don't want your application to run as a subprocess of a browser then you will need to write it as a standalone application, not a browser plugin.
If you want to learn more about spawning subprocesses read up on fork(). There are lots of other good resources around the internet on subprocesses.
Your other question is around dynamic port numbers. The easiest way to do this is to bind to port 0 and you will be assigned a random open port by the operating system. You can then use getsockname() to find out what port you ended up with. If you are working with a client/server situation you can have the client do this and then just tell the server which port it is using.

Windows Phone 7 Bluetooth/Wi-Fi

I would like to create application for Windows Phone 7, which will be communicating with desktop application via Bluetooth/Wi-Fi. Is there any API in Silverlight, which allows to use Bluetooth/Wi-Fi programatically?
Looks like bluetooth is going to be standard in the chassis spec. Unfortunately at this stage there is no api exposing Bluetooth functionality in the SDK. I think we'll have to wait and see on this one.
I understand devices will be able to inherently connect over wifi the same as 3g. No low level wifi specific api's known at this stage.

Resources