4. Binary Mode

CodeLess on the DA14531 offers two distinct modes of operation. So far the chapters covered pertains to the standalone CodeLess which is the command mode. This section gives an overview of the binary mode. Binary mode is used for the purpose of data pumps wherein the Bluetooth CodeLess device transfers data without examining it contents, which is the prefered method for end to end raw data transfer.

The DA14531 can be switched from Command mode to Binary mode and back to command mode or any other combination. The flow of commands to achieve this is mentioned below in the form of an example.

4.1. Example to show switching between Command mode and Binary mode

Description - Enter the Binary mode from the Command mode and back to Command mode between DA14531 and remote DA14531.

Software setup - codeless_531_datapump.hex is used to demonstrate Binary mode functionality

Hardware setup - As shown in Figure 9. To proceed with this example, connect two DA14531 Pro-DK to the PC and follow the commands as mentioned below.

Note

For all the AT commands you need to append CR, for escape sequence and binary mode you need to append NOTHING

AT command sequence:

  1. The DA14531 and remote DA14531 need to be connected.

    The set of commands to achieve this is mentioned in section 3.4.1

  2. Open two terminals for the communication. Since we are still in Command mode, keep the “append CR” enabled. For the ease of understanding, the DA14531 and remote DA14531 are represented by 531 and 531_R.

    531 - implies the commands being sent from DA14531 terminal 531_R - implies the commands being sent from remote DA14531 terminal

  3. Command mode to Binary Mode:

    After the 531 and 531_R are connected, execute the following,

    531: AT+BINREQ (The 531 requests the 531_R to enter the binary mode)

    531_R: AT+BINREQACK (531_R must send an acknowledgment back to 531 to enter binary mode)

    • Now both the devices have entered the Binary mode.
    • Test by sending random data from 531 and 531_R receives the same message and vice-versa.
  4. Binary mode to Command mode:

    531: +++ (this is the escape sequence and when sending this sequence in the terminal, you must NOT append a CR)

    531: AT+BINREQEXIT (append CR since its an AT command)

    531_R: AT (or any AT command, just to verify entering command mode)

    531_R: AT+BINREQEXITACK (acknowledgment can be sent to 531 on entering command mode)

4.2. Binary mode - Entering and exiting flow

Below is the picture that gives overview of the sequence of AT commands of entering and exiting the Binary mode.

_images/flowchart.png

Figure 37 Entering and Exiting Binary Mode

The signal flows for various cases, entering, exiting, suspending and resuming the binary mode is shown above.

The 531 device may switch to binary mode by using the command AT+BINREQ. The 531_R device should acknowledge this by AT+BINREQACK. When this command is detected by the command path the internal data path of the CodeLess devices is switched from CodeLess parser to Binary mode buffers, which is compatible with DSPS (Dialog Serial Port Service).

When any of the participating device need to exit binary mode, there are two cases.

  • With a smart device one can just write AT+BINREQEXIT to the remote CodeLess device receiving characteristic. Then the escape sequence will be issued to the remote CodeLess host to signal the exit from the binary mode. The remote CodeLess host should acknowledge exiting the binary mode by issuing an AT+BINREQEXITACK signaling the actual switch to the command mode.
  • With another CodeLess device, any of the host devices may issue the escape sequence followed by an AT+BINREQEXIT and then wait for an AT+BINREQEXITACK.

Note that the escape sequence issued by a host device suspends only locally the binary operation, means that the host may issue AT commands and then resume binary mode by issuing AT+BINRESUME.The actual switch to codeless mode for all devices is accomplished when AT+BINREQEXIT is issued and the remote host acknowledges the exit sequence by an “AT” command. The AT+BINREQEXITACK is a passthrough command without any effect in the internal states of the device and it is provided as a convenient way to mark the exit of remote host from binary mode.

If a host needs to exit binary mode, then it should issue the escape sequence. The escape sequence is comprised of a guard time, followed by three escape characters and another guard time. That is escape time1 -> escape characters -> escape time2. The user may use zero values for escape times if he is planning to use a custom protocol that reserves the escape characters for binary mode exit condition. In binary mode the default packet size is set to MTU size-3 and MTU size is set to RX/TX packet length-4. Arbitrary selection of MTU (AT+MAXMTU) or RX/TX packet length (AT+DLEEN) may cause loss of data in binary mode.

Demonstration of CodeLess Binary Mode