diff --git a/examples/JDY08/JDY08.ino b/examples/JDY08/JDY08.ino new file mode 100644 index 00000000..abe642b8 --- /dev/null +++ b/examples/JDY08/JDY08.ino @@ -0,0 +1,30 @@ +/* + * KiteLib JDY08 Example + * + * This example sends data using JDY08 Bluetooth module. + */ + +// include the library +#include + +// JDY08 module is in slot A on the shield +JDY08 ble = Kite.ModuleA; + +void setup() { + Serial.begin(9600); + + // initialize JDY08 + // baudrate: 9600 baud + ble.begin(9600); +} + +void loop() { + // read data incoming from Serial port and write them to bluetooth + // JDY08 supports all methods of the Serial class + while(Serial.available() > 0) { + ble.write(Serial.read()); + } + while(ble.available() > 0) { + Serial.write(ble.read()); + } +} diff --git a/src/KiteLib.h b/src/KiteLib.h index 6e94809c..03401aba 100644 --- a/src/KiteLib.h +++ b/src/KiteLib.h @@ -6,6 +6,7 @@ #include "modules/ESP8266.h" #include "modules/HC05.h" +#include "modules/JDY08.h" #include "modules/RF69.h" #include "modules/SX1231.h" #include "modules/SX1272.h" diff --git a/src/modules/JDY08.cpp b/src/modules/JDY08.cpp new file mode 100644 index 00000000..80f8c6d2 --- /dev/null +++ b/src/modules/JDY08.cpp @@ -0,0 +1,12 @@ +#include "JDY08.h" + +JDY08::JDY08(Module* module) { + _mod = module; +} + +void JDY08::begin(long speed) { + // set module properties + _mod->AtLineFeed = ""; + _mod->baudrate = speed; + _mod->init(USE_UART, INT_NONE); +} diff --git a/src/modules/JDY08.h b/src/modules/JDY08.h new file mode 100644 index 00000000..db72e191 --- /dev/null +++ b/src/modules/JDY08.h @@ -0,0 +1,15 @@ +#ifndef _KITELIB_JDY08_H +#define _KITELIB_JDY08_H + +#include "ISerial.h" + +class JDY08: public ISerial { + public: + // constructor + JDY08(Module* module); + + // basic methods + void begin(long speed); +}; + +#endif