JDY08/HC05 - Updated Serial interface
This commit is contained in:
parent
b474daacdd
commit
d29be7a252
8 changed files with 21 additions and 14 deletions
|
@ -21,9 +21,14 @@ void setup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
// read data incoming from Serial port and write them to bluetooth
|
|
||||||
// HC05 supports all methods of the Serial class
|
// HC05 supports all methods of the Serial class
|
||||||
|
// read data incoming from Serial port and write them to Bluetooth
|
||||||
while(Serial.available() > 0) {
|
while(Serial.available() > 0) {
|
||||||
bluetooth.write(Serial.read());
|
bluetooth.write(Serial.read());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// read data incoming from Bluetooth and write them to Serial port
|
||||||
|
while(bluetooth.available() > 0) {
|
||||||
|
Serial.write(bluetooth.read());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,12 +19,14 @@ void setup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
// read data incoming from Serial port and write them to bluetooth
|
|
||||||
// JDY08 supports all methods of the Serial class
|
// JDY08 supports all methods of the Serial class
|
||||||
|
// read data incoming from Serial port and write them to Bluetooth
|
||||||
while(Serial.available() > 0) {
|
while(Serial.available() > 0) {
|
||||||
ble.write(Serial.read());
|
bluetooth.write(Serial.read());
|
||||||
}
|
}
|
||||||
while(ble.available() > 0) {
|
|
||||||
Serial.write(ble.read());
|
// read data incoming from Bluetooth and write them to Serial port
|
||||||
|
while(bluetooth.available() > 0) {
|
||||||
|
Serial.write(bluetooth.read());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "ISerial.h"
|
#include "ISerial.h"
|
||||||
|
|
||||||
ISerial::ISerial() {
|
ISerial::ISerial(Module* mod) {
|
||||||
|
_mod = mod;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ISerial::begin(long speed) {
|
void ISerial::begin(long speed) {
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
class ISerial {
|
class ISerial {
|
||||||
public:
|
public:
|
||||||
ISerial();
|
ISerial(Module* mod);
|
||||||
|
|
||||||
void begin(long);
|
void begin(long);
|
||||||
bool listen();
|
bool listen();
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "HC05.h"
|
#include "HC05.h"
|
||||||
|
|
||||||
HC05::HC05(Module* module) {
|
HC05::HC05(Module* mod) : ISerial(mod) {
|
||||||
_mod = module;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HC05::begin(long speed) {
|
void HC05::begin(long speed) {
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
class HC05: public ISerial {
|
class HC05: public ISerial {
|
||||||
public:
|
public:
|
||||||
// constructor
|
// constructor
|
||||||
HC05(Module* module);
|
HC05(Module* mod);
|
||||||
|
|
||||||
// basic methods
|
// basic methods
|
||||||
void begin(long speed);
|
void begin(long speed);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "JDY08.h"
|
#include "JDY08.h"
|
||||||
|
|
||||||
JDY08::JDY08(Module* module) {
|
JDY08::JDY08(Module* mod) : ISerial(mod) {
|
||||||
_mod = module;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void JDY08::begin(long speed) {
|
void JDY08::begin(long speed) {
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
class JDY08: public ISerial {
|
class JDY08: public ISerial {
|
||||||
public:
|
public:
|
||||||
// constructor
|
// constructor
|
||||||
JDY08(Module* module);
|
JDY08(Module* mod);
|
||||||
|
|
||||||
// basic methods
|
// basic methods
|
||||||
void begin(long speed);
|
void begin(long speed);
|
||||||
|
|
Loading…
Add table
Reference in a new issue