Reload leaves corrupt state - bluetooth

My app connects to a bluetooth device using react-native-bluetooth-serial.
Whenever I press Reload from the developer menu, the app is left in a corrupt state. It's no longer connected to the bluetooth device, which is expected. However, attempting to connect again always fails. The user must manually unpair before the app can connect again.
This problem does not occur when the app is closed or killed on the device. Nor does it occur when running react-native run-android on the dev machine.
I was hoping to find event handler where I can disconnect. The obvious place is componentWillUnmount of the main component. But it does not run in case of a reload. Is there some way to detect reload and perform clean up before things go sideways?

Related

Running GUI without need of remote desktop connection on-going

Build: Server with Ubuntu 18.04 in data center with Ubuntu Mate Desktop interface.
As I understand, any GUI app needs a display in which to function. I connect to the server via x2go to display the ubuntu mate interface.
Once connected, I have a scheduled cron job that launches a terminal, a GUI and some commands.
Everything works perfect as I have previously detected what display I'm using as a user and specify that to launch the terminal and the commands.
Problem: if I'm not connected via x2go client to the server and provide that display, I noticed today that the cron job didn't launch at the specific time (08:50), which was previous to my x2go client connection (09:23); it just launched when I did the x2go client connection from my desktop manually -- my understanding is that it didn't launch because there was not any available display.
I'm not technical enough to get more deep into this problem.
¿Is there anyway in which I can make the cron script function (i.e. that it launchs the terminal and the GUI) without the need of manually getting into my desktop and launching the remote desktop client (x2go)?
My ideas go for having another minimal setup in that data center or another that takes the advantages of being there and have a physical monitor to display constantly connected to the main server OR just manually entering the server via x2go every day.
EDIT: When I disconnect the x2go client session from the server, the launched GUI and etc perfectly maintains, without dissapearing because "I have terminated the session and eliminated the display".
Finally got it working with the great help of one of x2go founders (Oleksandr Shneyder) after understanding how x2go handles the sessions and the X server.
Sessions can suspended/hibernated, disconnected and terminated.
Suspended/hibernated: when "manually" or automatically the x2go server side suspends so that it saves resources.
Disconnected: when you exit the session window and the x2go client in your desktop/laptop.
Terminated: when you log out from the DE environment or issue the x2goterminate-session command in the terminal inside the session.
My x2go app was somehow entering into suspending mode in the server, causing that the display (50 in my case) in which the scheduled cronjob need to be run and launche the GUIs, "was not awaken" until I entered into the session via the
app. In that moment, the cronjob started executing.
To tell x2go server to not hibernate, I needed to change the X2GO_NXOPTIONS in /etc/x2go/x2goagent.options to X2GO_NXOPTIONS="sleep=0"
After this, everything functions perfectly in the server.
Hope it helps others.

How to prevent Android Studio / AVD "CANNOT TRANSLATE guest DNS ip" error messages?

About every 4 second after I start the emulator device from my Android Studio project an error message is printed into the Run window. It's extremely annoying because it hijacks the focus. If I'm in the Debug window it switches to the Run window every 4 seconds because of this error no matter what I do.
This started a day ago, but I don't know what induced it. I use the same emulator devices for several months now. Maybe an upgrade of some portion of Android SDK? The external SDK Manager is not invokable any more.
The messages start to come right after I boot up this API 25 wear emulator. One workaround is to make that tab float, then it doesn't hijack my focus; I move it to my second monitor.
I also noticed I cannot connect my Android Wear app running on my physical device (I'm running physical phone with the emulated wear) with my emulator.
It is because you are connect to a network which has a auto-redirect in it or it is not encrypted(HTTP). Start by
Disconnecting yourself from the network.
Restarting Android Studio
If the problem continues try posting a more detailed description of the error
If the problem doesn't continue contact your network administrator.
Maybe this can help:
Please make sure that you are connected to internet
Explanation: At startup, the emulator reads the list of DNS servers that your system is currently using. It then stores the IP addresses of up to four servers on this list and set up aliases to them on the emulated addresses 10.0.2.3, 10.0.2.4, 10.0.2.5 and 10.0.2.6 as needed. So, it needs internet connection to deal with them.
When starting the emulator at the command line, you can also use the -dns-server option to manually specify the addresses of DNS servers to use, where serverList is a comma-separated list of server names or IP addresses.

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

How to start and stop an external program in another device using Qt?

I'm developing a firmware updater that should download data from a web server and upload it to an Embedded Linux device.
I want a program (client) to start another program (server) before establishing a connection between them and start sending the data. To do that in the same environment is easy: just call QProcess and startDetached(), but I want to do that remotely: I want to start the client in the Desktop machine and, with the device connected via ETH/TCP in a known IP address, click a button which will ask the device to start the server. When the server finishes starting and start waiting for connections, the Desktop app will then open the socket connection and start sending the data. After all data have being send, another command should be send to ask the server to shut down, closing the connection and finishing the file transfer operation.
My question is: how can I do this operation of asking for an application to either start or stop when it is located in a different machine (in an Embedded Linux device while the caller is in a PC)? Notice that the solution must be such that doesn't depend on some extra software (such as a Tcp server) to constantly run on the device - that's precisely what I'm trying to avoid.
This is not related to Qt in any way, because it doesn't provides anything for that purpose.
There are at least two paths from this point:
use SSH from your application to start any process in the remote machine: ssh user#remote-machine "any command here". This can be called using QProcess;
or
write another software to listen to socket commands and start/stop any process you want, then get it running all the time in the remote machine. Then, it's just a matter of changing your client software to send the relevant commands
Beware of any security issue that may arise by allowing the machine to execute arbitrary commands from external sources.

How to reconnect to a background GUI application after session disconnect?

We have Eclipse setup as our IDE on a central Linux server. Everyone will connect to the server, opens an Eclipse instance, work on it.
Eclipse will be run as a background process, showing the GUI to the user.
What happens is, sometimes people disconnect from the SSH session abruptly(making the laptop to sleep ..etc), without properly closing eclipse, which sometimes leaves the Eclipse process running in the background.
Whenever the user tries to connect next time, they are unaware of the existing Eclipse sessions, and continue starting a new one, while the existing Eclipse processes continue running in the background taking up all the resources.
Question is, can we re-connect to that abandoned Eclipse session somehow? Is it possible to bring up the Eclipse in the same state where user left it?
I looked at GNU screen . However, it can't bring the GUI application back to the user.
This seems to be a problematic setup to me. Why not work on the local computer in the first place? But if you want (or have to) to work on the server, better start the desktop directly on the server via XDMCP, VNC, or Citrix XenAPP (commercial).
EDIT: Just found this article about xmove. I haven't heard about it before, but maybe it works.

Resources