Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
konikoni428 committed Jun 18, 2020
1 parent 618f88b commit 212877d
Show file tree
Hide file tree
Showing 13 changed files with 675 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# BM64/BM62 Library for Arduino
Communicate BM64/BM62 device and your arduino board with UART.
For more detail of BM64, please see this link.
https://www.microchip.com/wwwproducts/en/BM64

Event code and parameter information, Please download Command Set document.
http://ww1.microchip.com/downloads/en/DeviceDoc/AudioUARTCommandSet_v2%2002.docx


# Licence
Copyright (c) 2020 Masahiro Konishi

This software is released under the MIT License, see LICENSE.txt.

Binary file added examples/.DS_Store
Binary file not shown.
78 changes: 78 additions & 0 deletions examples/AllFunctionExample/AllFunctionExample.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#include "BM64.h"
#include <SoftwareSerial.h>

#define RX_PIN 5
#define TX_PIN 6
#define TX_IND 7

SoftwareSerial swSerial(RX_PIN, TX_PIN);
BM64 bm64(swSerial, TX_IND);

void onEventCallback(BM64_event_t *event){
// handle Event
Serial.print("[EVENT]: ");
Serial.println(event->event_code, HEX);

for(int i=0; i<event->param_len; i++){
Serial.print(event->parameter[i], HEX);
Serial.print(" ");
}
Serial.println("");
}


void setup() {
Serial.begin(115200);
swSerial.begin(9600);
bm64.setCallback(onEventCallback);
}

void loop() {
//Check UART Event
bm64.run();
if (Serial.available() > 0)
{
// read the incoming byte:
char c = Serial.read();
switch (c)
{
case 'a':
bm64.getStatus();
break;
case 'b':
// Other Action, Please see BM64_Debug.h
bm64.musicControl(MUSIC_CONTROL_PLAY);
break;
case 'c':
// Other Action, Please see BM64_Debug.h
bm64.musicControl(MUSIC_CONTROL_NEXT);
break;
case 'd':
bm64.generateTone(0x07);
break;
case 'e':
// Other Action, Please see BM64_Debug.h
bm64.mmiAction(BM64_MMI_ACCEPT_CALL);
break;
case 'f':
// Other Action, Please see BM64_Debug.h
bm64.mmiAction(BM64_MMI_MUTE_MIC);
break;
case 'g':
bm64.powerOff();
break;
case 'h':
bm64.powerOn();
break;
case 'i':
String number_s = "1234567890";
bm64.makeCall(&number_s);
break;
case 'j':
char number_c[10] = {'1', '2', '3', '4', '5', '6', '7', '8', '9', '0'};
int len = 10;
bm64.makeCall(number_c, len);
break;
}
}
}
Binary file added examples/BasicExample/.DS_Store
Binary file not shown.
36 changes: 36 additions & 0 deletions examples/BasicExample/BasicExample.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include "BM64.h"

#define TX_IND 7
BM64 bm64(Serial, TX_IND);

void onEventCallback(BM64_event_t *event){
// handle event
switch(event->event_code)
{
case BM64_EVENT_CALL_STATUS:
if(event->parameter[1] == INCOMING_CALL){
// Incoming Call
}else if(event->parameter[1] == IDLE){
// End call event
}
break;
case BM64_EVENT_DEVICE_STATE:
if(event->parameter[0] == 0x00){
// Power Off Event
}else if(event->parameter[0] == 0x02){
// Power On Event
}
break;
}
}


void setup() {
Serial.begin(19200);
bm64.setCallback(onEventCallback);
}

void loop() {
//Check UART Event
bm64.run();
}
41 changes: 41 additions & 0 deletions examples/SoftwareSerialExample/SoftwareSerialExample.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include "BM64.h"
#include <SoftwareSerial.h>

#define RX_PIN 5
#define TX_PIN 6
#define TX_IND 7

SoftwareSerial swSerial(RX_PIN, TX_PIN);
BM64 bm64(swSerial, TX_IND);

void onEventCallback(BM64_event_t *event){
// handle event
switch(event->event_code)
{
case BM64_EVENT_CALL_STATUS:
if(event->parameter[1] == INCOMING_CALL){
// Incoming Call
}else if(event->parameter[1] == IDLE){
// End call event
}
break;
case BM64_EVENT_DEVICE_STATE:
if(event->parameter[0] == 0x00){
// Power Off Event
}else if(event->parameter[0] == 0x02){
// Power On Event
}
break;
}
}


void setup() {
swSerial.begin(9600);
bm64.setCallback(onEventCallback);
}

void loop() {
//Check UART Event
bm64.run();
}
28 changes: 28 additions & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#######################################
# BM64 Arduino Library Syntax Coloring
#######################################

#######################################
# Datatypes (KEYWORD1)
#######################################

BM64 KEYWORD1
BM64_event_t KEYWORD1

#######################################
# Methods and Functions (KEYWORD2)
#######################################
getStatus KEYWORD2
musicControl KEYWORD2
generateTone KEYWORD2
mmiAction KEYWORD2
powerOn KEYWORD2
powerOff KEYWORD2
makeCall KEYWORD2
getCallStatus KEYWORD2
run KEYWORD2
setCallback KEYWORD2

#######################################
# Constants (LITERAL1)
#######################################
9 changes: 9 additions & 0 deletions library.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name=BM64
version=1.0.0
author=Masahiro Konishi <[email protected]>
maintainer=Tomas Kovacik <[email protected]>
sentence=A library to control BM64 bluetooth audio module.
paragraph=
category=Communication
url=https://github.com/konikoni428/BM64_arduino
architectures=*
Loading

0 comments on commit 212877d

Please sign in to comment.