--------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------- HarrysLua - the embedded scripting language for Harry's apps (c) 2017 Harald Schlangmann --------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------- Revisions --------------------------------------------------------------------------------------------------- v1.0 22. September 2017 Initial write up focussing on sensor.btle purpose v1.1 27. September 2017 Revised samples to latest API, use of gnss, engine, and imu instead of gps, obd, acceleration throught the text v1.2 2. Octoer 2017 Performance considerations chapter added v1.3 10. October 2017 Added section "Is scripting required?" --------------------------------------------------------------------------------------------------- Introduction --------------------------------------------------------------------------------------------------- The document gives an introduction into HarrysLua, a scripting language embedded into Harry's apps and based on Lua 5.3 (see lua.org for reference and programming model). We have planned to enabled scripting for Harry's apps in several areas, but start with its sensor framework. Sensor integration has proven to be both complex and broad. "Broad" means there are hundreds of sensor interfaces out there we can't support using hard coded integration. By making this area scriptable, we address both complexity and broadness: Reduced complexity: the complete path from connection making using the various connection technologies (BT, BT LE, WiFi, Mfi), configuration of sensors, and reading / writing proprietary protocols is supported by powerful extensions to standard Lua. In addition, standard dialects like NMEA for GNSS sensors, or ELM327 for OBD sensors are provided as predefined libraries allowing sensor integration scripts as small as 10 lines of code. Scripts are platform independent too. An integration scripted for iOS will work on Android and vice versa. Allow broadness: scripting allows 3rd parties to provide their own integration - without our direct support and independent from app release cycles. Scripts can be written based on examples provided and tested "in real life" immediately. In case a 3rd party wants to have a sensor integration distributed to all LapTimer users, we can integrate it into release versions too. So far, we had to rejects lots of requests by manufacturers and users to support some new device. Due to capacity and time limitations, we had to pick the main stream / most common devices to support as many users as possible. Scripting will allow much broader support. In case you are interested in adding scripts, please read this document first. It should give you an understanding on how scripts are structured and how they can help to support your goals. Next, head to the Other Sources section and get your hands on the Programming in Lua paperback. It will give you a full understand of Lua, including embedded scenarios like HarrysLua. Finally, get you sensor and one of the sample scripts available and customize it to your requirements. In case you run into any problem, please use the HarrysLua Developer Forum to discuss solutiuons and request features. We are really excited to make this an universal and often used feature, so anyone starting the sensor integraton adventure will get our full support! --------------------------------------------------------------------------------------------------- Availability --------------------------------------------------------------------------------------------------- HarrysLua will be supported in production versions of Harry's apps starting with major release v22. We will make this feature available for early adopters in v21.1 Please watch the forum and our Facebook page for announcements. To allow debugging, we recommend to use Harry's GPS/OBD Buddy for testing. Other than LapTimer et al, Buddy is logging enabled and will allow you to log both the framework and your script. To join the developer program, contact us at Harry@gps-laptimer.de. Developer resources (and support through HarrysLua Developer Forum in particular) are made available for those joining the program only. --------------------------------------------------------------------------------------------------- Is scripting required? --------------------------------------------------------------------------------------------------- Probably not. Harry's apps supports several levels of sensor individualization: Predefined sensors: we try to make genuine sensors used frequently available out of the box. Usually connection making on operating system level is all a user needs to do. The accessory will be recognized automatically and just work. Predefined sensors are either hard coded or scripted (withou exposing this script). Predefined sensors are listed on http://www.gps-laptimer.de/compatibility/ios and http://www.gps-laptimer.de/compatibility/android Custom sensors: in case you have a plain vanilla GPS sensor feeding data using the NMEA, or an OBD sensor using the ELM327 protocol, you can connect it using the app's Expert Settings. The only thing to do is entering connection type and parameters. WiFi and BTLE connection types are supported for both iOS and Android. For Android, any Bluetooth (SPP) sensor speaking the named protocols can be added from Sensor List. Scripted sensors: for sensors requiring special connection configurations including custom initialization, or those featuring a proprietary protocol, scripting is required. Actually scripting is comming in two levels again. For NMEA and ELM327 sensors, a script will focus on connection and initialization only. For proprietary protocols, parsing and requesting data is scripted individually. See the sections below for the details. --------------------------------------------------------------------------------------------------- General structure --------------------------------------------------------------------------------------------------- We start with how a script is created and loaded into Harry's apps. A script files comes with an extension ".hscrl" and is an XML file on top level. To install the script into one of Harry's apps on Android, send it to yourself by mail and touch the attachment in e.g. Gmail. Select Harry's GPS/OBD Buddy from the list of apps shown and you are done. In case you had an older version of the script on your device already, it is replaced by the new version. A minimal script file looks something like this: Harry 1.0 sensor.btle The purpose defines the "plug-in" point into Harry's. If e.g. a purpose sensor.btle is chosen, the script will be used to implement a sensor using BT Low Energy technology. Purposes available or planned so far are: sensor.btle sensor.wifi sensor.bt [TODO] sensor.mfi [TODO] actioncam [TODO] reporting [TODO] import [TODO] Each purpose will define some mandatory and optional functions to be defined by the