2. Getting started

2.1. How to use CodeLess

的CodeLess is a quick Bluetooth® low energy solution that can be used out of the box without writing a single line of source code. It uses the well-known concept of AT Commands (ASCII instructions) that can be used to perform various tasks and in particular: - Control of BLE connectivity: BLE connect/disconnect, advertise, stop advertising, change roles (central/peripheral), scan for nearby devices, report BLE address, etc. - Interaction with the environment/sensor read out: Set/get GPIOs, read external interfaces, read battery, report GPIO status etc

的se AT commands will allow control over the local device as well as remote device, allowing you to easily integrate in a 3rd party microcontroller.

One can simply control from the Terminal and NO IDE is required!

_images/noIDE.png

Figure 6No IDE required

的user is free to choose any thrid-party terminal or Dialog’s very ownCodeLess Host application. Refer to chatper 7 for more information and how to download the application in your local PC.

_images/terminal.png

Figure 7CodeLess using Terminal

Android users may want to check out Dialog’s SmartConsole for an AT command execution application. Refer to chapter 8 for more information.

_images/atscreen.png

Figure 8SmartConsole application

2.2. Hardware Setup

的general setup to implement the CodeLess examples are as follows. This manual explains the use of Pro-Kit to show the examples however you can use the basic kit as well. The setup to implement CodeLess examples for DA14531 and DA14585/586 is given below.

Setup on DA14531 Pro-DK Motherboard:

To quickly get started with the CodeLess on a terminal, one can simply download and execute from the SysRAM using the Booter configuration as mentioned below. To execute from SPI Flash, please referhereto follows steps to program the SPI Flash.

  • Using the DA14531 Pro-DK motherboard, either DA14531, DA14531 Module, DA14585 or DA14586 daugterboard can be used with the same fly-wire and jumper connections
  • 的DA14531 USB kit cannot be configured to boot from SPI flash and also operate a 2/4 wire UART - for this reason it is not well suited to being used as a platform for CodeLess.
  • Use the flywires to connect from J1[UTX] to J2[P26], J1[URX] to J2[P25], J1[URTS] to J2[P27] and J1[UCTS] to J2[P28] as shown in the figure below
  • Use the jumpers to enable the SPI Flash as shown in the figure below and connect the rest of the jumpers as shown
  • Connect the Pro-DK to PC via USB cable
  • 3 LEDs will lit up, namely, D1, D2 and D4
_images/pro_531.png

Figure 9DA14531 Setup on DA14531 Pro-DK: SPI and 4-wire UART for CodeLess execution

Below is also the 4-wire UART connections from the Pro-DK motherboard to DA145xx (`DA14531/DA14585/DA14586) daughterboard overview.

_images/4wire.png

Figure 10DA145xx 4-wire UART connection overview


_images/module.png

Figure 11DA14531模块设置在DA14531 Pro-DK:四线UART for CodeLess


_images / 531585. png

Figure 12DA14585/586 Setup on DA14531 Pro-DK: SPI and 4-wire UART for CodeLess

Setup on DA14580 Pro-DK or DA14585/586 Basic kit for DA14585/586:

  • Connect the 3-way jumper that is needed to enable concurrent access to SPI-Flash and UART interface (jumpers are marked in red)
  • Connect the Pro-kit via USB cable to your PC
  • 3 LEDs will lit up, namely, D1, D4 and D6
  • For the LED example, when using Pro-kit the LED D3 toggles and for Basic kit LED D7 toggles
_images/5315852.png

Figure 13DA14531 Setup on DA14580 Pro-Kit

_images/setup.png

Figure 14DA14585/586 Setup on Pro-Kit

_images/basicsetup.png

Figure 15DA14585/586 Setup on Basic-Kit

Note

的red blocks indicate where the jumpers are supposed to be placed.

2.3. Software Setup

的CodeLess SDK comes with these following firmwares. Depending on the SoC and application, the user can download the appropriate firmware.

List of pre-compiled binaries provided with the SDK are:

  1. CodeLess for DA14585/586 (codeless_585.hex)
  2. CodeLess for DA14531 datapump (codeless_531_datapump.hex)
  3. CodeLess for DA14531 standalone (codeless_531_standalone.hex)
  4. CodeLess for DA14531 standalone SET TWO (codeless_531_standalone_set_two.hex)

For the examples in the Manual, CodeLess for DA14531 standalone (SET TWO) is used. Also, depending on the application and the set of commands supported in each firmware, the user is free to choose the appropriate one. To see the list of commands supported for each target, referTable 8

Likewise, the user can also add their custom commands by simply following the chapter 6 and by compiling the code using Keil compiler.

To quickly play with this, follow the below steps to send your first AT command.

  • Load CodeLess firmware into DA14531/DA1458x using SmartSnippets™ Toolbox. Use the Booter over Serial wire debug (SWD) to download the firmware to SysRAM or use Flash Programmer to burn the firmware onto flash and execute from flash. Please refer to SmartSnippets™ ToolboxUser Manualchapter 8 and 13 for this.
  • Open SmartSnippets™ Toolbox and select project or create a new one with any appropriate name, JTAG serial number, Target and click Open, like so,
_images/open_project.png

Figure 16SmartSnippets configuration

  • Go to Tools and select Booter. The board setup is as shown in the picture. Browse to your firmware and click download, like so,
_images/download_hex.png

Figure 17Downloading to SysRAM

  • To send AT commands, use the terminal to communicate with the board with the following settings, like so,

    • PORT :
    • BaudRate : 57600
    • DataBits : 8
    • StopBits : 1
    • Parity : None
    • Flow Control : None
    • Transmit Text: Append CR
_images/portsettings.png

Figure 18Serial Port Settings

  • Send your first AT command, like so,
_images/terminal_test.png

Figure 19AT over terminal

Note

When the DA14531/DA1458x powers up, it will stay awake for ten seconds and then go to extended sleep. If a character is received via UART within the 10 second window, the device will stay awake until it receives a sleep command (AT+SLEEP=1). Send a ‘@’ via the UART to wake up a sleeping device.


Alternatively,Dialog SmartBond™ Flash Programmer toollets the user program a flash device for the DA14531 SoC. This is a quicker way to ge things going with the CodeLess. The list of hex files are shown in the figure below,

_images/firmware_web.png

Figure 20Flash programmer Tool Download firmware from web

的setup is quite simple and the instructions to use the tool is explained in theUser Manual UM-B-138.


Demonstration of Dialog SmartBond™ Flash Programmer tool


2.4. CodeLess Bluetooth Services

的CodeLess service UUID is the following: 866d3b04-e674-40dc-9c05-b7f91bec6e83. The CodeLess service provides the characteristics shown in the table below:

Table 1 CodeLess characteristics
Characteristic UUID Length Properties Comments
CodeLess inbound command characteristic 914f8fb9-e8cd-411d-b7d1-14594de45425 1 - 165字节 Read, Write A CodeLess AT command can be written here. The read property is not used.
CodeLess outbound command characteristic 3bb535aa-50b2-4fbe-aa09-6b06dc59a404 1 - 165字节 Read, Write 的response of a previously issued AT Command can be read. The write property is not used.
CodeLess Flow Control Characteristic e2048b39-d4f9-4a45-9f25-1856c10d5639 1 byte Notify, read, write A notification that data is available from BLE CodeLess peer.

Apart from the CodeLess service the software supports both the SUOTA service and a the DSPS service as well.

2.5. SPI set of commands

基于底层控制器硬件,无附件软件支持具有专用命令集的串行外设接口操作。支持的操作是具有某些限制的外部设备的SPI配置,读取和写入外部设备: - 无附件软件仅支持SPI主模式操作 - 不支持多个从设备 - SPI时钟频率可以为2,4和8 MHz

For more details on the dedicated SPI set of commands refer to Chapter 9.

2.6. Event Management

的CodeLess software supports several events that can be used to indicate the state of the device to an external host. If activated, each event outputs a specific string to the serial port. Currently six events are supported, the following:

  • 初始化:如果事件被激活,如年代oon as the device is initialized an unsolicited message will be printed to the serial port to indicate that the device is working. From this point on the device is fully functional and AT Commands can be sent to the serial port.
  • On connection: If the event is activated, as soon as a Bluetooth connection is established the CodeLess software will send an unsolicited message to the serial port.
  • On disconnection: If the event is activated, as soon as a Bluetooth connection is dropped a unsolicited message will be sent to the serial port to indicate that the device has disconnected.
  • On wakeup: If the event is activated, an unsolicited message will be sent to the serial port as soon as the device wakes up from sleep.

All events are disabled by default on startup and the user must enable the desired events using the related event management commands that are documented in Chapter 9. The status of the events can be queried at any time. Please note that the status of the events in not retained in case of a reset or power cycle unless non-volatile storage is activated within the source code. If non-volatile storage is activated, then the CodeLess software will try to restore the status of the events on startup. If not, any desired events must be activated again by the host. No events are printed if the Codeless software is in binary transfer mode.

2.7. Bonding Database Management

Bonding allows two connected devices to exchange and store security and identity information to create a trusted relationship. Therefore, in the future an encrypted connection can be re-established without the need to exchange encryption keys for the second time. The CodeLess software supports a bonding database that can store bonding information for several external devices. The implementation has the following characteristics:

  • 数据库可以存储最多5个不同设备的绑定信息
  • If the database is not full and new bonding entry arrives it will be stored in one of the empty slots
  • If the database is full and new bonding information arrives then the older bonding entry is erased. The new entry becomes the most recent entry in the database.
  • Entries can be marked persistent. A persistent entry does not participate in the replacement mechanism and remains in the database regardless of new arrivals
  • If all entries are marked persistent then no more bonding information can be stored in the database
  • If a connection is re- established using a database entry, this entry becomes the most recent one in the database

的database can be managed using a related set of AT commands. The related commands can clear the bonding database, change the persistence status of an entry, remove a selected entry and import entries from an external host. It must be noted that the bonding database is not retained on reset or on power cycle. Therefore, the database must be exported and then reimported back by the host.

2.8. Event Handlers

In addition to event management support the CodeLess software supports the execution of AT commands on three predefined events (on connection, on disconnection and on wakeup). The user can enter a set of commands from the CodeLess command set that will be executed sequentially when the event occurs as if the user entered the commands through the console. If the handler is empty no commands will be executed.

2.9. Flow control and Sleep modes

Hardware flow control using UART RTS/CTS signals is possible using the AT+FLOWCONTROL command. When the device boots, it is by default not using Hardware (HW) flow control. In binary mode the HW flow control signals the available space of buffers of the device (RTS) and the availability of the host (CTS). In command mode the RTS/CTS signals have important role in signaling their sleep mode or waking up the device or host. Flow control is tightly interconnected with sleep modes.

的host may enable or disable sleep mode of the CodeLess device using the AT+SLEEP command.

  • If HW flow control is disabled, the device may be woken from a high to low transition of UART RX signal, this can be a dummy UART byte of value 0x00.
  • If HW flow control is enabled the device’s RTS signal is deasserted. The device may be woken from a high to low transition of CTS signal.

的re is also a host sleep mode supported. If the host wishes to enter its own sleep mode it should inform the CodeLess device using the AT+HOSTSLP command.

  • If HW flow control is disabled the device will wake up the host by issuing a for every .
  • If HW flow control is enabled the device will wake up the host by toggling its RTS for every .

In both cases the host should acknowledge the wakeup by issuing an “AT” command.

Note

In Binary mode if flow control is disabled (using AT+FLOWCONTROL) the device never enters sleep mode becuase this will cause loss of data. If flow control is enabled the RTS signal is asserted when the device is active in connection events.

Table 2 and Table 3 provides information regarding sleep modes with and without the HW flow control, like so,

Table 2 Sleep modes without RTS/CTS flow control
Command format Enter Sleep Exit Sleep Description
Device sleep AT+SLEEP=1 A dummy byte 0x00 from host This does not suspend every function of the device; it enables extended sleep. The device will acknowledge exiting sleep mode by an AWAKE string.
Host sleep AT+HOSTSLP=1,0, 100, 1000 By issuing byte 0x00. 的byte that will be issued is the second parameter of AT+HOSTSLP. The host should acknowledge exiting sleep mode with an AT command.


Table 3 Sleep modes with RTS/CTS flow control
Command format Enter Sleep Exit Sleep Description
Device sleep AT+SLEEP=1 A Hight to low of CTS signal (input to the device). This does not suspend every function of the CodeLess device, it enables extended sleep. The RTS will be deasserted. The device will acknowledge exiting sleep mode by an AWAKE string and will assert RTS.
Host sleep AT+HOSTSLP=1,0, 100, 1000 A Hight to low of RTS signal (input to the host). 的second parameter of AT+HOSTSLP is not effective. The host should acknowledge exiting sleep mode with an AT command.