mirror of
https://github.com/OpenEPaperLink/OpenEPaperLink.git
synced 2026-03-21 02:04:36 +01:00
Added ATC_MiThermometer to the BLE part. This allows to receive the Advertising data from the Custom firmware running on the Thermometer via BLE
This commit is contained in:
16
ESP32_AP-Flasher/data/tagtypes/BE.json
Normal file
16
ESP32_AP-Flasher/data/tagtypes/BE.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "ATC MiThermometer BLE",
|
||||
"width": 6,
|
||||
"height": 8,
|
||||
"rotatebuffer": 1,
|
||||
"bpp": 1,
|
||||
"colors": 1,
|
||||
"colortable": {
|
||||
"white": [255, 255, 255],
|
||||
"black": [0, 0, 0]
|
||||
},
|
||||
"shortlut": 0,
|
||||
"options": [],
|
||||
"contentids": [ 22 ],
|
||||
"usetemplate": 0
|
||||
}
|
||||
@@ -57,19 +57,28 @@ uint8_t gicToOEPLtype(uint8_t gicType) {
|
||||
}
|
||||
|
||||
bool BLE_filter_add_device(BLEAdvertisedDevice advertisedDevice) {
|
||||
Serial.print("BLE Advertised Device found: ");
|
||||
Serial.println(advertisedDevice.toString().c_str());
|
||||
|
||||
uint8_t payloadData[100];
|
||||
int payloadDatalen = advertisedDevice.getPayloadLength();
|
||||
memcpy(&payloadData, (uint8_t*)advertisedDevice.getPayload(), payloadDatalen);
|
||||
Serial.printf(" Payload data: ");
|
||||
for (int i = 0; i < payloadDatalen; i++)
|
||||
Serial.printf("%02X", payloadData[i]);
|
||||
Serial.printf("\r\n");
|
||||
|
||||
if (advertisedDevice.haveManufacturerData()) {
|
||||
int manuDatalen = advertisedDevice.getManufacturerData().length();
|
||||
uint8_t manuData[100];
|
||||
if (manuDatalen > sizeof(manuData))
|
||||
return false; // Manu data too big, could never happen but better make sure here
|
||||
Serial.printf(" Address type: %02X Manu data: ", advertisedDevice.getAddressType());
|
||||
for (int i = 0; i < advertisedDevice.getManufacturerData().length(); i++)
|
||||
Serial.printf("%02X", manuData[i]);
|
||||
Serial.printf("\r\n");
|
||||
memcpy(&manuData, (uint8_t*)advertisedDevice.getManufacturerData().data(), manuDatalen);
|
||||
if (manuDatalen == 7 && manuData[0] == 0x53 && manuData[1] == 0x50) {
|
||||
Serial.print("BLE Advertised Device found: ");
|
||||
Serial.println(advertisedDevice.toString().c_str());
|
||||
Serial.printf(" Address type: %02X Manu data: ", advertisedDevice.getAddressType());
|
||||
for (int i = 0; i < advertisedDevice.getManufacturerData().length(); i++)
|
||||
Serial.printf("%02X", manuData[i]);
|
||||
Serial.printf("\r\n");
|
||||
if (manuDatalen == 7 && manuData[0] == 0x53 && manuData[1] == 0x50) { // Lets check for a Gicisky E-Paper display
|
||||
|
||||
struct espAvailDataReq theAdvData;
|
||||
memset((uint8_t*)&theAdvData, 0x00, sizeof(espAvailDataReq));
|
||||
@@ -94,7 +103,34 @@ bool BLE_filter_add_device(BLEAdvertisedDevice advertisedDevice) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (payloadDatalen >= 17) { // Lets check for an ATC Mi Thermometer
|
||||
uint8_t macReversed[6];
|
||||
memcpy(&macReversed, (uint8_t*)advertisedDevice.getAddress().getNative(), 6);
|
||||
if (payloadData[9] == macReversed[5] && payloadData[8] == macReversed[4] && payloadData[7] == macReversed[3]) { // Here we found an ATC Mi Thermometer
|
||||
struct espAvailDataReq theAdvData;
|
||||
memset((uint8_t*)&theAdvData, 0x00, sizeof(espAvailDataReq));
|
||||
|
||||
theAdvData.src[0] = macReversed[5];
|
||||
theAdvData.src[1] = macReversed[4];
|
||||
theAdvData.src[2] = macReversed[3];
|
||||
theAdvData.src[3] = macReversed[2];
|
||||
theAdvData.src[4] = macReversed[1];
|
||||
theAdvData.src[5] = macReversed[0];
|
||||
theAdvData.src[6] = 0x00; // We use this do find out what type of display we got for compression^^
|
||||
theAdvData.src[7] = 0x00;
|
||||
theAdvData.adr.batteryMv = payloadData[14] << 8 | payloadData[15];
|
||||
theAdvData.adr.temperature = (payloadData[10] << 8 | payloadData[11]) / 10;
|
||||
theAdvData.adr.lastPacketLQI = payloadData[12];
|
||||
theAdvData.adr.lastPacketRSSI = advertisedDevice.getRSSI();
|
||||
theAdvData.adr.hwType = ATC_MI_THERMOMETER;
|
||||
theAdvData.adr.tagSoftwareVersion = 0x00;
|
||||
theAdvData.adr.capabilities = 0x00;
|
||||
|
||||
processDataReq(&theAdvData, true);
|
||||
Serial.printf("We got an ATC_MiThermometer via BLE\r\n");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -155,7 +155,7 @@ void BLETask(void* parameter) {
|
||||
if (millis() - last_ble_scan > (INTERVAL_BLE_SCANNING_SECONDS * 1000)) {
|
||||
last_ble_scan = millis();
|
||||
Serial.println("Doing the BLE Scan");
|
||||
BLE_startScan(5); // timeout in seconds, this is blocking but only for this thread!
|
||||
BLE_startScan(10); // timeout in seconds, this is blocking but only for this thread!
|
||||
}
|
||||
if (millis() - BLE_last_pending_check >= (INTERVAL_HANDLE_PENDING_SECONDS * 1000)) {
|
||||
if (BLE_is_image_pending(BLE_curr_address)) {
|
||||
|
||||
@@ -70,6 +70,7 @@
|
||||
#define GICI_BLE_EPD_BW_74 0xB8
|
||||
#define GICI_BLE_EPD_BWR_74 0xB9
|
||||
#define GICI_BLE_UNKNOWN 0xBF
|
||||
#define ATC_MI_THERMOMETER 0xBE
|
||||
|
||||
// Solum types - customer data byte 16 in M3 (nRF) UICR
|
||||
#define STYPE_SIZE_016 0x40
|
||||
|
||||
Reference in New Issue
Block a user