boolean connect( LBTAddress & address, const char* pinCode = NULL );
boolean connect( LBTAddress & address, const char* pinCode = NULL );
Connects Bluetooth SPP server with Bluetooth address.
|
Parameters |
Description |
|
LBTAddress & address |
Refer to LBTAddress type |
|
const char* pinCode = NULL |
The Bluetooth 2.0 pincode. If you set it as a constant string, it will enable LinkIt One to communicate with a Bluetooth 2.0 device. |
true: Successful.
false: Failed.
#include <LBT.h> #include <LBTClient.h> void setup() { Serial.begin(9600); bool success = LBTClient.begin(); if( !success ) { Serial.println("Cannot begin Bluetooth Client successfully"); // Do nothing. while(true); } else { Serial.println("Bluetooth Client begins successfully"); // start scan, at most scan 15 seconds int num = LBTClient.scan(15); if(num > 0) { LBTDeviceInfo info = {0}; if( LBTClient.getDeviceInfo(0, &info) ) { bool conn_result = LBTClient.connect(info.address);//bool conn_result = LBTClient.connect(info.address, "1234"); if( !conn_result ) { Serial.println("Cannot connect to SPP Server successfully"); // Do nothing. while(true); } else { Serial.println("Connect to SPP Server successfully"); } } else { Serial.println("Device index not correct"); // Do nothing. while(true); } } } }
LBTClient.h