Skip to content

SmallpTsai/linkit-remote-rpi-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

linkit-remote-rpi-python

What is Linkit Remote

LinkIt Remote is a tool to easily create an iOS/Android remote UI for your LinkIt 7697 Arduino projects. It consists of two software:

  1. The Arduino LRemote library for LinkIt 7697, which allows you to declare remote UI controls in your Arduino project.
  2. The LinkIt Remote iOS/Android application, which allows you to scan and connect to nearby LinkIt 7697 devices running the LRemote library, and send commands to them.

Visit https://docs.labs.mediatek.com/resource/linkit7697-arduino/en/developer-guide/using-linkit-remote for more detail.

What this project do

It provide a LRemote Python library for RPi (any platform use Bluez stack should works too.)

So that you can control your RPi use the same iOS/Android App, save you a lot of effort to write Mobile app.

Installation

  • Follow this Toturial from Adafruit to make sure latest Bluez is installed and has "--experimental" enabled
  • Install python library: dbus-python
    • pip3 install dbus-python
    • Note. It depends on libdbus-1-dev and libglib2.0-dev, so please apt-get install them if necessary
  • Install python library: PyGObject
    • pip3 install PyGObject
    • Note. It depends on libcairo2-dev and libgirepository1.0-dev, so please apt-get install them if necessary
  • Copy the LRemote folder into your source folder
  • add from LRemote import LRemote to your python file
  • call LRemote.xxx apis, check below example

Example code

In this example there will be 1 button and 1 label, when the button is pressed, it will update the label to be "ok", and back to "..." when released

import time

from LRemote import LRemote, LRemoteLabel, LRemoteButton
from LRemote import LRemoteLogger

if __name__ == '__main__':

    # enable this line for more log
    # LRemoteLogger.setLevel(logging.DEBUG)

    label = LRemoteLabel(1, 0, 2, 1, "pink", "...")
    btn = LRemoteButton(0, 0, 1, 1, "orange", "ok")

    def handler(obj, event, value):
        if obj == btn:
            print("btn state = {}".format(value))
            if value:
                label.updateText("ok")
            else:
                label.updateText("...")

    LRemote.setName("MyRPI")
    LRemote.setOrientation("portrait")
    LRemote.setGrid(3, 5)
    LRemote.addControls([label, btn])
    LRemote.begin(handler=handler)

    try:
        while True:
            time.sleep(1)
    except:
        pass

    LRemote.stop()

Verified platform

  • Hardware: RaspberryPi Zero W 1.1
  • OS Image: Rasbian Stretch
  • Python: Python 3.7.0 (build from source)

Known Issue / Todo

  • Make it a python package to support pip installation
  • Python 2.X support check
  • setName() is not working yet, It will still use hostname for BLE advertising
  • Only support Label/Button now, welcome to help contributing

Special Thanks / References

About

Python library for RPi to talk with LRemote App

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages