Saturday, November 28, 2015

Use your smartphone as a GUI display for your pi

With a very simple hack, we can use our smartphone as a GUI display for your raspberry pi. This can work over remotely and there is not HDMI or any other connector required to connect your smartphone to your pi.

There are a few apps that you would require on your smartphone. Download and install

Xserver XSDL
Connectbot

Xserver XSDL is a xserver which can be run on your smartphone. Whereas connectbot is a simple ssh client for connecting to your raspberry pi via ssh. The trick here is to run the Xserver on your smartphone. Ssh to your pi and tell your pi to forward the display to the Xserver running on your smartphone.

Let us see the configurations that need to be verified on the pi. Ssh to your raspberry pi over the network and check the following configuration options in these files.

/etc/ssh/sshd_config

AllowTcpForwarding yes
X11Forwarding yes
X11DisplayOffset 10



/etc/ssh/ssh_config

ForwardX11 yes
ForwardX11Trusted yes

If these configuration options are commented out, simply uncomment them. Else add them and restart your ssh server on your pi.

$ sudo service ssh restart

Now start the app Xserver XSDL on your smart phone. It may download a set of fonts and will then ask you to run some commands on your linux PC. The Xserver starts running on port 6000. Now, we need to forward the display of pi to our smartphone.

Go back to the ssh connection on your smartphone and run these commands.

$ export DISPLAY=192.168.1.37:0           
$ export PULSE_SERVER=tcp:192.168.1.37:6000


My smartphone is running on the ip 192.168.1.37. And i am forwarding the display directly to the Xserver running on port 6000.
This is insecure as the port forwarding is not happening over ssh but directly from the pi to the smartphone. But if you are on a local network, it should not matter.

Now simply start your lxde desktop environment on the ssh connection. Execute the following command on the ssh connection.

$ startlxde

And bingo...


It is not very comfortable for working as the mouse pointer is difficult to catch and click. But if you have an old smartphone or tablet lying around, you can use it as a display - running a smart photo frame or a hanging smart calendar.

Monday, November 09, 2015

Script to update godaddy dns A record

Recently, I have setup my raspberry pi as a download machine. The aim was to be able to access the machine from anywhere and be able to add files to download. Now, since the machine is connected via airtel broadband, it is bound to go down and come up as and when the electricity in my location does.

Everytime, when the machine came up, i would be having a different public ip address to access the machine as my ADSL modem+router would also go down.

At first, i setup a cron to be run at boot time which would give me the public ip address.

The corresponding cron entry is
@reboot /home/pi/progs/godaddy.py

I also created a dns entry to access the machine. And then wrote a script to update the dns record in godaddy whenever the machine reboots. Here is the script.

Now whenever my pi reboots, it checks and updates the corresponding DNS record at godaddy. And i can ssh my machine from anywhere.

Tuesday, January 20, 2015

Ecommerce review : Amazon.in shopping experience

I use ecommerce extensively. All my stuff - from clothes to shoes to electronics to groceries are delivered to my doorstep. The good point about ecommerce is that it saves you from the headache of driving down to the store, parking, standing in a queue to pay for your purchase, and hauling the stuff back to your place. And I use multiple shopping sites for getting my stuff:
Flipkart for books & electronics
Firstcry for diapers & other stuff for kids
Zovi, jabong, myntra in order of preference for clothes and shoes
Peopleeasy for groceries.

I try to avoid shopping on amazon. Reason being that the delivery times are too long. Also there is no quality control from amazon. My last order from amazon was a pair of school shoes for my kid which were defective. Since it was not "fulfilled by amazon" the only option I had was to send it back by a courier and wait for 15-30 days for a refund or go to a nearby cobbler and get the defect fixed. I chose the later. It costed me an additional amount, but saved me from the hassles of refund and re-order.

After that experience, I decided that the only option why I would order from amazon was when the product will be "amazon fulfilled".

I was looking for a coffee maker and found one on flipkart. But flipkart will not deliver it to my pin code. I have never tried snapdeal or paytm but have heard first hand horror stories from people who have used it. The only option was amazon which had the exact model that I was looking for and that too with the "amazon fulfilled" label. The delivery time was 10 days, but still I went ahead and ordered. I still cannot figure out why it takes 10 days for amazon to deliver while flipkart delivers in 3-4 days. And zovi & jabong deliver in 1-2 days. Zovi delivers from bangalore and that too in 2 days max.

When I got a mail that my package has been dispatched by india post, I was a bit astonished. What role does india post play in amazon fulfilled orders. I believe it is the cheapest option. But has service and reliability issues. I kept a track of the package on india post web site as amazon did not update the tracking details on its website frequently.

Finally after 7 days the package arrived in the post office nearest to me. I was hoping that I will get the order the next day. But what happened the next day shook my perception of e-commerce.

I got a call from the post office asking me to pick up the package from there. I was like - what??? And the person on the other end said that it is too big for him to deliver and cut off the phone. I connected up with amazon customer support and was given the assurance that I will get the package on my doorstep next day. Here is the actual conversation:

10:00 AM IST Amazon(Amazon): Thanks for contacting Amazon.in customer service. 
My name is Vijay. 
10:00 AM IST Jayant kumar : hi Vijay, 
10:00 AM IST Amazon(Amazon): Hi! Jayant 
10:01 AM IST Jayant kumar : i got a call from india post telling me that my package is at their facility and i have to pick it up ...
If i have to go out pick up a package, then why order online, wait for 15 days and then pick it up
i can simply go out and buy it from a store
10:02 AM IST Jayant kumar : is this what you call e-shopping ?
10:02 AM IST Amazon(Amazon): I really do apologize for the inconvenience this may have caused you.
10:02 AM IST Jayant kumar : Also, please let me know why this order is being delivered by india post, instead of amazon ?
10:02 AM IST Amazon(Amazon): Let me check what best I can do for you.
10:03 AM IST Amazon(Amazon): I will surely let you know about the same.
10:03 AM IST Jayant kumar : i ordered it because it said that this will be fulfilled by amazon
10:04 AM IST Amazon(Amazon): Jayant, I really appreciate for doing business with us.
10:04 AM IST Jayant kumar : and not india post - the worst courier service in the country
10:05 AM IST Amazon(Amazon): I have contacted the courier partner and have instructed them to deliver to your door step.
10:05 AM IST Jayant kumar : I was told that since the package is "big" it may be broken if delivered to my door step
in case the package is broken, i hope amazon will take it back...
10:06 AM IST Amazon(Amazon): And regarding the courier partner, it is automatically selected by the system and we do not have the option to select the same. 
But we try to dispatch through Amazon service as much as we can.
10:07 AM IST Jayant kumar : Since this package is fulfilled by amazon, please explain how?
10:07 AM IST Amazon(Amazon): Related to broken item, we assure you it will be taken back in such scenarios and will issue a full refund.
10:08 AM IST Jayant kumar : so, fulfilled by amazon does not mean amazon delivery service ?
10:09 AM IST Amazon(Amazon): Amazon Fulfilled guarantees the product to be in a perfect condition and also assures if any defects found customer can return it back within the return window and we will issue a full refund.
10:10 AM IST Amazon(Amazon): But, as I have stated earlier the courier does get selected automatically by the system.
10:10 AM IST Jayant kumar : ok
so, will this be delivered today ?
10:11 AM IST Jayant kumar : since it is at the hub nearest to my place?
10:11 AM IST Amazon(Amazon): I have contacted the courier for the delivery as soon as possible.
10:12 AM IST Jayant kumar : thanks
10:12 AM IST Amazon(Amazon): You are most welcome Jayant.
Is there anything else I may assist you with?
10:13 AM IST Jayant kumar : no
10:13 AM IST Amazon(Amazon): It was a pleasure assisting a valued customer as you.
Hope to see you soon.
10:13 AM IST Jayant kumar : looking forward to ordering more with confidence from amazon
10:13 AM IST Amazon(Amazon): Thank you for contacting Amazon Customer Service.
Have a Wonderful time and day ahead.
10:14 AM IST Amazon(Amazon): I assure, you will not face any such issue in the future. 

Note the final line - I was hoping that this problem is now resolved and was looking forward to the package.

What happened the next day is that in the morning, I got a call from the postman. Again asking me to come and collect the package. It seems that amazon customer service did not take any action on the issue raised by me and has given me false assurance. The two options available to me were to either cancel the order and wait for refund and go out and purchase from the market or go ahead and pick the package from india post. I chose the later - being the easier option of the two. The reason given by the postman was genuine that he cannot deliver a big package on his cycle to which I could not come up with a counter argument.

I was told that the post office opens from 10 am to 5 pm and knowing how government officials work - allowing them their tea, lunch and other breaks, I planned to visit the post office around 3 pm. When they would be done with their lunch and after lunch chit chat. When I reached there, I had to enquire around 4-5 people but was not able to trace where my package was. Everyone was busy doing their own work. So, I called up the postman and told him to connect me to the person who can locate and hand over the package to me. Finally after asking everyone's name and making the person talk with the postman, I was able to take delivery of the package.

So, there is me now carrying 2 big boxes in front of me from the post office to the car and from the car to my flat. All the while people staring at the amazon.in label on the boxes I am carrying and trying to figure if I am the guy who delivers for amazon. They must be figuring the ad of amazon where the delivery guy delivers the package with a smile. I, on the other hand was only concerned if I would encounter anyone who has faced similar fate by amazon and try to engage my as an amazon employee.

By luck the products were ok. I have no idea what will happen if I had to opt for an exchange or refund. If delivery is suoh a hassle, refund / exchange can be non existent. Also I cannot figure out how amazon plans to compete with other sites. When even small sites like zovi outsmart amazon on delivery. I would not be ordering from amazon till I hear some positive reviews.