P2P communication between mobile devices - mobile

Is it possible to communicate between two mobile devices without the need for an intermediary server?
For example: An app that sends a message to another device via its external IP address.
It would be necessary for the device to be both client and server at the same time,
it is possible?

Related

Connecting a mobile device to IOT system in a home

I am interested in building a device that will be connected to my home network and I will be able to control remotely via an app on my cell phone.
My original thought is this:
Both systems will pull data from some cloud service
My mobile device will modify a data entry in the cloud service
The device will be constantly pulling this data and update the necessary setting when they change
Concerns with the original thought:
Constant pulling of the device in order to see when data has been changed (inefficient)
No way to communicate from the device to the phone (feature limiting)
Question:
What is the best way to create the link between my mobile device and the device that will remain in my home?
Potential similar architectures include Nest, Ring, etc.
The concept is correct - typically, IoT devices and mobile apps communicate through the cloud. There are cases when you want to connect your app directly to a device (e.g. through bluetooth, LAN or sometimes even internets), but that is done usually for a specific reason, e.g.:
IP cameras generate a lot of traffic, putting it through a centralized server is very expensive, so cheap home products do P2P from mobile app (centralized served could help you get the IP address for your camera)
TV with phone as remote control. Using cloud service hear would be weird and limiting access to LAN simplifies the setup
In general cases (Next, Ring) you can be pretty sure the IoT devices talk to the cloud, instead of the mobile app directly. It both offer more feature (as the data can be processed in bulk in cloud), but there's also benefits for using the cloud even if it's used only to relay data.
In many cases, you also want to limit traffic (e.g. save batteries or data plan). Two key aspects to be able to do that:
Don't waste time setting up a connection. That means connecting to a stable cloud service (your mobile might not be online) and using optimized network (e.g. LAN with static IP address, NB-IoT or LTE-M)
Choose optimal M2M protocol. Two popular M2M protocols are COAP ("light weight HTTP") and MQTT (a messaging protocol)
Once you've set up how both your device and mobile app can exchange data with the server, it's up to you to design how to use that. Note that there's nothing stopping from the device to also push data to the server - all connection (IoT device <-> cloud <-> mobile app) can use two-way protocols.

Connect to the Wi-Fi network from within the app without internet access

I am developing hotspot helper application which tries to connect to the captive network after connecting to it, I need to handle the authentication within the app.
Approach 1
I used NEHotspotConfigurationManager in order to programmatically connect to the WiFi network and it works great. The problem i am facing is after connecting to the captive network iOS does not send the request to the connected network until the connected network has internet access or I manually go to the settings and it pops up the web page for authentication and i click cancel and select use without internet.
Approach 2
Second approach i used is by using NEHotSpotHelper as described in this tutorial
In this approach when I receive the commandType authenticate it does not send request to the Wi-Fi network (If the device is connected to the 4g the request goes over it otherwise it returns internet connection appears to be offline)
So how can i authenticate the user from the app after connecting to the WiFi with limited access?
I found that developer need to bind the request with the received command before making web request to the connected network. All you need to do is to make NSMutableURLRequest and then call hitTestURLRequest.bind(to: command) because bind function is defined in the category of NSMutableURLRequest.
Related question: https://stackoverflow.com/a/50753526/1796092

How publish data from multiple devices using a single connection to a broker

I'm working with a 6LowPan IPV6 network of connected devices (nodes) that forward their data to a border router which is connected to the internet. I'm trying to figure a way so that each node shows up in Watson IOT as a separate device. Is it possible to have more than one mqtt connection on the border router to the broker ?
Each device connects to Watson IoT platform using the a client ID in a format such as this: d:$org:$devicetype:$devicid so each device would be connected with it's own unique ID.
Have you configured your router as a gateway?
If you are using your router as a gateway then it would connect with a g: instead of a d: such as g:$org:$devicetype:$devicid
gateway can publish events from itself and on behalf of any device that is connected through the gateway.
Refer to documentation for more details.

Ionic tcp programming using socket.io issue

I need to develop an app in ionic that uses TCP connection in order to send and receive data. So there is a library socket.io, I used this library, but the problem is I want to communicate the app sends data from phone to an Arduino device. After a search I think this is not possible with socket.io because it should work in a browser at the client side.
Is there another library for TCP to send and receive data from phone to Arduino or vice versa?

How does the common networking application (using unix socket API) accomplish to forward its port, with the computer connected to a internet router?

Do you happen to know common application using unix socket api doesn't work on computer connected to internet router? For example, assume that there is a computer that is running a simple web server using socket in C. when a web browser in another remoter computer send a request, the web server cannot send a response to the request since its port is closed by the internet router(?) (Of course, there might exist another reasons).
However, the common applications by a competent developers works well. For example, utorrent client receives a request for some data from peers and responds to the request well, although a computer that is running utorrent is connected to the internet router. Does utorrent adjust router configurations using some system calls? If not, how does it upload the some data?
So my question is that
how does common application using socket API accomplish to forward its port, with the connection to the internet router?
How my program in C accomplish to forward its port with computer connected to the internet router?
Thank you in advance.
If you're connected the internet through a NAT router, in most cases any unsolicited connection into the router from the WAN will be refused. What you need is to tell the router (in some way) that unsolicited traffic coming in on a specific port number or range is to be accepted, and forwarded on towards a specific local IP address. This can either be done manually in your router's configuration, or if your router supports UPnP you can use that protocol to configure port mapping for the traversal of the router.
They don't. To send and receive data on the connections your program has started it's not needed. Port forwarding needs to be done by hand by the machine administrator and is only required to receive new connections.

Resources