Sync multiple devices without internet React Native - javascript

I have connect multiple android devices to the same WiFi network but internet connection is not working. I want to sync data between all devices. Is there anyway to do the data synchronization on local network without internet ? in short I want to sync data between devices using local network.

Sure! It's not trivial though.
If you're looking to do this without using a "static" server or database or similar on the local network,
you'll need a way for the devices to be able to discover each other (the easiest is manually, i.e. by entering an IP address)
listen to network requests – on one device if you're looking for a star/server-client topology, or on all of them if you're looking for a mesh where all devices sync with all of them
have the devices talk to each other to sync data as required.

Related

Remembering the device and reconnecting to it

I'm currently doing a project with the web bluetooth in js and I wonder if there is a way to save the device object and automatically connecting to it instead of choosing the device in the pop up every time.
I've tried saving the device in the local storage and tried to get it in the cookies but they both failed.
There is a way, but it implies enabling some Chrome feature flags on a Chrome 85+
You can have a look at the documentation.
To sum it up, after enabling those two feature-flags in chrome://flags :
#enable-experimental-web-platform-features
#web-bluetooth-new-permissions-backend
The Web Bluetooth spec will be updated with the algorithm for getDevices(). The devices returned by getDevices() may contain devices that are not currently in range and connected. The BluetoothDevice::watchAdvertisements() API can be used to detect when Bluetooth devices come into range of the Bluetooth radio. Then calling BluetoothRemoteGATTServer.connect() should resolve successfully if the device is able to be connected to.

Javascript get smartphone GPS without "HTML5 Geolocation" and Internet

Context
I'm working on an ESP32 device that use WifiManager library to set up the device Wifi. This library just create a Wifi Hotspot who redirect to a basic HTML page. This page will be reachable via a smartphone. I want to know the user location when he visits this HTML page.
My Problem
The problem is, that to see this page, he must be connected to the ESP32 Wifi Hotspot so every solution must work without an Internet connection.
Furthermore, I know that there is this API (HTML5 Geolocation), but it didn't work because the server is hosted locally in HTTP. (And I saw a post that said that it must be connected to Internet).
I have also a size constraint. I'm working on a tiny device with already a lot of code so the solution mustn't be to heavy.
So, is there a way to get a smartphone GPS Location via a Javascript script and without using HTML5 Geolocation and without an Internet connection ?
I don't know why you wouldn't want to use JS. It's the only way you can get information from the client in a web app.
The hurdle is, you usually need HTTPS for such sensitive data to be allowed to be sent by the users browser. But how to set your server up for HTTTPS is not a question for StackOverflow.
Sorry that we can't give you a better answer. If you can't do it native you'll have to work with what you've got.
EDIT:
Some browsers need intenet to verify certificates, can't do anything about that. If you don't control the device -> browser.

Is there an easy reliable way to transfer a file over local network using Electron / Node.js / terminal?

Are there any built-in methods in Electron / Node.js allowing to transfer a file over local network to another device?
I want to be able to send files locally from one computer to another (through an Electron app), but I also want it to be able to send files to smartphones.
How do I do it? Is it possible to just create a temp local server and download the file from another device by opening the URL (e.g. 192.168.0.x:x/file.txt)?
I tried using https://www.npmjs.com/package/quick-transfer which does exactly that, but for some reason opening the link on another device doesn't do anything.
As painful as it is for me to suggest... I'd recommend WebRTC for this, for these reasons:
It will make a local connection, when possible.
It will work over the internet as well, if required.
You can work around any firewall difficulties with TURN.
You will have compatibility with browsers.
You won't be opening up some server to a file that anyone on the network can get... transmission occurs over a secured connection. (This doesn't mean you can ignore other security aspects in your application however!)
Sample code: https://webrtc.github.io/samples/src/content/datachannel/filetransfer/
Commentary: It's amusing to me that in 2018, we still haven't solved the problem of sending a file from point A to point B. Network Neighborhood in Windows was the golden age, and now it's all screwed up with this newfangled cloud crap. :-) Obligatory: https://xkcd.com/949/

Browser Chat Without internet

Can anyone explain me the possibilities of creating a web chat (i.e similar to whatsappweb) which works without internet connections the only possible way that these device communicate is either by WiFi or Bluetooth (i.e Peer to peer). If it is not possible on earth could then explain why?
I've come across some javascript files like peer.js. But it uses internet i think. I want it to work without internet connectivity.
Thanks in advance.
With WebRTC it is possible to establish peer-to-peer communication between web-browsers in the same local network: https://developer.mozilla.org/en-US/docs/Web/Guide/API/WebRTC/Peer-to-peer_communications_with_WebRTC
A server is only needed for communication outside of a local network: http://blog.vline.com/post/63765098884/webrtc-if-its-p2p-why-do-i-need-a-server
There is another demonstration in this page: https://hacks.mozilla.org/2013/05/embedding-webrtc-video-chat-right-into-your-website/
However WebRTC is a relatively new system that is not widely supported - so consider it experimental at this stage - but it has the backing of Mozilla, so it might end-up somewhere.
However you are limited to the capabilities that WebRTC provides - and as your code is still JavaScript that runs in the browser you will not have access to any kind of actual networking API (such as Berkeley Sockets) or lower-level control of hardware, such as the ability to create Ad-hoc Wi-Fi networks, new Bluetooth Personal Area Networks, or LE Bluetooth connections... at present.
Google is working on making a Bluetooth API available that runs in the browser. Presently it is only available to Chrome Extensions, but it may soon be available in web-pages in general: https://developers.google.com/web/updates/2015/07/interact-with-ble-devices-on-the-web
Ofcourse there is a way to make this happen. You would have to set up a webserver on the device with this webapp. You could then connect with localhost or 127.0.0.1 . Other people would have to join your hotspot and connect to your ip address.
If you want to connect automaticly you would have to write a real app.
Browsers run in a "contained" mode. No hardware access is possible from any script ran inside the browser, thus there's no way to initialize and setup the device to start direct communication.

Chromecast – Connect to other device session from Chrome

Context
When casting from Google Chrome and using the session listener it's possible to join an already created session, this works well when the session is created from chrome, and if the autoJoinPolicy was set to ORIGIN_SCOPED it even works from a different tab.
The problem
If another device created a session the sessionListener handler doesn't fire, so I'm not able join the created session.
Between devices (android, ios) is possible to detect sessions, that the same behavior I would like to achieve with chrome, is this possible?
You can connect to other sessions as well, it shouldn't be necessarily your own session. For example, you can check out the CastVideos-android and CastVideos-chrome sample apps and start a cast session with Android and then connect to that with the chrome app.

Categories

Resources