-
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
31fa8ae
commit 99ab9df
Showing
1 changed file
with
47 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,47 @@ | ||
#include "BM64.h" | ||
#include <SoftwareSerial.h> | ||
|
||
#define TX_IND 7 | ||
BM64 bm64(Serial, TX_IND); | ||
|
||
// For BM64 Debug. | ||
// Please define BM64_DEBUG in BM64_Debug.h | ||
|
||
#define DEBUG_RX 10 | ||
#define DEBUG_TX 11 | ||
// variable name can't change. | ||
SoftwareSerial _swSerial(DEBUG_RX, DEBUG_TX); | ||
|
||
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); | ||
// Start serial communication. | ||
_swSerial.begin(19200); | ||
bm64.setCallback(onEventCallback); | ||
} | ||
|
||
void loop() { | ||
//Check UART Event | ||
bm64.run(); | ||
} |
99ab9df
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#2