I looked in the .zip file, and found:
//-------------------------------------------------------------------------------
// TinyCircuits ST BLE TinyShield UART Example Sketch
// Last Updated 2 March 2016
//
// This demo sets up the BlueNRG-MS chipset of the ST BLE module for compatiblity
// with Nordic’s virtual UART connection, and can pass data between the Arduino
// serial monitor and Nordic nRF UART V2.0 app or another compatible BLE
// terminal. This example is written specifically to be fairly code compatible
// with the Nordic NRF8001 example, with a replacement UART.ino file with
// ‘aci_loop’ and ‘BLEsetup’ functions to allow easy replacement.
//
// Written by Ben Rose, TinyCircuits http://tinycircuits.com
//
//-------------------------------------------------------------------------------
#include <SPI.h>
#include <STBLE.h>
//Debug output adds extra flash and memory requirements!
#ifndef BLE_DEBUG
#define BLE_DEBUG true
#endif
#if defined (ARDUINO_ARCH_AVR)
#define SerialMonitorInterface Serial
#elif defined(ARDUINO_ARCH_SAMD)
#define SerialMonitorInterface SerialUSB
#endif
uint8_t ble_rx_buffer[21];
uint8_t ble_rx_buffer_len = 0;
uint8_t ble_connection_state = false;
#define PIPE_UART_OVER_BTLE_UART_TX_TX 0
void setup() {
SerialMonitorInterface.begin(9600);
while (!SerialMonitorInterface); //This line will block until a serial monitor is opened with TinyScreen+!
BLEsetup();
}
void loop() {
aci_loop();//Process any ACI commands or events from the NRF8001- main BLE handler, must run often. Keep main loop short.
if (ble_rx_buffer_len) {//Check if data is available
SerialMonitorInterface.print(ble_rx_buffer_len);
SerialMonitorInterface.print(" : ");
SerialMonitorInterface.println((char*)ble_rx_buffer);
ble_rx_buffer_len = 0;//clear afer reading
}
if (SerialMonitorInterface.available()) {//Check if serial input is available to send
delay(10);//should catch input
uint8_t sendBuffer[21];
uint8_t sendLength = 0;
while (SerialMonitorInterface.available() && sendLength < 19) {
sendBuffer[sendLength] = SerialMonitorInterface.read();
sendLength++;
}
if (SerialMonitorInterface.available()) {
SerialMonitorInterface.print(F("Input truncated, dropped: "));
if (SerialMonitorInterface.available()) {
SerialMonitorInterface.write(SerialMonitorInterface.read());
}
}
sendBuffer[sendLength] = ‘\0’; //Terminate string
sendLength++;
if (!lib_aci_send_data(PIPE_UART_OVER_BTLE_UART_TX_TX, (uint8_t*)sendBuffer, sendLength))
{
SerialMonitorInterface.println(F(“TX dropped!”));
}
}
}
If you try to do math on the BLE output of this sketch, it will choke on the
“:” and string length sent in the void loop part.
In AI2, you can use text split at : to break out the
length and string into separate list items.