BlueZ , set connection interval - connection

I'm trying to speed up communication that uses iOS on one end and BlueZ on the arm linux platform at the other end.
What I have realized so far is that bluez api does not have the option to change the connect event.
My wish is to set from the default 30mS to 15mS and thus speed up the communication.
I'm trying to ect/bluetooth/main.conf, but I'm not sure if this is the right way to go. Please if anyone can offer me the best way to do this also via hci commands or bluetoothctl?

This is done as a driver config, if you have debugfs enabled:
echo "30" > /sys/kernel/debug/bluetooth/hci0/conn_min_interval
echo "45" > /sys/kernel/debug/bluetooth/hci0/conn_max_interval
Take into consideration the Apple Guideline for optimal results: https://developer.apple.com/accessories/Accessory-Design-Guidelines.pdf (page 180 - 40.6 Connection Parameters).

Related

Disable chrony NTP server when unsync

I have a OpenWRT router running chrony (chronyd). The hardware doesn't have RTC, so after a power loss, the system clock goes crazy.
I want to have a LAN NTP server, but if somehow have no internet connection and the clock is wrong because a power loss, the NTP server passes the wrong time to the clients. Consider I'm using 'cheap' NTP clients (Android/Arduino/other routers/cameras) that have no way to prevent a big clock slew.
I would like to disable chrony NTP server on reboot and wait to a first sync to enable it. I thought this was a common setting, but couldn't find anywhere.
I've also tried ntpd and I'm open to alternatives (but it must run on OpenWRT).
Note: I'm already trying to use a USB GPS as a more reliable clock source even without internet connection.
My solution so far:
On chrony.conf, set to be disabled on startup.
deny all
Then, I created a script to check every minute if clock is sync (using chronyc) and then enable it again.
until ! chronyc tracking | grep "Reference ID" | grep -q "()"
do sleep 60
done
chronyc allow all
Finally, set to run script on startup.
Seems this in only possible with chrony (not ntpd), as it have a client to change settings on the fly.

starting with nodemcu/esp8266 dev board

I have a esp dev board that I've been trying to get to work, but have faild miserably. after spending a few days trying I was able to 'flash' a firmware and up load code(to connect to my wifi) via arduino IDE. the problems are when I open the serial monitor the serial monitor window is nowhere to be seen(it refuses to show up on my desktop, but if I place my mouse over arduino IDE on the task bar I can see a tiny version of the window with what seems like the esp is supposed to tell me). I verified the wifi program was working with advanced ip scanner. The other problem is that when I try to use esplorer I am told the following:
Communication with MCU..Got answer! Communication with MCU established.
AutoDetect firmware...
Can't autodetect firmware, because proper answer not received (may be unknown firmware).
Please, reset module or continue.
à‚3þÿÖ
ü
I've tried reseting via hardware and software and also saving a init.lua to the esp ( which I am told: Waiting answer from ESP - Timeout reached. Command aborted.)
Is there an easy step by step tutorial or something where I can get this thing to work in such a way that it is possible to develop with it? I dont care what language I have to use as long as I dont have to spend more time on trying to get the hardware to work. For something that is Arduino-like hardware it is significantly harder to do the simplest thing, a pic mcu is easier.es
If you are doing serious IoT thing then, I guess its better to go by Espressif IDE. There's a Freetos version also available which makes programming experience better.
To get started step by step you can check lot of videos on youtube, that's my preferred way of getting started. I found these three helpful to get started : here

Enable Raspberry Pi's internal pull-up resistors?

Is there a way to enable Raspberry Pi's internal pull-up resistors using Android Things?
EDIT: I filed a feature request -> https://code.google.com/p/android/issues/detail?id=233630
As of current release (DP2), there is no Peripheral I/O API to dynamically configure pull/down resistor on Android Things.
However has pointed in the release notes and the BCM2835 documentation, the Raspberry Pi 3 has internal pull-up (3.3V) resistor configured by default on the following pins, when configured as input with Gpio.setDirection:
BCM4
BCM5
BCM6
This is now available through the android things console:
First you should read this link for base knowlege.Pull-up resistors is hardware, it make uncertain voltage to 1 or 0 for pin!

looking for alternative solution than IPFW for slowing down an internet connection

I need to slow down (simulate bad) internet connection, I found some documentation where it was achieved by "ipfw pipe" command , the thing is that in latest MAC OS versions , ipfw was deprecated (and removed)...
I was wondering if there are any alternative to the ipfw API ?
Does anyone know how latest Network Link Conditioner achieves it?
The original previous way which enabled to slow down an internet connection :
sudo ipfw pipe 1 config bw 56Kbit/s delay 200 plr 0.2
and to clear the pipe :
sudo ipfw delete 1
Thanks.
I don't know much about Mac OS (I use Linux myself), but I'll give this a shot.
A bunch of digging established that ipfw seems unavailable, as you say.
I was also unable to find a way to use the Network Link Conditioner from the command line. Everything should be usable from the command line, so that's stupid.
One work around would be to try to access the NLC from within AppleScript. The following will get you started on toggling the NLC:
property thePane : "com.apple.Network-Link-Conditioner"
tell application "System Preferences"
activate
set the current pane to pane id thePane
--delay 2
end tell
---
tell application "System Events"
tell application process "System Preferences"
try
click ((checkboxes of window "Network Link Conditioner") whose description is "enable switch")
on error
click ((checkboxes of window "Network Link Conditioner") whose description is "enable switch")
end try
end tell
end tell
I think that you can run a script from the terminal with osascript <SCRIPT>.
As an alternative, Charles Proxy is a pay-to-use program that can be used to perform throttling, provided you can convince the software you are testing to connect to the proxy's port rather than directly to the internet. Maybe there are free proxy solutions out there somewhere?
Perhaps Squid would work in that regard. SquidMan seems to be an easy-ish way to install it for Mac. It looks as though DelayPools and or Client Bandwidth Limits might be useful for simulating a low speed connection, though I can't find evidence of people having used them for such.
I found several solutions that might work. They come from some old threads, but they might help:
How to simulate slow internet connections on the mac
Apple has made a very handy official tool to slow down the network connections on you Mac for testing purposes.
The Network Link Conditioner preference is a free download from within Xcode (for Lion and later OS). Additionally, iOS has similar function accessible from within Xcode and iOS 6 or later.
How do I simulate a bad Wi-Fi connection on my iPad?
There are a few ways you can do this, depending on your situation:
Move further away from your router. While this may seem a bit obvious, I realize that it isn't always possible while testing/debugging (for example, if you are working on a desktop computer).
Put aluminum foil around the router and/or antenna. This will (partially) block some or all of the radio signals by creating a makeshift Faraday cage. The results you get will depend on the strength of your router signal, distance from the router, and other environmental factors.
Set your router's wireless signal power to a lower setting. The method for doing this is different for each router, so you will have to look at the user guide for instructions on how to do this.
Slow down internet for iOS simulator
You can set the network to slow characteristic by testing on devices. Go to Settings -> Developer Settings -> Network Link Conditioner -> Enable. This is for iPhone/iPad running iOS 6
I don't know if the last one you can still do.
I've used many methods in the past for slowing down network connections, among them:
performing a parallel download of some massive Linux ISO file;
physically pulling out the Ethernet cable (at one point, I actually toyed with the idea of building a push-button device that would sit between two cat5 cables and do this without having to physically disconnect the whole cable).
using ifconfig eth0 down ; sleep 1 ; ifconfig eth0 up.
Hopefully one or more of those methods will help.
If you're looking to slow down your network connection because you're doing testing/profiling work, one option is to get a specific device that can create network latency/noise.
For example Apposite Tech's mini2 WAN emulator allows you to change values for bandwidth and packet loss. You can roll your own device too using something like: http://wanem.sourceforge.net/ . It just depends on your needs, time and budget.

Is there a way to limit processing power and network bandwidth for iPhone Simulator?

Is there a way to limit processing power and network bandwidth for iPhone Simulator?
This question is essentially a CPU and bandwidth limiting tool for specific program on Unix. Any recommendations...?
As for network/bandwidth limitations, there's a really good tool called Network Link Conditioner included with XCode nowadays. Possible to use a number of presets as well as setting up your own configurations.
You can also check out:
How do I simulate a slow internet connection (Edge/3g) on a mac. Is there a Firefox plugin?
UPDATE: Note that the Network Link Conditioner (as of iOS6) is available from the Settings > Developer menu on your iPhone (if it's marked as Use for development).
To limit your bandwidth, you can try using http://mschrag.github.com/. It's a preference pane which helps you simulate several bandwidth configurations (Edge, 3G, etc).
You could try using nice: http://unixhelp.ed.ac.uk/CGI/man-cgi?nice
At least that will help with the CPU problem.
You can use cpulimit to limit the CPU usage in term of percentage.
UPDATE: Read this discussion to know how to configure iptables to limit bandwidth per process.
You could use the osx firewall to do this :
sudo ipfw add 1 pipe 1 ip from any to me src-port 80
sudo ipfw pipe 1 config bw 40KByte/s
Edit : it seems that the simulator use local ipv6 address, and ip6fw doesn't manage pipe and bandwidth limit. I've edited my code to be sure that localhost v4 (127.0.0.1) address is used.

Resources