How do I create a variable from an output of a program? - wifi

I am building a device to give a constant read out of the signal strength of my wifi network using a rasberry pi pico and an adafruit airlift featherwing since the pico doesn't have on board wifi. I was planning on either using iwconfig or wavemon to get the dBm value but I'm unsure how to have a program running that constantly updates the signal strength variable itself and stores that value. Is there a way to either have my program pull the value after running iwconfig each time or directly tapping into the variable used by wavemon? Or could I get a signal strength measurement without having to tap into secondary programs?

Related

ESP8266 NodeMCU node.dsleep option 4 with wifi connect command

I am using developer branch firmware and i am working on deepsleep mode. I use node.dsleep function with option 4. With this option after timer wake up there is no rf functionalty. My project is about temperature control and i want connect wifi only when temperature data pass some limit. So I want use deepsleep mode option 4 with my control on wifi connection. Are there any command for connect wifi after wakeup deespsleep option 4.
Try passing 1 instead of 4 to dsleep().
Or use the same functions you'd usually use to initialize wifi and network.

Does bluez support low energy pairing with ios devices?

I have been beating my head on the wall with this project. I have an app built to an iPhone 5 that needs to communicate with my mac via bluetooth low-energy, and I want to do it through linux using the bluez protocol. I have my mac dual booted with ubuntu 12.04 and my iPhone app is connectible (acting as a peripheral), which I verified with lightblue. So, my question is, basically, is this possible? Will bluez support this type of connection, or will it only work if I use a dongle?
I have tried many different permutations of bluez. My linux kernel is 3.11.0. I think I am currently running bluez 4.98. I can get the hcitool to sense my app, then I use gatttool -b -I -t random which gives me the [ ][MAC.......][LE]>
then I type connect, I get
[CON][MAC.......][LE]> for about 15 seconds and then the CON goes away. That was the best I could do. Actually, at this point I'm not even getting that anymore. I'm getting any one of 3 errors. Either connection refused (111), could not create connection, or device busy (16).
Anyway, any help is appreciated!
Thanks.
To quickly answer your question, yes BlueZ DOES support pairing with iOS devices. That being said, the way Bluetooth Low Energy works is that you only need pairing if you want to perform an action on a characteristic (i.e. reading, writing, or enabling indications/notifications), and that characteristic requires pairing for that action to be performed. In other words, I think that the errors you are seeing are unrelated to pairing (since they occur before you do anything to the characteristics). I recommend that you try resetting the hci device with the command:
hciconfig hciX reset
Where hciX is the local hci device you are using.
If that doesn't work, try using #hcidump or #btmon to read the raw hci data and possibly get a clearer picture of what exactly might be happening.
If you want to make sure that you have a local hci device (and therefore meaning you wouldn't need a dongle), run the following command
hcitool dev
This should display the local hci devices. If the response is empty, that means that your Linux system is not using Apple's Bluetooth hardware, and that you probably need a dongle.
Also, watch out for other common errors, i.e. are you sure that your peripheral device is connectable, does it have proper implementation of services and characteristics, does the peripheral device have a random address (hence the -t random option?), are you sure you can see it from your linux machine (e.g. with the #hcitool lescan command), and if you are using the gatttool command correctly. There are a couple of good bluez questions on this site that might be beneficial to look at:
Using Bluetooth Low Energy from The Command Line
Bluetooth Low Energy Listening for Notifications/Indications
Raspberry Pi iBeacon Connection Timing Out
Attribute Requires Authentication Before Read/Write
Finally, when it comes to pairing, you have to increase the security level by passing "--sec-level=medium" or "--sec-level=high", e.g.
gatttool --sec-level=high -t random -b <MAC Address> --primary
or
gatttool -l high -t random -b <MAC Address> --primary
This should initiate the pairing process, and then result in a pop-window to appear asking you to accept the pairing request
I hope that this helps,

How does Linux kernel wifi driver determine when a connection is lost?

My understanding is that current WiFi driver uses rate control algorithm to choose a data rate within a small set of predetermined values to send packets over the WiFi medium. Different algorithms exist for this purpose. But how does this process work when WiFi driver decides that the connection is lost and shutdown the connection all together? Which part of the code should I read in open source WiFi driver such as MadWiFi and the likes?
The WiFi driver for your hardware which runs in Linux communicates with the WiFi chip which also runs a pretty complex firmware. The interface between the driver and the firmware is hardware specific. In some hardware the detection of connection loss events is done completely by the firmware and the driver only gets a "disconnected" event while in others the driver is also involved.
Regardless of who does what disconnection usually occurs due to either
Receiving a DEAUTH frame from the AP
Detecting too many missing beacons. Beacons are WiFi frames sent periodically by the AO (for most APs every ~100ms) . If you get too far from the AP or the AP was just powered off you stop seeing the beacons in the air and usually you'll signal disconnection or try to roam to a different AP.
Too many failures on Tx of packets (i.e. not receiving ACK frames for too much traffic)
This usually indicates that you've gone too far from the AP. It could be that you can "hear" the AP but it can't hear you already. In this case it also makes sense to signal a disconnection.
For example you can look in TI wifi driver in the Linux kernel drivers/net/wireless/ti/wlcore/events.c and the function wlcore_event_beacon_loss()
In Cfg80211 architecture, assume we are station mode.
driver call kernel API cfg80211_send_disassoc() if we received a deassoc/deauth frame.this function will notify corresponding application (ex wpa_supplicant) a disconnect event.
on another hand, when we decide to disconnect with AP, applicantion (ex wpa_supplicant) can call linux kernel API cfg80211_disconnected(), it will trigger corresponding driver ioctl function to finish disconnection task.

iOS - Receive an external input to my app from a switch with BT or IR?

I am building an assistive iOS app for a kid that uses a switch to control his computer (a simple button that can send only one massege to the computer).
I am looking for a way to connect my app to a switch that can send click events to my app.
It can through by BT, IR or even through the earphone connection (headset port).
(BTW he can not use the iOS screen as the switch).
Any ideas ?
A BT connection requires you to be a certified MFi developer, and that requires money and a real company.
The headphone port would be a great place to interface with. You could wire a simple switch over the microphone line and ground line which, I think, would create a square wave duty cycle for on and off. I've done something similar where we used the headphone port to communicate to a microcontroller through a sound wave that was then converted to 16 bit packets and used to control additional hardware and also give feedback from that hardware.
Another option is a wifi connection, an arduino with a wifi shield and the button on that.
Edit:
The more I think about it, the more I would say use the headphone port. It will be super cheap, the programming to detect the presses will be really easy, and this will probably be the fastest way to achieve your solution. Provided you can solder.
I'm going to suggest going down a different path. Instead of trying to connect the switch directly to the iPhone, use something like an Arduino board with both physical switch and ethernet I/O ports plugged into the local network, and create what amounts to a physical I/O server.
The Arduino handles the physical interfacing and your iPhone app only has to handle the communications protocol to the Arduino over Wi-Fi.
One inexpensive solution would be to use the mic or mic input on the headset port. Connect the switch up to some sort of tone generator (555 timer or Arduino, plus piezo speaker or headset cable). Have the app run an input Audio Queue, and pass the Audio Queue input buffers to a DSP narrow band filter or an FFT. Monitor the frequency band of the tone generator for any significant energy burst above the background noise level. Potentially use multiple separate tone frequencies for more than one switch.
Added: Another simple alternative might be to use the switch to activate a solenoid or small motor (scavenged from an old motorized toy or similar) to tap a capacitive pen or ball of conductive foam on the iPod Touch display. No MFi, WIFI or audio DSP coding required.

WLAN triangulation of mobile devices from WLAN side as a pose to cell phone app

Im trying to measure the signal strength of mobile devices from either existing WLAN routers or creating directional antennas. I want to see what specific routers are picking up the top 3-4 signal strengths from a specific mobile device, and use triangulaiton to gather their locaiton. Any ideas of the best route to do this?
I don't know whether such router exists or not, but can provide you an alternative and convenient way. Wireless channel is symmetric in both direction; this is, if the router transmits signal at 20 dBm and mobile device receives such signal at -30 dBm, the received signal strength at router would be -30 dBm if the mobile phone transmits at 20 dBm (given that environment does not change much). Then simply install WiFi analyzer app on your Android phone and record the signal strength of your normal routers.

Resources