MySensors on Raspberry Pi with nRF24L01+

Recently I’ve learned that nRF24L01+ radio module can be connected directly to Raspberry Pi via GPIO pins in order for this Raspberry Pi to be used as MySensors library “gateway”.

I’ve successfully installed MySensors on Raspberry Pi using official instruction, but one thing wasn’t exactly clear – how do I specify channel for nRF24L01+? Without specifying proper channel, the “gateway” won’t be able to see other nodes.

It turned out to be quite simple actually – before doing make / sudo make install one has to run configure with these parameters:

./configure --my-transport=nrf24 --my-rf24-channel=123

The 123 is the number of channel to be used.

P.S. Remember to enable SPI via raspi-config.

Advertisements

DSLR focus control with gphoto2

If you read the documentation on gphoto2 regarding the focus control (“manual” focus as they call it) it mentions that focus control only works while liveview mode is on, and that seemed to be sufficient for Canon, but it turned out that for Nikon cameras there was more to it than just liveview.

First the necessary disclaimer though: I’ve only tried the Nikon D5100 here and Canon 550D and 600D, so YMMV.

But let’s start with liveview (or preview) mode itself first – this one is controlled by “/main/actions/viewfinder” setting in both Nikon and Canon. Continue reading

Installing Cisco AnyConnect VPN on Ubuntu 16.04

Oracle, Unix and the world at large

I was struggling setting up a new VPN to connect to my servers at the office as vpnsetup.sh was failing

# ./vpnsetup.sh 
Installing Cisco AnyConnect Secure Mobility Client...
Extracting installation files to /tmp/vpn.0Zgby3/vpninst625702875.tgz...
Unarchiving installation files to /tmp/vpn.0Zgby3...
Starting Cisco AnyConnect Secure Mobility Client Agent...
Failed to start vpnagentd.service: Unit vpnagentd.service not found.

I found a bunch of articles on the internet saying that this was due to missing libraries so started with the first batch of recommendations…

# apt install -y lib32z1 lib32ncurses5

This still didn’t work.

So I tried the next one, which was to also install the network-manager-openconnect package and reload the daemons

# apt install network-manager-openconnect

# systemctl daemon-reload

Success!

# ./vpnsetup.sh Installing Cisco AnyConnect Secure Mobility Client... Removing previous installation... mv: cannot stat '/opt/cisco/vpn/*.log': No such file or directory Extracting installation files to /tmp/vpn.yUyv15/vpninst922924093.tgz... Unarchiving installation files to /tmp/vpn.yUyv15... Starting Cisco AnyConnect Secure Mobility Client…

View original post 13 more words

S3 mock endpoint

This post is incomplete and more of a note for oneself – be advices.

Here’s the way I’ve been trying to mock S3 for local testing, using Ruby FakeS3 app: https://github.com/jubos/fake-s3

In order to make S3 endpoints point to localhost I had to create custom regions override XML and debug AWS Java SDK to figure out it’s format.

I also have to pass path of that file as system property in order for AWS Java SDK to use it:

-Dcom.amazonaws.regions.RegionUtils.fileOverride=/Users/user/.aws-regions-override.xml 
-Dcom.amazonaws.sdk.disableCertChecking=true 
-Dcom.amazonaws.regions.RegionUtils.disableRemote=true

I could not find a way to disable SSL (switch from HTTPS to HTTP) in Amason AWS SDK without modifying the code of apps (which I can’t do – otherwise I’d just set endpoint manually), thus I ran FakeS3 configured with some random certificates, and pass disableCertChecking property. Also RegionUtils.disableRemote property is included to reduce number of helper calls to actual AWS.

Still, I did not find any possibility to make AWS SDK use path style access – thus bucket name is prepended to my localhost:9000 URL configured in .aws-regions-override.xml file, and thus I still had to add some entries to /etc/hosts to make it point to localhost. But at least I did not break any real AWS URLs with that.

UPD: Also, in order for endpoint URI to change one has to call setRegion in code at least once. This works for Spring wrapper over AWS S3 SDK, but may not work for custom code, that instantiates S3 client without setting region.

The content of .aws-regions-override.xml is this (the “whatever” tag can have any name):

  
<whatever>
   <Region>
      <Name>localhost</Name>
      <Domain>localhost</Domain>
      <Endpoint>
         <ServiceName>s3</ServiceName>
         <Hostname>localhost:9000</Hostname>
         <Http>true</Http>
         <Https>true</Https>
      </Endpoint>
   </Region>
   <Region>
      <Name>us-east-1</Name>
      <Domain>localhost</Domain>
      <Endpoint>
         <ServiceName>s3</ServiceName>
         <Hostname>localhost:9000</Hostname>
         <Http>true</Http>
         <Https>true</Https>
      </Endpoint>
   </Region>
...
</whatever>

Paho MQTT client, max in-flight messages for QoS > 0

Working with MQTT protocol in Java usually means using Eclipse Paho FOSS library as a client (it’s even used by Spring for MQTT support in Spring Messaging).

Using Paho to send messages with Quality of Service (QoS) bigger than zero though might result in error/exception “Too many publishes in progress” in case many messages are sent in short period of time.

The straightforward fix to that is of-course not to use QoS other than zero, but there are other ways to remedy that problem.

Continue reading

Raspberry Pi Raspbian Jesse – free serial port ttyAMA0

I’ve posted the answer at stackexchange.

In short, disabling terminal on serial via raspi-config (advanced->Serial) should do the trick.

It it doesn’t for some reason – commenting out ttyAMA0 from /boot/cmdline.txt and disabling serial-getty via sudo systemctl mask serial-getty@ttyAMA0.service should definitely free the port.

But still one must manually set pins 15 and 16 into ALT0 state. Command-line “gpio” utility can be used for that:
gpio mode 15 ALT0
gpio mode 16 ALT0

UPD:
Don’t do the manual pin ALT0 mode setting – enable UART in /boot/config.txt instead (find enable_uart=0 and change to enable_uart=1).
This will ensure /dev/ttyAMA0 will exist. Otherwise it may not exist.