/* This example configures LinkIt 7697 to act as a simple GATT server with 1 characteristic.
To use it, open AppInventor project:
*
Build & install it on Android id
created Mar 2017 */ #include <LBLE.h> #include <LBLEPeriphral.h>
// Define a simple GATT service with only 1 characteristic LBLEService ledService("19B10010-E8F2-537E-4F6C-D104768A1214"); LBLECharacteristicInt switchCharacteristic("19B10011-E8F2-537E-4F6C-D104768A1214", LBLE_READ | LBLE_WRITE);
void setup() {
// Initialize LED pin pinMode(LED_BUILTIN, OUTPUT); digitalWrite(LED_BUILTIN, LOW);
//Initialize serial and wait for port to open: Serial.begin(9600);
// to check if USR button is pressed pinMode(6, INPUT);
// Initialize BLE subsystem LBLE.begin(); while (!LBLE.ready()) { delay(100); } Serial.println("BLE ready");
// configure our advertisement data. // In this case, we simply create an advertisement that represents an // connectable device with a device name LBLEAdvertisementData advertisement; advertisement.configAsConnectableDevice("BLE LED");
// Configure our device's Generic Access Profile's device name // Ususally this is the same as the name in the advertisement data. LBLEPeripheral.setName("BLE LED");
// Add characteristics into ledService ledService.addAttribute(switchCharacteristic);
// Add service to GATT server (peripheral) LBLEPeripheral.addService(ledService);
// start the GATT server - it is now // available to connect LBLEPeripheral.begin();
課程,太棒了,如果有一系列資料,就太感謝了
有的,陸續上線中,您可以用 http://blog.cavedu.com/?s=7697 或頁面右上角搜尋 7697 即可看到 7697 最新文章喔
請問如果以APP INVENTOR本身有的藍芽客戶端來連結7697可以這樣寫嗎?
#include
#include
void setup() {
Serial.begin(9600);
pinMode(13,OUTPUT);
pinMode(14,OUTPUT);
}
void loop() {
if(Serial.available()>0)
{
char data = Serial.read();
if (data == ‘a’)
{
digitalWrite(13,HIGH);
delay(1000);
digitalWrite(13,LOW);
}
else if(data == ‘b’)
{
digitalWrite(14,HIGH);
delay(1000);
digitalWrite(14,LOW);
}
}
}
您好,不行啊… 因為7697不支援傳統藍牙,所以一定要用 BluetoothLE 元件喔
請教一下這幾個參數意義?
serviceUuid / characteristicUuid
signed 是指要加密嗎?
serviceUuid / characteristicUuid 是 BLE 兩邊所要設定的 ID,請參考 https://zh.wikipedia.org/zh-tw/%E8%93%9D%E7%89%99%E4%BD%8E%E5%8A%9F%E8%80%97
另外 signed 是指”有號數” 有一個位元會用來表示正負數。