-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
618f88b
commit 212877d
Showing
13 changed files
with
675 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
####################################### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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=* |
Oops, something went wrong.