Can't get info from hcidump --raw output - node.js

i am trying to create a BLE scan module via nodeJs and Bluez. I want to learn how to get mac address, minor, major and rssi values from the output of hcidump --raw command. I took a look at Radius Networks ibeacon_scan file but i still don't have a clue how i can do it with nodeJs. Can anyone help me with that? Thanks a lot

Try this: sudo hcidump -R -x
Then in a second terminal do your Bluetooth stuff

Related

Bluetooth, btmgmt tool how to set Link Mode

I try to understand how btmgmt work. I search command equal to:
sudo hciconfig -a hci0 lm master
I have try to use sudo btmon for dumping hci command but I have only this result:
# RAW Open: hciconfig (privileged) version...
with no op-code output, this not realy help me. Writing output to btsnoop format reveal some unknown op codes (btmon -a /tmp/btsnoop). With wireshark I have no HCI events, I don't understand.
Using sudo strace hciconfig... reveal socket and ioctl call with ioctl(ctl, HCISETLINKMODE, dr)
I read HCISETLINKMODE value and hciconfig function
but nothing about op-code to put the interface in MASTER or SLAVE mode. For some others btmgmt commands I use btmon output and the command op-code and I use op-code to search in mgmt-api.txt.
After reading that hciconfig would be deprecated, I'm trying to migrate commands using btmgmt and i just miss this one.
Any help is welcome. Thank you

Why cant you curl into nano?

So i was using the curl command the other day to get the information on a webpage and i piped it into nano to try and save the information but all it did was make the console completely unresponsive. The command i used was in the form:
curl -vk [web address] | nano
This caused the console to completely seize up, i sorted the issue by using a different command but i cant seem to find an answer anywhere on why this happens...
Can anyone enlighten me.
nano reads stdin with the dash - notation.
In your case, that'd give you :
curl -vk [web address] | nano -

get info from nmcli linux shell script

I am making a script in shell and I want to extract information from the command nmcli.
If I execute nmcli -p dev wifi list in a linux terminal I get a table with all Wi-Fi available. From each Wi-Fi (SSID) in the table I want to get only the SECURITY field.
So the output of the script would be something like:
SSID1 : SSID1-SECURITY
SSID2 : SSID2-SECURITY
... : ...
I've been searching for a while but haven't found how to do it :(
Can someone tell me how to get the security field from each SSID?
Thank you very much.
Don't know much about nmcli, but I think you can do :
nmcli -p dev wifi list | grep 'SSID.*SECURITY'

Read raw USB data for port being used by VirtualBox

I have software for communicating with a serial device that only runs on Windows 7. My host machine is running Ubuntu 16.04, with Windows 7 in virtual box.
I've managed to set it up using USB device filters in VirtualBox settings so that Windows sees and can communicate with the device.
However I'd like to capture what's being sent to and from the device. I thought something as simple as cat /dev/ttyUSB0 would work but unfortunately when I start VirtualBox I get this in dmesg:
[31199.465270] vboxdrv: ffffffffc0df4020 VMMR0.r0
[31199.653494] vboxdrv: ffffffffc0ef7020 VBoxDDR0.r0
[31199.710573] VBoxNetFlt: attached to 'wlp1s0' / 98:54:1b:04:13:48
[31199.863579] ftdi_sio ttyUSB0: FTDI USB Serial Device converter now disconnected from ttyUSB0
[31199.863674] ftdi_sio 1-3:1.0: device disconnected
So I don't know which file to monitor in /dev anymore. I suppose I might be able to try listen for the communication from Windows, but if I can I'd like to know if it's possible to monitor it from my host machine.
Edit:
This answer helped me for a start. I now get some cool looking stream on the terminal, next step is deciphering it, or if anyone has a better way I'm interested - it looks like the person who answered that question still has deciphering it as a TODO :-)
The fact that it was communicating with software in VirtualBox didn't really matter. This answer got me most of the way just by (as root):
modprobe usbmon
cat /sys/kernel/debug/usb/devices|less and search for device
cat /sys/kernel/debug/usb/usbmon/7u where 7 is the number from "Bus=" in the device table from step 2
From there is was just filtering the output.
A basic way could be just
cat /sys/kernel/debug/usb/usbmon/1u |cut -d\ -f9- | grep ^\n
But the device I was working with was constantly sending lines with just 4 characters, to filter out those I got the address word from the output line, and grepped for that. In my case I only wanted to capture "C" or callback output. I was also filtering for lines that contained more than just the default "0160" that the device was constantly outputting. To try understand the hex output I put a xxd -r -p at the end which gave me:
cat /sys/kernel/debug/usb/usbmon/1u | grep -e 'C Bi:1:005:1\s0\s\w*\s=\s0160\w' | cut -d\ -f8- | xxd -r
Where the grep is
grep -e 'C <address> <someotherstuff> = <always-output-string><anycharacter>
This still gave me this indecipherable junk below, but I don't know the format so I'm stuck here. Maybe the steps to read and filter will be useful for someone
>
O�UDQN��RG_JAMS142E DEFAULT0XXXXXXX�lSTz:�RSDU�vy��������������������������z�fff=�����{6zC"z�u6zC�z�H
;�����C��Af[���RSC�b ISD�EGIN
�CG_IEW0321:0407JUN12S��Z-�$''$'''C'''

wpa_supplicant keeping print message to screen

I am start learning Linux(CentOs 5.5 kernel 2.6.35.13).
When I try to install a usb wifi stick(TP-Link TL-WN823N,and "lsusb" will show ID 0bda:8178 Realtek Semiconductor Corp..)
It work fine in the window interface( ctrl+shift+F7).
But when I shift to the command window(ctrl+shift+F1),and try to start wifi connection by
wpa_supplicant -Bw -Dwext -iwlan0 -c/etc/wpa_supplicant.conf
I found it kept print logs to screen before I type the command above.
I use
ps axjf |grep wpa_supplicant
to list all related process and find
there is a process start by user "dbus" with the command
/usr/sbin/wpa_supplicant -c /etc/wpa_supplicant/wpa_supplicant.conf -u -f /var/log/wpa_supplicant.log
I dont know whether is this dbus' command that lead the problem.
Below is the screen shot.
kept logging msg:(
Partly fix the problem.
There are two things that make the wifi information keep on loging on the screen.
First, if you use NetworkManager, it will automate run the command under /etc/sysconfig/wpa_supplicant, where you can find the default command write there has no -B parameter which will keep the log in the background.So you can either add an -B to that command or stop NetworkManager and start wifi connection with your own command like in the question.
Second, when you install the driver, the default run status is power saving mode, so when you transfer data with wifi, you can see the screen keeping log infomation like "get into the pw_saving","get out pw_saving" etc.
To fix this, you can shut down the power saving mode like this:
create a file /etc/modprobe.d/8192cu.conf with the following contents:
options 8192cu rtw_power_mgnt=0 rtw_enusbss=0
Or you can rewrite driver code to stop print the info to screen, which I still don't know how to do.

Resources