diff --git a/README.md b/README.md index 90c1eb75..67e66df9 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ To start developing for LINE Things using the example code and the sample firmwa ### Installing the Firmware To start development using the example firmwares, you will need a compatible Bluetooth LE enabled development board. -Currently LINE Things Starter firmwares supports the following 6 development boards +Currently LINE Things Starter firmwares supports the following 7 development boards - [LINE Things dev board](https://github.com/line/line-things-dev-board) - [Espressif ESP32-DevKitC](https://www.espressif.com/en/products/hardware/esp32-devkitc/overview) @@ -21,9 +21,10 @@ Currently LINE Things Starter firmwares supports the following 6 development boa - [Adafruit Feather nRF52 Bluefruit LE - nRF52832](https://www.adafruit.com/product/3406) - [Adafruit Feather nRF52840 Express](https://www.adafruit.com/product/4062) - [BBC micro:bit](https://microbit.org/) +- [Linkit 7697](https://labs.mediatek.com/en/chipset/MT7697) - [Obniz](https://obniz.io/) -Each firmware is located under、`line-things-dev-board`, `esp32`, `m5stack`, `nrf52`, `microbit`, `obniz` respectively. +Each firmware is located under、`line-things-dev-board`, `esp32`, `m5stack`, `nrf52`, `microbit`, `mt7697`, `obniz` respectively. For further details, please refer to the `README` file in each directory. ### Enable LINE Things diff --git a/mt7697/README.md b/mt7697/README.md new file mode 100644 index 00000000..423f7129 --- /dev/null +++ b/mt7697/README.md @@ -0,0 +1,18 @@ +# LINE Things Starter for Linkit 7697 + +## Requirements +* [Arduino IDE](https://www.arduino.cc/en/Main/Software) +* [Linkit 7697](https://labs.mediatek.com/en/chipset/MT7697) +* Micro-USB to USB Cable + +## Installation +Please ensure you have Arduino IDE installed and the board **disconnected**. + +[Arduino IDE Setup](https://docs.labs.mediatek.com/resource/linkit7697-arduino/en/environment-setup/setup-arduino-ide) + +## Setup +[Steps](https://docs.labs.mediatek.com/resource/linkit7697-arduino/en/environment-setup/connecting-linkit-7697-to-computer) +## Upload +1. From this repository, open **arduino/sample/sample.ino** +2. Change the `USER_SERVICE_UUID` to your generated UUID +3. Upload and Enjoy! diff --git a/mt7697/arduino/sample/sample.ino b/mt7697/arduino/sample/sample.ino new file mode 100644 index 00000000..e1670220 --- /dev/null +++ b/mt7697/arduino/sample/sample.ino @@ -0,0 +1,67 @@ +#include +#include + +#define BUTTON_PIN (6) + +int nButtonChanged = 0; +int bOn = 0; +LBLEUuid serviceUuid("91E4E176-D0B9-464D-9FE4-52EE3E9F1552"); +LBLEService userService("91E4E176-D0B9-464D-9FE4-52EE3E9F1552"); +LBLECharacteristicInt writeCharacteristic("E9062E71-9E62-4BC6-B0D3-35CDCD9B027B", LBLE_WRITE); +LBLECharacteristicInt notifyCharacteristic("62FBD229-6EDD-4D1A-B554-5C4E1BB29169", LBLE_READ | LBLE_WRITE); + +LBLEService psdiService("E625601E-9E55-4597-A598-76018A0D293D"); +LBLECharacteristicInt psdiCharacteristic("26E2B12B-85F0-4F3F-9FDD-91D114270E6E", LBLE_READ); + +void setup() { + pinMode(LED_BUILTIN, OUTPUT); + digitalWrite(LED_BUILTIN, LOW); + Serial.begin(115200); + while (!Serial) { + ; // wait for serial port to connect. Needed for native USB port only + } + LBLE.begin(); + while (!LBLE.ready()) { + delay(100); + } + LBLEPeripheral.setName("MT7697"); + userService.addAttribute(writeCharacteristic); + userService.addAttribute(notifyCharacteristic); + LBLEPeripheral.addService(userService); + + psdiService.addAttribute(psdiCharacteristic); + LBLEPeripheral.addService(psdiService); + + LBLEPeripheral.begin(); + LBLEAdvertisementData advertisement; + advertisement.configAsConnectableDevice("MT7697",serviceUuid); + LBLEPeripheral.advertise(advertisement); + attachInterrupt(BUTTON_PIN, button_press, CHANGE); + Serial.println("Ready to Connect"); +} + +void loop() { + // put your main code here, to run repeatedly: + delay(20); + if (writeCharacteristic.isWritten()) { + bOn = writeCharacteristic.getValue(); + if (bOn > 0) { + digitalWrite(LED_BUILTIN, HIGH); + Serial.println("LED ON"); + } else { + digitalWrite(LED_BUILTIN, LOW); + Serial.println("LED OFF"); + } + } + if (nButtonChanged == 1) { + nButtonChanged = 0; + int btnValue = digitalRead(BUTTON_PIN); + notifyCharacteristic.setValue(btnValue); + LBLEPeripheral.notifyAll(notifyCharacteristic); + delay(50); + } +} +void button_press(void) { + Serial.println("====Button Changed"); + nButtonChanged = 1; +}