2. Getting Started
2.1. How to Use CodeLess
The 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 Bluetooth® LE connectivity: Bluetooth® LE connect/disconnect, advertise, stop advertising, change roles (central/peripheral), scan for nearby devices, report Bluetooth® LE address, etc
Interaction with the environment/sensor read out: set/get GPIOs, read external interfaces, read battery, report GPIO status etc
These AT commands allow control over the local device and remote device, and easily integrate in a third-party microcontroller.
One can simply control from the Terminal and no IDE is required.
The user is free to choose any third-party terminal or Dialog’s CodeLess Host application. Refer to Chapter 7 for more information and how to download the application to your local PC.
Android users may want to check Dialog’s SmartConsole for an AT command execution application. Refer to Chapter 8 for more information.
2.2. Hardware Setup
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 DA145xx is given below.
Setup on DA1453x Pro-DK Motherboard
To quickly get started with the CodeLess on a terminal, download and execute from the SysRAM using the Booter configuration as mentioned below. To execute from SPI Flash, refer to UM-B-083 to follows steps to program the SPI Flash.
Note
Using the DA1453x Pro-DK motherboard, you can use either DA14531-00,DA14531-01, DA14531 Module, DA14585 or DA14586 daughterboard with the same fly-wire and jumper connections. The 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 Figure 9.
Use the jumpers to enable the SPI Flash and connect the rest of the jumpers as shown in Figure 9.
Connect the Pro-DK to PC via USB cable.
Three LEDs lit up: D1, D2, and D4.
Figure 10, Figure 11, and Figure 12 display also the 4-wire UART connections from the Pro-DK motherboard to DA145xx daughterboard overview.
The pin mapping on the DA145xx is in the following table:
DA145XX Pin |
Function |
---|---|
P0_6 |
UART TX |
P0_5 |
UART RX |
P0_7 |
UART RTS |
P0_8 |
UART CTS |
Setup on DA14580 Pro-DK or DA1458x Basic Kit for DA1458x
Connect the three-way jumper to enable concurrent access to SPI-Flash and UART interface.
Connect the Pro-Kit via USB cable to your PC.
Three LEDs lit up: D1, D4, and D6.
For the LED example, when using Pro-Kit, the LED D3 toggles and for Basic Kit, LED D7 toggles.
Note
The red blocks indicate where the jumpers are supposed to be placed.
2.3. Software Setup
The CodeLess SDK comes with the following firmware images. Depending on the SoC and application, the user can download the appropriate firmware.
Pre-compiled binaries provided with the SDK:
CodeLess for DA1458x (codeless_585.hex)
CodeLess for DA1453x datapump (codeless_531_datapump.hex)
CodeLess for DA1453x standalone (codeless_531_standalone.hex)
CodeLess for DA1453x standalone SET TWO (codeless_531_standalone_set_two.hex)
For the examples in the Manual, CodeLess for DA1453x 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, see Section 9.
Likewise, the user can also add their custom commands by following the Chapter 6 and by compiling the code using Keil compiler.
To send your first AT command, follow the steps:
Load CodeLess firmware into DA145xx 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. Refer to SmartSnippets™ Toolbox User Manual Chapter 8 and 13.
Open SmartSnippets™ Toolbox, select project or create a new one with any appropriate name, JTAG serial number, Target, and then click Open as shown in Figure 16.
Go to Tools, select Booter, browse to your firmware, and then click Download as shown in Figure 17.
To send AT commands, use the terminal to communicate with the board with the following settings:
PORT : <COM_Port>
BaudRate : 57600
DataBits : 8
StopBits : 1
Parity : None
Flow Control : None
Transmit Text: Append CR
Send your first AT command.
Note
When the DA145xx 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 tool lets the user program a flash device for the DA1453x SoC. This is a quicker way to get things going with the CodeLess. The list of hex files are shown in the Figure 20.
The instructions on how to use the tool is explained in the User Manual UM-B-138.
Demonstration of Dialog SmartBond™ Flash Programmer Tool
2.4. CodeLess Bluetooth Services
The CodeLess service UUID is the following: 866d3b04-e674-40dc-9c05-b7f91bec6e83. The following table lists the characteristics that the CodeLess service provides.
Characteristic |
UUID |
Length |
Properties |
Comments |
---|---|---|---|---|
CodeLess Inbound Command characteristic |
914f8fb9-e8cd-411d-b7d1-14594de45425 |
1 – 165 bytes |
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 bytes |
Read, Write |
The 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 Bluetooth® LE CodeLess peer. |
Apart from the CodeLess service the software supports both the SUOTA service and the DSPS service.
2.5. SPI Set of Commands
Based on the underlying controller hardware, the CodeLess software supports Serial Peripheral Interface operations with a dedicated set of commands. The operations supported are SPI configuration, reading and writing of external devices with certain limitations:
The CodeLess Software supports only SPI master mode operation
Multiple slave devices are not supported
The SPI clock frequencies can be 2,4 and 8 MHz
For more details on the dedicated SPI set of commands refer to Chapter 9.
2.6. Event Management
The 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 the following six events are supported:
On initialization: If the event is activated, as soon 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, an 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.
Note
The status of the events is 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:
The database can store bonding information for up to five different devices
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
The 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.
The 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
There 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 <wkup_byte> for <wkup_retry_times> every <wkup_retry_interval>
If HW flow control is enabled, the device will wake up the host by toggling its RTS for <wkup_retry_times> every <wkup_retry_interval>
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 because 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 provide information regarding the sleep modes with and without the HW 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. |
The byte that will be issued is the second parameter of AT+HOSTSLP. The host should acknowledge exiting sleep mode with an AT command. |
Command Format |
Enter Sleep |
Exit Sleep |
Description |
---|---|---|---|
Device sleep |
AT+SLEEP = 1 |
A High 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 High to low of RTS signal (input to the host). |
The second parameter of AT+HOSTSLP is not effective. The host should acknowledge exiting sleep mode with an AT command. |