Passing data within an app between devices in same network - windows-10

I am currently developing a Universal Windows 10 application that is planned to run both on the PC + Mobile and the Raspberry Pi 2.
I was wondering what would be the best way for these two apps to pass data from one another through a local network and not using Azure. It is required that for every transaction done on each device, it gets transmitted over to another.
We also need to remote control the Raspberry Pi 2, like manage the data and shut it down using the app.
We are planning to build a RESTful API that will run on the same local network to facilitate this but I'm not pretty sure what APIs to use for this.
What are the necessary APIs that will be good for this requirement?
Thank you very much for your help!

Depending on the size of what you transfer, I found this:
BackgroundUploader class
Windows.Web.Http namespace.
See https://msdn.microsoft.com/library/windows/apps/br207140?cs-save-lang=1&cs-lang=csharp#code-snippet-2

Related

Web-application design on embedded linux

I am working for a lighting automation company and we will design and develop a product which will implement Yocto/ Buildroot embedded linux operating system.
We will use a Linux SoM inside the product and the specs of the SoM is ~:
1.2/1.5GHz MPU
128/256MB RAM
4/8/16GB eMMC/SD
various peripherals UART, SPI...
At this point, Linux side must implement a Web-Based App, which monitors luminaires and control them etc. In general, project intends to control the lighting of a building/home using the web-app running on the device. Front-end shall show each luminary on the page and relevant buttons and icons help client control and monitor the luminaries. The front-end may have a couple of different pages. Overall there can be max of 250 luminaries and 10-bytes of data for each luminary.
I will have an MCU running beside which does real-time stuff and connected to Linux SoM using UART. The real-time MCU communicates to the luminaries and sends their data to Linux through UART or vice versa. The web-app should start a web-server I guess so that client can connect to the app from his/her PC/Smartphone browser. I also think I will need a database, because device should retain the data once restarted or in case of a power failure.
At this point I am not sure what kind of design should I do. I do not want to create a complex application. I do not want to do over-engineering. We are currently 2 embedded guys and 2 software guys will join us soon. I am an embedded C/C++ guy and although I know how stuff works in a very general sense for Vui.js, React.js etc. I am not really sure how well they will do on embedded linux with restricted sources such as RAM.
I have 3 different designs in my head:
1st ->
Receive data through UART directly using a high-level
language inside web-app backend (Node.js, Flask or ??? if possible)
Web-app backend (Node.js, Flask etc. or ???) either writes
received data to a database (SQLite ??) or executes it directly in a
proper way
Front-end communicates to backend through REST APIs
(Vue.js, React or ???)
2nd ->
Receive data through UART with a plain C executable file (circular buffer etc.)
Web-app backend (Node.js, Flask or ???) receives data through a local socket from
the C file and does database operations etc.
Front-end communicates to backend through REST APIs (Vue.js, React or ???)
3rd -> If flask, vue.js etc. complicates the Linux applications
Receive data through UART with a plain C executable file (circular buffer etc.)
Use lighttpd or similar to start a web-server and use fast-cgi ?
As far as I learnt from the web, with the specs of the SoM I will use, technologies such as Node.js Vue.js can be handled easily and there should be no problem at all. If so, even though it is a quite general question, how to do it in a simple & modern way?
I think the best way is the first.
In this way you build all the system with module so in the future will be easyer to change something.
All the framework you will use is maintained by big company so will live for longer

how to communicate with my apps using IP address and socket remotely

I am to Electron and nodejs
And stuck here, actually i m making a desktop app to control every PC in network. which tells me the ip and mac of computers in the network. But now I need to talk to it and push/get some message. but how ?
Socket.io is likely the easiest way to do what you are trying to do. It'll allow you to communicate between the machines with a relatively low amount of effort.
Sockets generally work on a "server" and "client" basis, so you may want a central server that will coordinate with the clients.
This blog post from node source provides a really good intro to using them.

How does some apps to get the hostname of device based on ip?

Have you seen those apps which explore your local network looking for devices?
Well, I would like to know how they get (mostly) the names of devices!
Does anyone know? Because I am building an application which needs to get (if possible) the hostname of the local devices..
Local network device discovery is often done by a zeroconf implementation (e.g. Apple services typically use Bonjour services to discover local device names).
If you wanted to explore this type of service for use in nodeJS, then maybe have a look at https://github.com/agnat/node_mdns. I've never used it myself but it does seem reasonably popular and stable.
Otherwise just do some research generally around zeroconf/mdns and make a decision based on your needs.

restart via code on windows 10 uwp

We've created a Windows 10 application that runs on tablets in Windows 10 kiosk mode. It works just fine, however, the wifi connection gets lost sometimes since the locations are very remote. We tried fixing the issue from the networking side, but when the devices lose and regain internet access the application will still hang as if it doesn't have internet access displaying a blank page. Where these devices are used, they are bolted into the wall to prevent theft. Which means if we want to reboot its very time consuming as we have to unscrew the cases off the wall and then open the cases to gain access to the power button, and the only way to get the application to run successfully again is to do a reboot on the device.
It was suggested that we have a way to perform a reboot from the application, however, every code example I've tried doesn't work in Windows 10 UWP. Here is the most common one I've found:
System.Diagnostics.Process.Start("restart", "/r");
I have access to the namespace
System.Diagnostics
but the Process class does not exist. Anyone have suggestions on rebooting via code on Win 10 UWP? Or a better solution to our issue? Thanks in advance.
It's also worth mentioning I tried execute a Powershell command too and the dll I need to reference for the Powershell class is not compatible with UWP.
What you require is not possible with the APIs available to UWP apps. This was a security decision. An app distributed through the store shouldn't be able to do things like restart machines.
Based on your scenario though you shouldn't need to go through the store. This means that you could PInvoke native code to do whatever you want. This would still need to be initiated on the actual device.
Yes you can do that!
You should add IoT System Administration in App capability declarations:
<Capabilities><iot:Capability Name="systemManagement"/></Capabilities>
and also You need to have "Windows IoT Extension for UWP" added to your project
using this for Shutdown
Windows.System.ShutdownManager.BeginShutdown(Windows.System.ShutdownKind.Shutdown, TimeSpan.FromSeconds(1)); //Delay is not relevant to shutdown
or for Restart
Windows.System.ShutdownManager.BeginShutdown(Windows.System.ShutdownKind.Restart, TimeSpan.FromSeconds(1)); //Delay before restart after shutdown
You can get more information in this Link

Listening a particular port on linux to access data comes from mobile device

i am newbie to Linux platform, i am working on java technology.
what i have to do is : Having a program that running on mobile devices,that sends some data to my Linux machine, now i have to create a program in java that
listen to a particular port.
access data comes on that port(which is sending by mobile device)
save that data to the database.
response back to the mobile device.
i.e. i would make my Linux system as server that can listen from many clients(mobile devices), but not getting how to configure this environment... :(
i used cent OS 5.4 and
installed jdk1.6.0_24
any help would be appreciated.....
thanx in advance!
khushi
One of Java's greatest strengths is that you can pretty much ignore the host operating system as long as you stick to core Java features. In the case you're describing, you should be able to accomplish everything by simply using the standard Java networking APIs and either the JDBC to access an existing, external database or you could choose any number of embedded Java databases such as Derby. For your stated use case, that you'll be running the application on Linux is pretty much irrelevant (which should be good news... you don't need to learn a whole operating system in addition to writing your app ;-).
Here's a nice client/server tutorial, in that it is broken into steps, and adds each new concept in another step.
Here's another client/server tutorial with much more detail.
I would write it to accept one connection at a time. Once that works, I would study the new(ish) java.lang.concurrent classes, in particular the ExecutorService, as a way of managing the worker bee handling each connection. Then change your program to handle multiple connections using those classes. Breaking it up in two steps like that will be a lot easier.

Resources