Skip to content

arduino library for bluetooth a2dp module based on BK8000L chip from BEKEN corp.

License

Notifications You must be signed in to change notification settings

Gegerd/BK8000L

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

arduino library for BK8000L

This directory contain all files needed to support A2DP bluetooth module based on Beken BK8000L chip.

BK8000L (F-6188 module at least) have AT command control support, supported commands are described here

how to connect BK8000L

directly to computer

this is for testing if your module has serial interface enabled:

BK8000L computer(USB2serial for example)
RX TX
TX RX
GND GND
VBAT via diode to 5V

arduino using software serial (UNO, nano..)

BK8000L computer(USB2serial for example)
RX 7 (1st parameter of SoftwareSerial in example)
TX 6 (2nd parameter of SoftwareSerial in example)
RESET 5 (defined as resetBTpin in example)
GND GND
VBAT via diode to 5V

arduino using harware serial (mega ..)

BK8000L computer(USB2serial for example)
RX TX1 (if using Serial1)
TX RX1 (if using Serial1)
RESET 5 (defined as resetBTpin in example)
GND GND
VBAT via diode to 5V

how to use it

Information about using libraries on arduino site

Copy content of this repository directory or just this two files: BK8000L.cpp, BK8000L.h to ~/Arduino/libraries/BK8000L/ directory (if did not exist, create one). Open new project in arduino and use this code, or check code in examples directory BK8000L.ino:

#include "BK8000L.h"
#include <SoftwareSerial.h> //if using SW, with HW no need for this

#define resetBTPin 5
 
SoftwareSerial swSerial(7, 6); //rxPin, txPin

BK8000L BT(&swSerial, resetBTPin); //in case of HW serial use for example: (&Serial1)

void(){
  BT.begin(); //or BT.begin(9600); for specific baudrate
}

void loop(){
//should be call periodically, to get notifications from module, for example if someone calling...
BT.getNextEventFromBT();
}

for more examples look ate examples/BK8000L/BK8000L.ino

supported functions

begin(uint32_t baudrate); //parameter baudrate is communication speed between MCU and arduino, default 9600

sendData(String cmd); //construct string of AT+cmd and send it to serial port 

sendAPTData(String cmd); //construct string of APT+cmd and send it to serial port 

getNextEventFromBT(); //parse data send from module and send internal variales, call this periodicaly, to parse data received from module ASAP

PairingInit(); //initialize pairing mode

PairingExit(); //exit pairing mode

ConnectLastDevice(); //connect to last device 

Disconnect(); //disconnect from currently connected device

callAnsware(); //answare currently receiving call, see CallerID variable to see who is calling

callReject(); //reject currently receiving call,  see CallerID variable to see who is calling

callHangUp(); //hang up current call, see CallerID variable to see who you are calling with

callRedial(); //call last dialed number, see CallerID variable to see who you dialing

volumeUp(); //set volume up

volumeDown(); //set volume down

languageSwitch(); //did not understand what is this doing based on provided info in datasheet (sending AT+CM)

channelSwitch(); //did not understand what is this doing based on provided info in datasheet (sending AT+CO)

shutdownBT(); //shutdown BT module

switchInput(); //switch to AUX input 

openPhoneVoice(); //did not understand what is this doing based on provided info in datasheet (sending AT+CV)

memoryClear(); //did not understand what is this doing based on provided info in datasheet (sending AT+CZ)

languageSetNumber(uint8_t number); //did not understand what is this doing based on provided info in datasheet (sending AT+CM+number)

musicTogglePlayPause(); //toggle play/pause music on mobile phone

musicStop(); //stop playing music

musicNextTrack(); //switch to next track

musicPreviousTrack(); //switch to previous track

musicFastForward(); //fast forward current track

musicRewind(); //rewind current track

getName(); //get bluetooth module name

getConnectionStatus(); //get BT connection status 

getPinCode(); //get pin

getAddress(); //get HW address of module

getSoftwareVersion(); //get SW version of module (this one did not work for me)

MusicGetStatus(); //get playback status 

getHFPstatus(); //get BT connection status

resetModule(); //reset module, for example to start it again

Handling responce from module

As far as getNextEventFromBT() is called periodicaly, (it is called in all of functions mentioned above, just to handle responce to send command ASAP) library handle responce like this:

library has its own variables, which are set/updated when data are received from module:

String BT_ADDR; // updated after getAddress() is called

String BT_NAME; // updated after getName() is called

String BT_PIN; // updated after getPinCode() is called

String CallerID; // updated automatically or by calling getHFPstatus()

uint8_t BTState; // enum, updated automatically or by calling getHFPstatus() or getConnectionStatus()

uint8_t CallState; // enum, updated automatically or by calling callRedial() or getHFPstatus()

uint8_t MusicState; // enum, updated automatically  or by calling getMusicStatus()

uint8_t PowerState; // enum, updated automaticaly or by calling getHFPstatus(),getMusicStatus() or getConnectionStatus()

If you init BK8000L library as in example code this variables can be accessed directly from main sketch with prefix BT, for example:

Serial.print(BT.BT_NAME);

BTState, CallState, MusicState and PowerState have these states, these are accessible from main sketch with prefix like other variable:

BT.Playing; // responce from module "MA"

BT.Idle; // responce from module "MB"

BT.IncomingCall; // responce from module "IR- or M2"

BT.OutgoingCall; // responce from module "PR- or M3"

BT.CallInProgress; // responce from module "M4"

BT.Connected; // responce from module "M1"

BT.Disconnected; // responce from module "M0"

BT.On; // responce from module "ON"

BT.Off; // set if shutdownBT() is called

BT.Pairing; // set if PairingInit() is called

these can be used to triger actions in main sketch based on change of module state see BK8000L.ino in examples directory.

About

arduino library for bluetooth a2dp module based on BK8000L chip from BEKEN corp.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 100.0%