How to use gatttool non-interactive mode - bluetooth

I want to write gatttool in non-interactive mode.
$ sudo gatttool -i hci0 -b 78:A5:04:44:0A:57 -I
[78:A5:04:44:0A:57][LE]> connect
Attempting to connect to 78:A5:04:44:0A:57
Connection successful
[78:A5:04:44:0A:57][LE]> char-write-cmd 0x0025 ff
I'm changing color of light that is using bluetooth.
What is the equivalent by using non-interactive mode?
I tried like this, but it doesn't change the color of light and to stop it I must use ctrl+c. There is no message at all.
sudo gatttool -i hci0 -b 78:A5:04:44:0A:57 --char-write -a 0x0025 -n ff
How can I write the command?
Environment:
I'm using Raspberry Pi and Rasbian.

the option is not --char-write but a --char-write-req.
Total command must be:
sudo gatttool -i hci0 -b 78:A5:04:44:0A:57 --char-write-req -a 0x0025 -n ff

Related

Using name resolution in tshark

I wanted to enable name resolution in tshark, the equivalent in wireshark would be View->Name Resolution-> resolve network addresses.
I ran tshark with the -N n flag, and the output only shows de ip.
When opening the same file with wireshark it shows the names.
How can I make tshark show the names?
For example:
❯ tshark -r test_capture.pcap -N n -Y "ip.src_host contains DESKTOP # This line does not return anything
❯ tshark -r test_capture.pcap -Y "ip.src_host contains DESKTOP" # neither does this
But opening the file with wireshark, I have
ths output
Just in case it's relevant, I tried this two ways to capture the packets
❯ tshark -w test_capture.pcap -c 100
❯ tshark -N n -w test_capture.pcap -c 100
I want to be able to have the resolution names activated using tshark.

Raspberry PI uhubctl permissions

Trying to use uhubctl to control power to USB ports. I want to write a bash script to automate the task.
Right now I can use sudo commands to get it to turn off and on.
sudo ./uhubctl -l 1-1 -a 0
sudo ./uhubctl -l 1-1 -a 1
However I want to run these without sudo. I have added the permssions to the file /etc/udev/rules.d/52-usb.rules
Added the line SUBSYSTEM=="usb", ATTR{2109:3431}=="2001", MODE="0666" 2109:3431 is for Raspberry pi 4B.
And then run sudo udevadm trigger --attr-match=subsystem=usb and rebooted.
I keep getting the follwing errors
No compatible smart hubs detected!
Run with -h to get usage info.
There were permission problems while accessing USB.
To fix this, run this tool as root using 'sudo uhubctl',
or add one or more udev rules like below
to file '/etc/udev/rules.d/52-usb.rules':
SUBSYSTEM=="usb", ATTR{idVendor}=="2001", MODE="0666"
then run 'sudo udevadm trigger --attr-match=subsystem=usb'
What am I missing?

Always have to type 'sudo service ssh restart' on raspberry pi for controlling through laptop using putty

I am using my laptop's screen, keyboard and mouse for using raspberry pi 3 by using putty. but putty doesn't connect till I run 'sudo service ssh restart' command from terminal for which at least a keyboard is required which kinda defies the purpose. Is there any way to solve this or maybe I could put that command somewhere in the s card which has the os so that the command runs automatically at startup?
If you can't connect an keyboard try this, mount the SD card in another system and create symbolink links like this:
sudo ln -s /etc/init.d/ssh /etc/rc2.d/s03ssh
sudo ln -s /etc/init.d/ssh /etc/rc3.d/s03ssh
sudo ln -s /etc/init.d/ssh /etc/rc4.d/s03ssh
sudo ln -s /etc/init.d/ssh /etc/rc5.d/s03ssh
then restart and check the ssh connection

Is there any way to remove and insert network module remotely without losing connection?

I need to ssh to the server, remove the original network driver and insert a new one, but after I remove the original one, the connection will lose.
Is there any way to do it without losing connection.
The thing I want to do is:
$ ssh user#server
$ sudo rmmod igb
$ sudo insmod ./igb.ko
P.S., igb is the driver for one of Intel ethernet network card.
Thanks in advance.
Check this:
$ ssh user#server
$ sudo rmmod igb; sudo insmod ./igb.ko
Here the SSH server in the server will receive both the both commands even before executing the first command.

linux serial port connection with cu command

there is a network device on my ttyUSB0 port. I can access it with sccren command on linux, but when I try to connect with cu command I get this error:
sudo cu -s 9600 -l /dev/ttyUSB0
cu: open (/dev/ttyUSB0): Permission denied
cu: /dev/ttyUSB0: Line in use
How can I connect with cu command?
Usually it's just the file permissions on /dev/ttyUSB0 that aren't set after connecting the device:
sudo chown $USER /dev/ttyUSB0
Or add yourself to the dialout group:
sudo usermod -a -G dialout $USER

Resources