Python code for data transfer between Bluetooth Module and Android Mobile (through App)

#Code is written for communication between HC-05/HC-06 Bluetooth
#module and Android device using SPP app developed at IGDTUW and
#available at website www.mysmartphone.mobileeducationkit.net
# Code version V1.0, written by Project staff
#Suitable for working with UART on Raspberry pi 2 and older versions
# If instructions mentioned separately followed.

import serial
import time
port=serial.Serial(“/dev/ttyAMA0”,9600, timeout=3.0)
print”\nBluetooth Communication Between RPI & ANDROID mobile Device\n”
print “Send somthing from Android device”
while True:
        port.flushInput()
        port.flushOutput()

        time.sleep(2)
        rcv=port.read(50)
        if rcv:
                 print”Received String from Android: ” + rcv
                 time.sleep(2)
                 keyin = raw_input(“Enter a string to send:”)
                 port.write(keyin)
                 print “Send somthing from Android device”