Thursday, January 11, 2018

Remote accessing the Raspberry pi over internet

In this guide, an xmpp based client-daemon is used as a chat-bot, this chat-bot is written in C++ and it is based on gloox-xmpp-client library. Xmpp provides an easy way of communication between two clients which are typically behind a firewall. A jabber server with public-ip over internet helps to achieve this secure communication between two xmpp clients.
Following steps explain how to compile and run the xmpp-client-daemon(chat-bot) on raspberry pi. Here is a diagram showing typical setup of remote communication between raspi and a smart phone.

How to prepare raspberry-pi to act as a chat-bot?
(following steps are tested on a raspi running 2017-11-29-raspbian-stretch-lite.img)
  1.  Login to the linux-shell-terminal of your raspi using directly connected keyboard or ssh.
  2.  sudo apt-get update
  3. sudo apt-get install cmake git libjson-c-dev libgloox-dev openssl
  4. mkdir /home/pi/xmproxy
  5. cd /home/pi/xmproxy
  6. git clone https://github.com/hackboxguy/brbox
  7. cd /home/pi/xmproxy/brbox/sources
  8. cmake -H. -BOutput -DCMAKE_INSTALL_PREFIX=/home/pi/xmproxy/buildir -DAUTO_SVN_VERSION=OFF
  9. cmake --build Output -- install (suffix -j5 incase of quad-core-raspi for faster build)
  10. cd /home/pi/xmproxy/buildir
  11. echo "user: my-raspi-usrname@gmail.com" >/home/pi/xmproxy/buildir/xmpp-login.txt;echo "pw: super-secret-pw" >>/home/pi/xmproxy/buildir/xmpp-login.txt
  12. export LD_LIBRARY_PATH=/home/pi/xmproxy/buildir/lib
  13. /home/pi/xmproxy/buildir/bin/xmproxysrv --loginfile=/home/pi/xmproxy/buildir/xmpp-login.txt

Check on your android phone's hangout if "my-raspi-usrname" is online, if so, then send "help" message and the reply would show the list of available commands.

enjoy chatting with your raspi-chat-bot!!

Note-1: For proper operation of xmpp with google account, ensure that your Raspi's account has this allow-less-secur-apps setting enabled. 

Note-2: Two xmpp accounts need not be on google, any two jabber accounts would work. Here is an explanation on preparing the jabber accounts.

Note-3: steps explained above would work on any debian based linux distro machine.
source code is open, suggestions and contributions are welcome.

4 comments:

Sanchit Mehra said...

Informative Article

Unknown said...

hello once installed there are programming examples I would like to create a question and answer bot with sending photos and videos ..

Anonymous said...

Acknowledging the dedication of our team to maintaining a positive and inclusive online community. Appreciate the creators of this Online Reaction Time Test for offering an entertaining yet valuable means to assess and improve mental reflexes.

Anonymous said...

I appreciate the thoughtfulness and intentionality behind each of your blog posts – thank you! Get ready to unleash your inner comedian and sharpshooter in Funny Shooter 2 Online - it's a riot!