11. Appendix
11.1. Codeless SW package content
11.1.1. Description
CodeLess AT Commands platform allows control of a device through local UART as well as a remote device via BLE. Using the well known concept of of AT commands it enables a developer to make a fast peripheral or central application (or both). In its second version CodeLess supports DA145xx, many new AT commands,binary data transfers and SUOTA.
The following at commands sources exist:
Local command source: UART
Remote command source: Bluetooth LE connected peer implementing codeless service/mobile phone application.
Command sequencer: Command scripts can be executed by the command sequencer
Handlers source: Commands can be executed on specific events (on connection, on disconnection etc).
Valid at commands should follow the following format:
(Command specifier)|(Command tag)|[=]|arg1,…argN(Carriage Return)
Command specifier: AT
, AT+
, ATr
, ATr+
Command tag: any of the implemented commands i.e I
, E
, Z
, R
, IOCFG
, BDADDR
etc arg: are the arguments for each command. N should be lower than the maximum allowed number of arguments defined on build (default is 5).
Commands with command specifier ATr
or ATr+
are forwarded to the connected peer if any.
Commands triggers a command action and generate a valid command reply. Some commands may reply with an unsolicited message.
There is also the special pipe command | which sends the following string to the connected peer and when the peer receives it, it prints it out to the local terminal. No reply is expected/generated by the pipe command.
11.1.2. Project/file structure
This repository contains all source and project settings required to produce the CodeLess application binary. It also contains the host application as a Windows executable file, the source code and instruction to build the host application. In particular:
Keil_5: This directory
projects/target_apps/codeless/codeless_5xx
contains the CodeLess Keil project(codeless.uvprojx
) that builds with Arm C. The project is common for all available targets, but different targets can be selected when the project opens.e2studio: This directory
projects/target_apps/codeless/codeless_5xx
contains the CodeLess e2 Studio project(.project
) that builds with LLVM. The project is common for all available targets but different targets can be selected when the project opens.Eclipse: This directory
projects/target_apps/codeless/codeless_5xx
contains the CodeLess SmartSnippets Studio project(.project
) that builds with GCC. The project is common for all available targets, but different targets can be selected when the project opens.IAR: This directory
projects/target_apps/codeless/codeless_5xx
contains the CodeLess IAR Embedded Workbench project(codeless.eww
) that builds with IAR compiler. The project is common for all available targets, but different targets can be selected when the project opens.src: This directory (
projects/target_apps/codeless/codeless_5xx
) contains the source files for the Codeless project.SUOTA: This directory (
projects/target_apps/codeless
) contains the binary files for testing the SUOTA service.
The folders contain all the necessary material to generate the needed files for testing SUOTA with the CodeLess (datapump version). Already working images built with Keil are included as well. To provide a quick and easy way to test SUOTA, the images are advertising as CMv2, CNv2, COv2 and CPv2 instead of CLv2. Ready to test images were moved to the “total” subfolders where they were renamed according to the advertising name for convenience. The rest of the folders show the intermediate steps for the creation of the CodeLess images.
sdk6: This directory contains the SDK repository used for the project, common for both DA14531 and DA14585/DA14586
application: This directory (
projects/host_apps/Host_application
) contains the host application executable.source_code: This directory (
projects/host_apps/Host_application
) contains the source code for the host application.utilities: This directory contains the project and source files for the secondary bootloader
binaries: This directory contains all the binary file for the different targets
codeless-python: This directory (
projects/host_apps
) contains a useful python library and examples in order to communicate with a codeless device over UART or BLE(codeless peripheral).
11.1.3. CodeLess BLE profile
For a CodeLess device to communicate over BLE, a custom BLE profile is provided. Every CodeLess device has 3 characteristics, an inbound data , an outbound data and flow control.
When a CodeLess device acts as a server/peripheral it will accept commands by having the client/central writing to its database to the inbound characteristic. Once the server has a response ready, it will produce a notification through the flow control characteristic to the client that the outbound characteristic has been updated.
When a CodeLess device acts as a client/central it will accept commands by having the server/peripheral producing a notification to the client that the outbound characteristic has been updated. Once the client has a response ready it will gatt write to the servers inbound characteristic the reply.
11.1.4. CodeLess application architecture
This is a quick overview of how the source code of this project is organized. Files prefixed with user_*
implement parts of the CodeLess application.
Callback functions that define behavior of codeless app are implemented in user_codeless.c/h
Most noticeable callbacks are user_at_cmd_ready
that is triggered every time a carriage return is send over local UART, and user_catch_rest_hndl
that handles custom profile messages including command interpreting from application task, and command/reply reception from BLE remote connected peer.
The CodeLess interpreter environment variables are implemented in user_codeles_env.c/h
. The set of AT commands is implemented in user_at_commands.c/h
and a jump table is used. The CodeLess command interpreter is implemented in user_cmd_interpreter.c/h
and is called every time a command string is received either from UART or over BLE. The interpreter will use parsing utilities as implemented in user_cmd_parser.c/h
and user_utility_functions.c/h
have more generic tools used throughout the application.
Files user_gatt.c/h
, user_gap.c/h
are responsible for sending to peer over gatt commands and responses, scanning and connecting over gap.
Files such as user_handlers.c/h
, user_bonding_database.c/h
, user_pwm.c/h
, user_security.c/h
, user_heartbead.c/h
, user_baud.c/h
, user_spi.c/h
, user_i2c.c/h
provide the respective application functionality.
11.1.5. Python tools
In order to facilitate interaction with codeless devices, a python library and a set of examples has been developed. It can be used to connect to a local (UART) codeless device or a remote (BLE) peripheral device, send commands and receive replies.
11.1.6. License
SDK License can be found in the respective sdk folder: sdk6/doc/licensing.txt
. Project licence can be found in the respective doc folder.
11.2. Codeless Host Application
codeless_host_app
is a graphic user interface application, written in python, to send commands to the connected Codeless device. The user is able to:
Connect or disconnect to the serial port of the Codeless device,
Send AT commands and see their output,
Enter, exit and resume binary mode easily. If the remote device, which is connected with the Codeless device, sends
AT+BINREQ
, local device automatically responds withAT+BINREQACK
. If the remote device sendsAT+BINREQEXIT
, then the local device exits automatically binary mode using sequence of AT andAT+BNREQEXITACK
commands,Send a file (text or binary) while the device operates in binary mode,
Keep a log file of any received file from the remote host (SAVE LOG button)
Keep a log file of all the commands that are sent to the local device (under current folder
<timestamp>_console.log
)Send a batch file, containing a set of AT commands with a new line separated, –> is the indication of input command, <– is the indication of the command reply, OK or ERROR is the default terminating strings and anything in between is for validation that the command is executed with the correct parameters
eg.:
–> AT+GAPSTATUS
<– AT+GAPSTATUS
0,0
OK
Stop the executed batch file, if any command responds with an error,
Be notified by an indication that the binary mode is on (blue color) and off (yellow led),
Reconnect or change any of the serial’s port parameters without pressing Disconnect option from the menu.
11.2.1. Requirements
Python Required version is Python 2.7.15
Installation - Download the Python installer from Python 2.7.15 - Add Python to PATH
PyInstaller PyInstaller freezes (packages) Python applications into stand-alone executables.
Installation
- pip install PyInstaller==3.6
- Rename pyinstaller.exe
to pyinstaller2.7.exe
Create the executable under current folder - Open any command prompt. - Navigate to the codeless-pytohn folder. - Execute following command to generate the .exe file
`pyinstaller27.exe -n codeless_host --onefile gui_app\codeless_host_app.py --windowed -i gui_app\Dialog_D-Symbol_Color_RGB_Small_icon.ico --add-data "gui_app\Dialog_D-Symbol_Color_RGB_Small_icon.ico;." --hidden-import pygatt --distpath gui_app\`