Skip to content

Instantly share code, notes, and snippets.

@valkjsaaa
Last active September 3, 2015 02:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save valkjsaaa/457d3217b1f45fda14a1 to your computer and use it in GitHub Desktop.
Save valkjsaaa/457d3217b1f45fda14a1 to your computer and use it in GitHub Desktop.
features in the IOT system

Feature and progress report of the IoT system

Here I listed most of the features of the IoT system that I have implemented or I'm goint to implement. Tick in the checkbox means that it is done, empty checkbox means that it is still under development.

Overall Progress

  • Desktop system
  • Mobile system
  • Query server(I need to build a server in order for the global query to work)

Regular User

Global

  • find/query a object globally

expression: IOT.Global.find(rules, types)

comment: Only certain rules are supported, such like geo-location.

  • create a thing by uuid

expression: thing = Thing(uuid)

comment: The system will automatically gather all the capabilities of that Thing.

Local

  • find a Thing around the end user

expression: IOT.find(rules, types)

comment: In contrast, the rules here can be any function.

  • find all Thing around the end user

expression: IOT.findAll(types)

  • find nearest Thing around the end user

expression: IOT.findNearest(types)

Task with Thing

Assume that the user already has a Thing: thing

  • call an existing function

expression: return_value = thing.func(parameters...)

  • list all function supported

expression: thing.[press tab in interactive environment]

comment: For power user, there is a way to gather all the function name programatically.

  • subscribe to a subscribable value

Assume that the user has created a callback function (callback) to process new value for variable.

expression: token = thing._subscribe("variable", callback)

comment: User should keep the token. Once the object is freed from the system, the subscription will stop. This feature is used to subscribe a changing variable (For example, the temperature characteristics of a Thing) to this Thing and watch it, once the variable changes, callback will be called reactively.

  • see the documentation of a function

expression: thing.func?

comment: This depends on whether the function creator has created a doc string for this function.

What "Regular User" expected to create

Universal light switch
light = IOT.findNearest("light")
light.turn(!light.light)
Home alert
HOME_UUID = '93DB3DEA-2234-4BC6-8594-103F732313A5'
PERSON_UUID = 'D993F2AA-55F5-472A-A336-AF8B58DCDA81'

home = Thing(HOME_UUID)
me = Thing(PERSON_UUID)

def callback(motion):
	if(motion > 70 && !(me in home.surrounding())):
    		alert("Some one is in your home!")

home._subscribe("motion", callback)

Power User

More about Thing

  • create a function for a Thing. (Assume the user has already written a function func.)

expression: thing._createMethod("funcName", func, funcParameters, "function doc string")

  • create a subscribable variable for a Thing

expression: thing._createSubscribable("name", value, "doc string")

  • create a type for a Thing

expression: thing._addType("light")

  • nest a Thing inside another

expression: Thing thingA._addNested(thingB)

What "Power User" expected to create

a Person
import sl4a

PHONE_UUID = 'C1893026-13EF-41F9-9023-4A61B7F76251'
PERSON_UUID ='1DB4ACE3-E219-4A07-990A-5C75A3DD2B4A'

phone = Thing(PHONE_UUID)
phone._createMethod("identify", lambda: sl4a.AndroidFacade.vibrate(10), {})

phone._createType("phone")
phone._createMethod("phoneNumber", lambda: sl4a.PhoneFacade.getLine1Number(), {}, "get current phone's number")

phone._createType("smartphone")
phone._createMethod("speak", lambda text: sl4a.EyesFreeFacade.ttsSpeak(text), {"text": "string"}, "speak a text in speaker")


person = Thing(PERSON_UUID)
person._createMethod("identify", lambda: phone.identify(), {})

person._createType("person") person._addMethod("email", lambda: "jackieyang51@gmail.com", {}, "get the person's email")
person._createMethod("name", lambda: "Jackie Yang", {}, "get the person's name")
person._createMethod("notify", lambda: phone.speak(person.name() + ", you have got a message!"), {}, "notify the person")

phone._nested.append(person)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment