Skip to content

Commit

Permalink
add debug example
Browse files Browse the repository at this point in the history
  • Loading branch information
konikoni428 committed Jun 9, 2021
1 parent 31fa8ae commit 99ab9df
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions examples/BasicExamplePlusDebug/BasicExamplePlusDebug.ino
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();
}

1 comment on commit 99ab9df

@konikoni428
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#2

Please sign in to comment.