1. Home
  2. Sorce Documentation
  3. Libraries
  4. Python – Core functions

Python – Core functions

RemoteMe class

Configuring, monitor connection, sending messages. These are the core functions and you should import all the dependencies at all your RemoteMe Pages. Basically you write your own python scripts which are manage by RemoteMe program at Raspberry Pi. RemoteMe Raspberry Pi Program also create socket server where all your python script connect and then send and receive messages.

 

SourceCode

Prepare
How script is run

At system configuration you set name of the script to run, Usually Raspberry Pi Program use first sh scripts which looks like :

parameters:

  • $1 – directory of the script (its ./) [TODO] at your python script usually at the beginning you are changing working directory into these value by :
  • $2 –  parentId – its deviceId of rasbperryPi
  • $3 – deviceId – its deviceId of current run script
  • $4 – its a port where RPiProgram open socket connection
  • $5 – device name od the script

To import needed RemoteMe class at your python script

at base directory are needed files

Functions
startRemoteMe(sys.argv)

connect to open socket created by Raspberry Pi

Example of use:
 

startRemoteMeDirect(port, parentId, ownId,name)

does the same which

but here you add all properties as function arguments

  • port – port of raspberry Pi program where socket server opens
  • parentId – deviceId of parent raspberry Pi
  • this script deviceID
  • name – device name of this script
sendUserMessage(receiveDeviceId,data)

sendUserMessage to device with ID receiveDeviceId. parameters:

  • receiveDeviceId – device where message will be send
  • data – data to send it can be String, Array with all elements less then 256, or byteArray

If to the Raspberry Pi is established webrtc connection, by deviceID equals to receiveDeviceId, then this message will be sent by webrtcDataChannel, otherwise web socket will be used to deliver this message

example :

logServerInfo(message)

send to server Info log. Logs can be seen at real time at Logs tab at the system. example of use: TODO add with screen form to system

logServerWarn(message)

send to server Warning log. Logs can be seen at real time at Logs tab at the system. example of use:  look at logServerInfo

logServerError(message)

send to server Error log. Logs can be seen at real time at Logs tab at the system. example of use:  look at logServerInfo

Events
setUserMessageListener: function(senderDeviceId,data)

add function to be called when userMessage comes to script

example:

 

setUserSyncMessageListener: function(senderDeviceId,data)

add function to be called when synchronized userMessage comes to script. Function have to return value which will be passed to the caller.

example: