Bluetooth Low Energy: listening for notifications/indications on Raspberry Pi B+ - raspberry-pi

How is it possible to authenticate using Bluez 5.31 and GattTool?
I want to listen on a notification.
I've connected using gatttool -b <addr> -I and I can run the primary command etc.
I sniffed the device and I know that handle 0x0024 is where I will find a notification.
When I try char-write-req 0x0024 0100 I get Error: Characteristic write Request failed: Attribute requires authentication before read/write
So I try sec-level medium and then sec-level high but I still get the same error.
Any ideas?

Related

UDP packets over NB-IoT

I'm trying to send UDP packets over the t-mobile NB-IoT network using AT-commands on a SIM7020E chip. I used the product wiki as reference. The starter version of the sim card I have doesn't support TCP, but I'm planning on using that later if I can succesfully communicate using UDP.
I created a UDP-socket on a Raspberry Pi using "nc -u -l 9999". I set an A-record on my hosting provider to refer dev.mydomain.com to the IP address of the Raspberry Pi. I verified the portforward and A-record settings by sending UDP packets from my laptop on another network using "nc -u dev.mydomain.com 9999" and typing some teststrings, so this all works.
On the 4G chip I use the following AT-commands:
// Check network
AT+CSQ
+CSQ: 21,0
AT+CGREG?
+CGREG: 0,5
AT+COPS?
+COPS: 0,2,"20416",9
AT+CGCONTRDP
+CGCONTRDP: 1,5,"iot.t-mobile.nl","x.x.x.x.255.255.255.0" <-- crossed out my ip
// Create UDP socket
AT+CSOC=1,2,1
+CSOC: 0
// Connect socket 0 to the listening port on the Raspberry Pi
AT+CSOCON=0,9999,"dev.mydomain.com"
OK
// Send "test"
AT+CSOSEND=0,0,"test"
At this point I expect to see "test" appear in the command line on the Raspberry Pi, but nothing happens. In the T-mobile portal it shows a PDP-context is successfully activated.
Also, setting the APN manually with AT*MCGDEFCONT="IP","iot.t-mobile.nl","username","password" doesn't work.
Did you work this out Hans? I was plodding along with a SIM7020E following https://www.waveshare.com/wiki/Pico-SIM7020E-NB-IoT code examples. Was successfully sending HTTP GETS to a server (without having to use micropython's wretched urequests lib) via the CHTTPCREATE/CHTTPCON/CHTTPSEND AT cmds, that seem to be be able to send packets over LTE to a server without specifying TCP/UDP etc or using a socket. Maybe give it a try?
Sadly I got the bright idea of trying an 'AT+POWD=1' cmd over the uart (was supposed to power the 7020E down) & now the module now does nothing but echo AT cmds (still auto connects to the LTE network & slow flashes the network led, just won't do anything else.) Real shame, nice little module otherwise.

Alexa M-search not received by Raspberry Pi

I am using fauxmo to have Alexa trigger a script on a Raspberry Pi, which then triggers a BroadLink RM hub to send out IR and RF signals for my home theatre.
This has worked beautifully for a year or two, and yesterday it stopped. I did not touch anything, I swear!
I found out that fauxmo does no longer receive Alexa discovery requests.
When I ask Alexa (voice/web/app) to discover devices, it sends out SSDP M-SEARCH requests to 239.255.255.250 1900. I can verify this using Wireshark on a Windows laptop.
However, these requests do not seem to get to the Raspberry Pi anymore. I have tried with two Raspberries. Confirmed they are on they same WiFi network, which is Google Wifi (and confirmed Upnp is enabled). And I powercycled Alexa and Google Wifi.
I also sent M-SEARCH requests locally on the Raspberry Pi, and those are received.
window 1:
sudo tcpdump -n udp dst port 1900 -A
window 2 (on same Pi):
echo -e "M-SEARCH\r\nurn:Belkin:device:**" | nc.traditional -q 1 -u 239.255.255.250 1900
window 1 result:
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on wlan0, link-type EN10MB (Ethernet), capture size 262144 bytes
02:06:41.485902 IP 192.168.86.247.45796 > 239.255.255.250.1900: UDP, length 31
E..;+.#...FO..V........l.'m.M-SEARCH
urn:Belkin:device:**
However, if I do this on 2 Pi's (window 1 on one, window 2 on the other), the request is not received. Actually, I also tried with another Ubuntu machine, so it's not specific to Pi.
I thought that it could be a general network issue, but then I would not see the Alexa requests on my Windows laptop.
I am at a loss - I did not make any code or configuration changes (actually it worked at the beginning of a movie "Alexa turn projector on", and it did not work after the end of the movie "Alexa turn projector off").
Wiring the Pi to the Google WiFi pod worked, I posted this at Google WiFi instead - https://support.google.com/wifi/thread/13904262

Catching Probe Requests using monitor mode in Raspberry pi 3

I wanna catch probe requests of mobile devices that are not connected to a network using monitor mode on Raspberry pi 3. I am using Raspbian OS. I used "Wifite" command but it only shows the mac addresses of access points and not of the non connected mobile device. I am a beginner in networking and Raspberry pi. Kindly guide me which commands should I use for this purpose?
You might try looking into sniff-probes.
It switches WiFi channels every two seconds and captures incoming packets using tcpdump.

How to change network buffer of network interface to get errors?

I tried with sudo ethtool -G eth0 rx 1020, but im getting this error Cannot get device ring settings: Operation not supported. Is there any other way to change network buffer to simulate NIC card errors and Packet drops. Thanks
Netem can simulate all kinds of packet delay, corruption etc.http://www.linuxfoundation.org/collaborate/workgroups/networking/netem

Fetch Device IP Addresses/MAC address of devices connected to a LAN

Currently I am wondering how I would go about implementing a fetch request to a local wireless network (router) to obtain all devices currently connected to a currently connected LAN....
So I've done some research and apparently 'nmap' is a terminal/commandprompt command that returns connected devices to a local wireless network, with some parameters that need to be inputted into the nmap command.
I found an iPhone app that does what I'm trying to do... https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&ved=0CDYQFjAA&url=https%3A%2F%2Fitunes.apple.com%2Fus%2Fapp%2Fip-network-scanner-lite%2Fid335517828%3Fmt%3D8&ei=qhHfUbDpJ4GkigKClIHYCg&usg=AFQjCNFMDPn5H8TbDw54-zYDYJ9iezRXpA&sig2=QN42a5w-MgClO5BvBUoDGw
It scanns for devices on a currently connected WiFi network and displays all devices connected to such network... I am attempting to do the same but am stuck on where to start...
Anyone have any ideas? I am trying to do this for iOS..
I'm thinking you could do a broadcast ping, ala:
$ ping -b 192.168.0.255
using the Apple sample code for ping.
But I have not tried it.