Syntax
size_t write(
    const uint8_t* buf, 
    size_t size = 1
);
ContentsIndex
PreviousUpNext
LBTServerClass::write Method (uint8_t*, size_t)
LBTServerClass Class | Example
Syntax
size_t write(
    const uint8_t* buf, 
    size_t size = 1
);
Description

Writes data to a Bluetooth SPP client.

Parameters
Parameters 
Description 
const uint8_t* buf 
[IN] The data to write. 
size_t size = 1 
[IN] The size of the buffer. 
Returns

Number of bytes written. 

0: Write failed.

Example
#include <LBT.h>
#include <LBTServer.h>
 
void setup()
{
  Serial.begin(9600);
  bool success = LBTServer.begin();
  if( !success )
  {
      Serial.println("Cannot begin Bluetooth Server successfully");
      // Do nothing.
      while(true);
  }
  else
  {
      Serial.println("Bluetooth Server begins successfully");
  }
 
  // waiting for Spp Client to connect
  bool connected = LBTServer.accept(20);
 
  if( !connected )
  {
      Serial.println("No connection request yet");
      // Do nothing.
      while(true);
  }
  else
  {
      Serial.println("Connected");
  }
}
 
void loop()
{
    char* buffer = "LinkIt BT Server";
    int write_size = LBTServer.write((uint8_t*)buffer, strlen(buffer));
    if(write_size > 0)
    {
        Serial.print("Size written: ");
        Serial.println(write_size);
    }
}
File

LBTServer.h

Class