Set and sync time using ADB shell with Python - adb

I'm trying to sync up clocks exactly using adb shell commands with Python.
I can set the date/time using:
adb shell date 071710102020
This only changes the time up to the second. Is there a way to set time up to the millisecond using adb shell on a Samsung device?
Another option is to change $EPOCHREALTIME up to the millisecond? Is that possible?
Thanks!

The most straight forward solution is to sync both, the Android device and the machine running python using ntp. This is built in to Android and all modern operating systems including Windows, Linux and MacOS.
If you really want to sync the device to the host time, you first need to install and configure ntp on your machine and then you should be able to sync with adb shell like so
adb shell ntpdate -q <yourservername>

Related

Use ssh to access couchdb on remote server from mobile device

I have an instance of couchdb running on my local port 5984.
My ultimate goal is to run couchdb on a server within a closed network, and be able to send requests to this server from mobile devices within the network.
This post seems to provide a solution, provided I can open a terminal and make an ssh tunnel:
ssh -f -L localhost:15984:127.0.0.1:5984 user#remote_host -N
But I obviously won't be able to access the command line on mobile devices to make the tunnel. How does one go about accessing applications from mobile devices within closed networks? (I can't just deploy it to some web server as I don't have access to the internet)
You CAN run command line on Android, for example with this terminal emulator you can copy a statically linked ssh binary to /data/data/jackpal.androidterm/app_HOME then cd $HOME and ./ssh to execute it
and there are graphical ssh clients, some of which might have the functionality
also termux should have an ssh client available, you probably need to "apt install ssh" when in the app to get it.
You can create a SSH tunnel if the client supports port forwarding. Those I know are :
The paid version of JuiceSSH : Setting up a New Port Forward Profile
Connectbot : Long press in the hosts list and choose "Edit port forwards". The parameters are straightforwardly adapted from the -L option.
You can write a client via sudo apt-cache search libssh; it supports tunneling AKA forwarding.
#include <libssh/libssh.h>
http://api.libssh.org/master/libssh_tutor_forwarding.html

Bluetooth Low Energy - Linux with BlueZ

I'm working on a project where I need to establish connection between my computer and a Adafruit feather 32u4 with BLE incorporated.
Due to comments on lots of webs, I decided to use linux to do the job.
I got everything installed and I can connect my BLE with the PC successfully.
----MY CONNECTION PROCEDURE-----
I can even recieve data and send data between them with gatttool.
To connect both devices i use this commands:
sudo hcitool lescan
sudo gatttool -t random -b F6:E5:F4:A7:71:E6 -I
connect
The devices are connected correctly. I can use all the gatttool commands and they respond as expected.
----END OF CONNECTION PROCEDURE----
---MAIN PROBLEM---
I don't know how I could implement all the commands in a packed C program.
I need to be able to manage all the commands in the same program !! without using brute force with system().
It would be great if someone could show me how gatttool do its magic.
I mainly need to know how to get the data from Rx and how to send it to Tx via code not commands.
Note: I can supply any further information if needed.

Use Psexec to get Connected USB Device names

I'm wondering if it's possible to use Psexec to return a list of connected USB Devices on remote windows 8 computers. Ideal output would be something like this:
USB1: Keyboard
USB2: Barcode Scanner
Obviously the device name would be displayed instead of 'keyboard' ect, is there an easy way to do this? I'm working within a secure environment with hundreds of remote machines, so unable to install any new Microsoft Tools such as Devcon myself.
Any suggestions would be appreciated.

Raspberry pi 3 Bluetooth

My Raspberry Pi 3 can connect briefly to my Android mobile, but once I accept the connection on the Raspberry Pi, I get this error:
GDBus.Error:org.bluez.Error.Failed: No such file or directory. Try to connect manually.
Please help me on this.
You can fix that from Bluetooth control. Type $bluetoothctl as root then you will end up with Bluetooth shall. There you should type "power on" command. After that you can use "scan on" command to check connection.
to continue from Dinusha's answer, after you scan and find your device's ID (you should also be able to see it's name in parentheses) you'll need to pair with the device by doing
pair <device ID>
then connect with the device by doing
connect <device ID>
You'll be able to see status of the connection
There are cases where I use a separate bluetooth dongle for connections I don't want dropped
Raspbian Jessie has some issues as far as I know with the Bluetooth module. I'd recommend using bullseye or buster. Also, there are a couple issues regarding the newest kernel. Run the following command to see if your phone which you are willing to connect is listed:
sudo bluetoothctl devices
If your mobile device is still listed here and not paired on the mobile side, there is your problem. Remove the device using the following command in RPI:
sudo bluetoothctl remove <mac-adress-of-device>

USB turned RAW when making a bootable USB drive failed and now cannot be formatted

I was making a bootable usb drive(8GB) for Win7 using the tool on the microsoft site but the process failed. When i tried to run the process again the windows tool told me that the usb is used by another program and cannot be used. I tried diskpart => clean on the USB but it failed with a write-protected drive error but when I used the diskpart command to check the USB's attributes it was NOT write protected. Under Computer Management => Storage the drive appears to be healthy because it says no problems (primary partition). When I try to format through Computer Management => Storage it fails and tells me the formatting was unsuccessful.I tried many other tools but I can't get the drive working. I don't care about the data on the USB i just want it working again so I can reinstall windows.
Thanks
You just messed up with your USB drive while making it bootable, you can try EASEUS Partition Master for formating your USB drive. This is really nice tool to make your USB alive back. The second thing is in order to make your USB drive bootable you can make use of Y.U.M.I tool to make your USB drive bootable, without formating it.
Also if you are familiar with Linux (Ubuntu) you can try this command to format it:
sudo mkfs.vfat /dev/sdc
Here /dev/sdc is your USB device detected by Linux it could be /dev/sdb , in order to make sure you can try it with this command:
sudo fdisk -l
This will list you all the devices connected to Linux machine.

Resources