How to identify IoT devices on WiFi network in Rails production app? - ruby-on-rails

I have an IoT project that I have been developing using Rails. I am using ActionCable to manage websocket connections between my app and Arduino devices. The Arduino's are hardwired to ping into the app and join the websocket channel. In development, it is easy because I tell my server to listen to outside requests and the Arduinos ping localhost:3000. Now that I am trying to deploy, I realized it's tricky to manage this in production.
I would like a user to log in and see a list of smart devices in their home, the same way that many market ready devices work. If my app is on Heroku, is there a way I can configure the Rails app to look for incoming requests that share the same WiFi network as the current user? Otherwise, I would need to set up a form on the Arduinos where users would have to input their login credentials for the app to associate devices to users, but from a user experience perspective that would be a pain.

I would probably try to generate and hardcode a unique token in each arduino, put it on a sticker on the device and then ask the users to register their devices.
Or if there is way for them to input the wifi passwords for the local wifi, then you can do any kind of device identification when you show some secret on the website and ask the user to enter it on the device(s).

Related

How VoIP apps like Viber, Skype,.. work when user's IP changed?

I'm currently researching about how to make an iOS VoIP app and I wondering how user1 of Skype, Viber, Facebook Messengers... can reach to other user in contact list? In my case, the users can request a call to admins. Then admins can call back to them with their IP address they were request to server.
The big problem is if users connected to a Wi-Fi to request a call to server, app will send their ip address to admins. But if they have to connected to another Wi-Fi, their IP address will difference with the older.
I don't know how to check when user's IP was changed. And how to update the IP if it occurs. Does anyone faced this problem and can you guys give me some solution about this problem?
For this you have to configure many things.
Usually Skype, Viber, Facebook Messengers configure things like below.
Ideally there should be target on specific IP or something.
That end point to get connect in video call has to configured and come from server end
https://www.vidyo.com/ is really good platform, though have SDK in C++ so in any technology you can configure it easily
To know online / offline user's, better approach is websocket
list of user will also based on websocket or API response
Good platform for websocket - https://github.com/tidwall/SwiftWebSocket
Pushkit is also required thing, when app is in killed ( Terminated ) state then using pushkit silent notification with local notification you can notify user about incoming call

Can you communicate with nearby devices using a website?

Can a website help a user communicate with nearby devices via bluetooth/WLAN without downloading software?
User requests that something be done on their device (which could be, for example a wirelessly connected printer or a bluetooth keyboard).
The site, which contains a repository of relevant actions, sends specific instructions for that device to the user's own machine.
Those instructions are then relayed to the correct device (with the user's permission) via the user's device's WLAN or existing bluetooth connection.
Part 3 is what I'm not sure of - is there a mechanism by which a website can contribute to a wireless/bluetooth connection held locally?
It is not possible. User browser can't interact with hardware for wireless networking.
You should force user to install some custom software to do this.
You would have to submit the "commands" first, then have the device make requests to the website server, i.e., check for any pending "commands" for the device, and then process them locally. A website is not "thing" that can directly interface with a hardware device.

Peer-To-Peer chat iOS Application

Is it possible to create a chat application that works with Peer-To-Peer, so without a server connecting the devices?
I think this would be more trustworthy for users...
Yes it is possible, but you will still need some type of server or middleman that everyone connects to at first in order to find the people to chat and distribute their ips to each client, but from that point onward you can use tcp to connect the devices without a middleman.

p2p ios devices connect. How find and connect devices

I must develop simple p2p connect app.
I have:
1) database server and simple code server (php, nodejs or similar);
2) two ios devices.
How can I connected p2p between devices (for stream voice, text and photos)? Connect by IP and random port impossible, because devices may has same IP.
Devices can located on local network or different countries. Devices can has wi-fi or 3g/4g internet. Devices can stationed behind a router, NAT.
I know about openpeer and others SIP services. But it's very big and excessive solution. WebRTC not work in ios and webView. Multipeer connectivity framework is local devices only.
My question: how I can detect, uniquely identify devices and connect his?
I see this as:
1) On start app and has internet (wi-fi or 3g/4g) - application send message to server.
2) Server get from app: IP, UUID or other (I dont know what information is necessary and sufficient for p2p connect).
3) Server register app and device in DB and return now on-line devices list.
4) App get from server list of other devices.
5) User select other devices and click "connect".
6) Server send to two devices the necessary for connection information (IP's, UUID's and other).
7) Devices start connect p2p, receiving and transmitting data without using a server.
I see this arhitecture (openpeer) image:.
It is good. I must know HOW "finder" server detect devices and what data is necessary and sufficient for connect?
For me unacceptable using third-party servers for connect.
Please help me find the solution.

Not able to view active servers through wifi and connect with it all the time by using Bonjour and NSNetServiceBrowserDelegate?

i am working on an App that uses wifi network to pass data from one ipad to another ipads .
i have already referred the following sample code about:
http://mobileorchard.com/tutorial-networking-and-bonjour-on-ip
The above sample code connects Devices using wifi and can exchange messages using Cfnetworking and Bonjour.
My problem is that i am not able to see Active Servers all the time .While Some times it Shows me Active servers and i can easily connect with and Exchange Messages but when i relaunch or open the app after some time it doesn't show me active servers so i am unable to connect and exchange messages. The same problem occurs in the sample code available from above link having tutorial on to Send data over wifi to another Devices.
I am Stucked up over here where i am unable to connect with active Devices all the time because not able to access those servers.
In chatty sample code same problem occurs where you can see active chat room's and connect with but some times you will not be able to see those active chat rooms availabe even if there are active servers who have already started new chat room where all Devices are connected to same wifi network.
Any help would be highly Appreciable , Thanks in advance.
Any chance the wi-fi interface on the device is going to sleep from disuse? Or that the user roamed to a different Wi-Fi access point with the same name that isn't bridged via Bonjour?
Have you considered using Multipeer Connectivity instead of using Bonjour directly? IIRC, that API would let you communicate even if the devices are not on the same Wi-Fi network, which is probably what you want anyway.

Resources