BW16 BLE CLIENT與ESP32 BLE Server

請問bw16的battery ble client程式修改之後,能夠和esp32的ble server溝通嗎? 我發現bw16和esp32 ble的client程是寫法有許多不同之處? 有辦法讓兩者互連嗎?

@tom.chen2017

应该是可以的,只要它们的数据格式一样,两边都用的是 BLE,就应该能够沟通。

这个正常,就像 esp32,adafruit,arduino 的 BLE API 都有点不一样

1.請問BW16的BLE2902.h部分由哪個檔案替代呢?
2.另外
在esp32 ble連續丟8 bytes參數的寫法
static uint8_t custom[8] = {0xff, 0x40, 0x41, 0x42, 0x00, 0x00, (byte) 0xA3, (byte) 0x3D};
pRemoteCharacteristic->writeValue(custom, sizeof(custom));

在bw16可以怎麼改寫呢? 下面bw16的寫法成立嗎?
static uint8_t custom[8] = {0xff, 0x40, 0x41, 0x42, 0x00, 0x00, (byte) 0xA3, (byte) 0x3D};
battChar1.setData(&custom[8],8);

@tom.chen2017

  • 2902 的功能 BLECharacteristic 本身就有,通过以下 function 开启和使用 notify 和 indicate 功能
void setNotifyProperty(bool value);
void setIndicateProperty(bool value);
void notify(uint8_t conn_id);
void indicate(uint8_t conn_id);
static uint8_t custom[8] = {0xff, 0x40, 0x41, 0x42, 0x00, 0x00, 0xA3, 0x3D};
battChar1.setData(custom, 8);

或者

static uint8_t custom[8] = {0xff, 0x40, 0x41, 0x42, 0x00, 0x00, 0xA3, 0x3D};
battChar1.setData(custom, sizeof(custom));

battChar1.setData(custom, 8);
或者
battChar1.setData(custom, sizeof(custom));
Compiler後會告知
invalid conversion from ‘uint8_t {aka unsigned char}’ to ‘uint8_t* {aka unsigned char*}’ [-fpermissive]

請問可以提供類似esp32 BLEClient & BLEService的範例嗎? (不是BLEBatteryClient,BLEBatteryService)