This commit is contained in:
James 2024-04-25 22:01:17 +01:00
parent 9cffaa9025
commit 939df496f8

View File

@ -18,6 +18,9 @@ void setup() {
Serial.println("Scanning..."); Serial.println("Scanning...");
} }
bool gotBasicInfo;
bool gotCellInfo;
void loop() { void loop() {
BLEScan* pBLEScan = BLEDevice::getScan(); // Create new scan BLEScan* pBLEScan = BLEDevice::getScan(); // Create new scan
pBLEScan->setActiveScan(true); // Active scan uses more power, but get results faster pBLEScan->setActiveScan(true); // Active scan uses more power, but get results faster
@ -96,22 +99,30 @@ void loop() {
} }
Serial.println(" - TX is writable"); Serial.println(" - TX is writable");
while(1){ bool gotBasicInfo=false;
bool gotCellInfo=false;
while(gotBasicInfo==false || gotCellInfo==false){
// REQUEST BASIC INFO // REQUEST BASIC INFO
// header status command length data checksum footer // header status command length data checksum footer
// DD A5 03 00 FF FD 77 // DD A5 03 00 FF FD 77
if(gotBasicInfo==false){
delay(500); delay(500);
uint8_t a_data[7] = {0xdd, 0xa5, 3, 0x0, 0xff, 0xfd, 0x77}; uint8_t a_data[7] = {0xdd, 0xa5, 3, 0x0, 0xff, 0xfd, 0x77};
pRemoteCharacteristic_tx->writeValue(a_data, sizeof(a_data), false); pRemoteCharacteristic_tx->writeValue(a_data, sizeof(a_data), false);
}
// REQUEST CELL INFO // REQUEST CELL INFO
// header status command length data checksum footer // header status command length data checksum footer
// DD A5 03 00 FF FD 77 // DD A5 03 00 FF FD 77
if(gotCellInfo==false){
delay(500); delay(500);
uint8_t b_data[7] = {0xdd, 0xa5, 4, 0x0, 0xff, 0xfc, 0x77}; uint8_t b_data[7] = {0xdd, 0xa5, 4, 0x0, 0xff, 0xfc, 0x77};
pRemoteCharacteristic_tx->writeValue(b_data, sizeof(b_data), false); pRemoteCharacteristic_tx->writeValue(b_data, sizeof(b_data), false);
} }
} }
Serial.printf("\r\n\r\n===============================\r\n\r\n");
}
} }
static void MyNotifyCallback(BLERemoteCharacteristic *pBLERemoteCharacteristic, uint8_t *pData, size_t length, bool isNotify){ static void MyNotifyCallback(BLERemoteCharacteristic *pBLERemoteCharacteristic, uint8_t *pData, size_t length, bool isNotify){