Closed Alexispap closed 11 months ago
Did you try changing the case to lower case for char UUID and service UUID ?
Yes, both are not working. I tried with another package. It is also not working. So i suspect that there is a general issue with ios here. Do i need some special permissions or do i have to configure the characteristic on the peripheral in some special way?
Is this an issue that comes from passing a normal string to the API, whilst the native module wants a NSString?
Hi, have you call retrieveServices? Is the characteriti/service listed?
Yes, i called this function. The service is listed and some characteristics, but not the one that i need. Are there special restrictions on the UUID or do i have to enable something in Xcode for it to work?
You can use app like light blue to connect and check all the services present. If light blue does not show it, it means device does not have it.
On Fri, Mar 5, 2021 at 7:44 AM Alexis notifications@github.com wrote:
Yes, i called this function. The service is listed and some characteristics, but not the one that i need. Are there special restrictions on the UUID or do i have to enable something in Xcode for it to work?
β You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/innoveit/react-native-ble-manager/issues/716#issuecomment-791500895, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACS2CO3LHWB3TZKPA4AJOJTTCD34TANCNFSM4YPK6Y2Q .
It exists, since on Android it works totally fine.
If you donβt mind sharing the screen capture for LightBlue showing services and characteristics and console log for retrieve services for comparison, I can check and see if any find any clue.
On Fri, Mar 5, 2021 at 8:07 AM Alexis notifications@github.com wrote:
It exists, since on Android it works totally fine.
β You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/innoveit/react-native-ble-manager/issues/716#issuecomment-791516019, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACS2CO2PQBV3FBGJY2PJNNDTCD6TFANCNFSM4YPK6Y2Q .
In the release build the app even crashes. @djain1992 @marcosinigaglia Do you have any idea? I have to fix it very soon π Thanks for your time!!
Yes, i call retrieveServices shortly after connecting with a setTimeout.
IOS code has logs. Did you try running it from Xcode and look at the debug logs. I see several debug statements:
(void)peripheral:(CBPeripheral )peripheral didDiscoverServices:(NSError )error { if (error) { NSLog(@"Error: %@", error); return; } NSLog(@"Services Discover");
NSMutableSet servicesForPeriperal = [NSMutableSet new]; [servicesForPeriperal addObjectsFromArray:peripheral.services]; [retrieveServicesLatches setObject:servicesForPeriperal forKey:[peripheral uuidAsString]]; for (CBService service in peripheral.services) { NSLog(@"Service %@ %@", service.UUID, service.description); [peripheral discoverCharacteristics:nil forService:service]; // discover all is slow } }
In XCode it only says: "Terminated due to signal 9". I will now rebuild and try again, let's see.
Try add a delay also after the retrieveServices and the startNotification.
It is still giving me the same messages :/
Your ble device is custom? Maybe the problem is there.
Yes, it is custom. Do we need to use specific UUIDs or something like that so that Apple devices can observe it? It is very strange, because in any case it should not crash... Thanks for your help so far, that is very kind!
Did you respond to this query? On IOS if you have lightblue and lightblue shows the characteristics, then we can rule out the issue with the device.
I will try that as soon as i have an Iphone where i can install lightblue (at the moment i borrowed one and cannot install things - my own will come in the next days)
But i found this log in Xcode:
2021-03-10 00:09:18.115477+0100 frexitcc2[1031:2093847] BleManager initialized 2021-03-10 00:09:18.116456+0100 frexitcc2[1031:2093847] [CoreBluetooth] API MISUSE: <CBCentralManager: 0x10b5c04d0> has no restore identifier but the delegate implements the centralManager:willRestoreState: method. Restoring will not be supported 2021-03-10 00:09:18.123341+0100 frexitcc2[1031:2094367] [CoreBluetooth] XPC connection invalid
What does that mean?
This is ok. You can ignore this warning.
On Tue, Mar 9, 2021 at 3:30 PM Alexis notifications@github.com wrote:
I will try that as soon as i have an Iphone where i can install lightblue (at the moment i borrowed one and cannot install things - my own will come in the next days)
But i found this log in Xcode:
2021-03-10 00:09:18.115477+0100 frexitcc2[1031:2093847] BleManager initialized 2021-03-10 00:09:18.116456+0100 frexitcc2[1031:2093847] [CoreBluetooth] API MISUSE: <CBCentralManager: 0x10b5c04d0> has no restore identifier but the delegate implements the centralManager:willRestoreState: method. Restoring will not be supported 2021-03-10 00:09:18.123341+0100 frexitcc2[1031:2094367] [CoreBluetooth] XPC connection invalid
What does that mean?
β You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/innoveit/react-native-ble-manager/issues/716#issuecomment-794602224, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACS2COYDCNI3JCEYAQRQU6DTC2VQ3ANCNFSM4YPK6Y2Q .
Does this mean, that the characteristic is somehow not correct in repect to iOS principles?
Yes. Not an issue with BLE manager package. Which BLE chip do you use? How do you define your characteristics?
On Thu, Mar 11, 2021 at 5:12 AM Alexis @.***> wrote:
Does this mean, that the characteristic is somehow not correct in repect to iOS principles?
β You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/innoveit/react-native-ble-manager/issues/716#issuecomment-796725424, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACS2CO5AWEJHXX6PVS5RCVLTDC6SDANCNFSM4YPK6Y2Q .
We use an Seeeduino Wio Lite MG126 microcontroller and Arduino ide for implementing. Since i did not write the code, i have to understand it and find the correct lines before i can answer your question regarding the definition of the characteristics. Here is a part of the code, does that already help answer it?
// // STEP 0: Character declare // const BLE_CHAR AttCharList[] = { // ===== GATT ===== {TYPE_CHAR, 0x0003, {ATT_CHAR_PROP_RD, 0x04, 0, 0x00, 0x2a}, UUID16_FORMAT}, //name //05-06 reserved
// ===== Device Information Service Characteristics ===== {TYPE_CHAR, 0x0008, {ATT_CHAR_PROP_RD, 0x09, 0, 0x29, 0x2a}, UUID16_FORMAT}, //manufacture {TYPE_CHAR, 0x000a, {ATT_CHAR_PROP_RD, 0x0b, 0, 0x26, 0x2a}, UUID16_FORMAT}, //firmware version {TYPE_CHAR, 0x000e, {ATT_CHAR_PROP_RD, 0x0f, 0, 0x28, 0x2a}, UUID16_FORMAT}, //sw version
// ===== Item Service Characteristics ===== {TYPE_CHAR, 0x20, {ATT_CHAR_PROP_RD | ATT_CHAR_PROP_W | ATT_CHAR_PROP_W_NORSP | ATT_CHAR_PROP_NTF, 0x21, 0, 0}, 1}, // Characteristic {TYPE_INFO, 0x22}, // Characteristic User Description {TYPE_CFG, 0x23, {ATT_CHAR_PROP_RD|ATT_CHAR_PROP_W}}, // Client Characteristic Configuration {TYPE_PRESENTATION_FORMAT, 0x24}, // Characteristic Pre-sentation Format };
// List of 128-bit UUIDs const BLE_UUID128 AttUuid128List[] = { {0x8f, 0x2e, 0x78, 0x51, 0xba, 0xfb, 0x95, 0xb9, 0xca, 0x41, 0x28, 0x3f, 0x00, 0x00, 0xe2, 0xcc}, {0x8f, 0x2e, 0x78, 0x51, 0xba, 0xfb, 0x95, 0xb9, 0xca, 0x41, 0x28, 0x3f, 0x01, 0x00, 0xe2, 0xcc}, };
Only thing I can think of is the connection handle are not continuous. Can you try starting the connection handle from 0x10 instead of 0x20.
If this does not work try starting from 0x0f.
On Thu, Mar 11, 2021 at 9:13 AM Alexis @.***> wrote:
We use an Seeeduino Wio Lite MG126 microcontroller and Arduino ide for implementing. Since i did not write the code, i have to understand it and find the correct lines before i can answer your question regarding the definition of the characteristics. Here is a part of the code, does that already help answer it?
// // STEP 0: Character declare // const BLE_CHAR AttCharList[] = { // ===== GATT ===== {TYPE_CHAR, 0x0003, {ATT_CHAR_PROP_RD, 0x04, 0, 0x00, 0x2a}, UUID16_FORMAT}, //name //05-06 reserved
// ===== Device Information Service Characteristics ===== {TYPE_CHAR, 0x0008, {ATT_CHAR_PROP_RD, 0x09, 0, 0x29, 0x2a}, UUID16_FORMAT}, //manufacture {TYPE_CHAR, 0x000a, {ATT_CHAR_PROP_RD, 0x0b, 0, 0x26, 0x2a}, UUID16_FORMAT}, //firmware version {TYPE_CHAR, 0x000e, {ATT_CHAR_PROP_RD, 0x0f, 0, 0x28, 0x2a}, UUID16_FORMAT}, //sw version
// ===== Item Service Characteristics ===== {TYPE_CHAR, 0x20, {ATT_CHAR_PROP_RD | ATT_CHAR_PROP_W | ATT_CHAR_PROP_W_NORSP | ATT_CHAR_PROP_NTF, 0x21, 0, 0}, 1}, // Characteristic {TYPE_INFO, 0x22}, // Characteristic User Description {TYPE_CFG, 0x23, {ATT_CHAR_PROP_RD|ATT_CHAR_PROP_W}}, // Client Characteristic Configuration {TYPE_PRESENTATION_FORMAT, 0x24}, // Characteristic Pre-sentation Format };
// List of 128-bit UUIDs const BLE_UUID128 AttUuid128List[] = { {0x8f, 0x2e, 0x78, 0x51, 0xba, 0xfb, 0x95, 0xb9, 0xca, 0x41, 0x28, 0x3f, 0x00, 0x00, 0xe2, 0xcc}, {0x8f, 0x2e, 0x78, 0x51, 0xba, 0xfb, 0x95, 0xb9, 0xca, 0x41, 0x28, 0x3f, 0x01, 0x00, 0xe2, 0xcc}, };
β You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/innoveit/react-native-ble-manager/issues/716#issuecomment-796898166, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACS2COZIALQCZWAKMK2IZE3TDD23HANCNFSM4YPK6Y2Q .
Thank you, i will try it :)
I cannot fix this :/ Do you have any other idea?
The full file is now:
/// Characteristic Properties Bit
// ===== Device Information Service =====
// ======================================
// ===== GAP ===== char DeviceInfo[9] = "Spionglas"; /max len is 24 bytes/ // ===============
// ===== Item Service ===== char itemCharacteristicUserDescription[18] = "Show item solution"; byte cccd[2] = { 0, 0 }; // Format:1, Exponent:1, Unit:2, NameSpace:1, Description:2 byte itemCharacteristicPresentationFormat[7] = {0x01, 0x00, 0x00, 0x27};
uint16_t cur_notifyhandle = 0x21;
uint8_t getDeviceInfoData(uint8_t len) { len = sizeof(DeviceInfo); return (uint8_t)DeviceInfo; }
void updateDeviceInfoData(uint8_t* name, uint8_t len) { memcpy(DeviceInfo, name, len); ble_set_name(name, len); }
/** *DataBase
01 - 06 GAP (Primary service) 0x1800 03:04 name 07 - 0f Device Info (Primary service) 0x180a 0a:0b firmware version 0e:0f software version 10 - 19 LED service (Primary service) 6E400001-B5A3-F393-E0A9-E50E24DCCA9E 11:12 6E400003-B5A3-F393-E0A9-E50E24DCCA9E(0x04) RxNotify 13 cfg 14:15 6E400002-B5A3-F393-E0A9-E50E24DCCA9E(0x0C) Tx 16 cfg 17:18 6E400004-B5A3-F393-E0A9-E50E24DCCA9E(0x0A) BaudRate 19 0x2901 info ****/
typedef struct ble_character16 { uint16_t type16; //type2 uint16_t handle_rec; //handle uint8_t characterInfo[5];//property1 - handle2 - uuid2 uint8_t uuid128_idx; //0xff means uuid16,other is idx of uuid128 } BLE_CHAR;
typedef struct ble_UUID128 { uint8_t uuid128[16];//uuid128 string: little endian } BLE_UUID128;
// // STEP 0: Character declare // const BLE_CHAR AttCharList[] = { // ===== GATT ===== {TYPE_CHAR, 0x0003, {ATT_CHAR_PROP_RD, 0x04, 0, 0x00, 0x2a}, UUID16_FORMAT}, //name //05-06 reserved
// ===== Device Information Service Characteristics ===== {TYPE_CHAR, 0x0008, {ATT_CHAR_PROP_RD, 0x09, 0, 0x29, 0x2a}, UUID16_FORMAT}, //manufacture {TYPE_CHAR, 0x000a, {ATT_CHAR_PROP_RD, 0x0b, 0, 0x26, 0x2a}, UUID16_FORMAT}, //firmware version {TYPE_CHAR, 0x000e, {ATT_CHAR_PROP_RD, 0x0f, 0, 0x28, 0x2a}, UUID16_FORMAT}, //sw version
// ===== Item Service Characteristics ===== {TYPE_CHAR, 0x11, {ATT_CHAR_PROP_RD | ATT_CHAR_PROP_W | ATT_CHAR_PROP_W_NORSP | ATT_CHAR_PROP_NTF, 0x12, 0, 0 }, 1}, // Characteristic {TYPE_INFO, 0x13}, // Characteristic User Description {TYPE_CFG, 0x14, {ATT_CHAR_PROP_RD|ATT_CHAR_PROP_W}}, // Client Characteristic Configuration {TYPE_PRESENTATION_FORMAT, 0x15}, // Characteristic Pre-sentation Format };
// List of 128-bit UUIDs const BLE_UUID128 AttUuid128List[] = { {0x8f, 0x2e, 0x78, 0x51, 0xba, 0xfb, 0x95, 0xb9, 0xca, 0x41, 0x28, 0x3f, 0x00, 0x00, 0xe2, 0xcc}, {0x8f, 0x2e, 0x78, 0x51, 0xba, 0xfb, 0x95, 0xb9, 0xca, 0x41, 0x28, 0x3f, 0x01, 0x00, 0xe2, 0xcc}, };
uint8_t GetCharListDim(void) { return sizeof(AttCharList) / sizeof(AttCharList[0]); }
// // STEP 1: Service declare // void att_server_rdByGrType( uint8_t pdu_type, uint8_t attOpcode, uint16_t st_hd, uint16_t end_hd, uint16_t att_type ) { // GAP and GATT (start handle 0x01) if ((att_type == GATT_PRIMARY_SERVICE_UUID) && (st_hd == 1)) //hard code for device info service { //GAP Device Name uint8_t t[] = {0x00, 0x18}; att_server_rdByGrTypeRspPrimaryService(pdu_type, 0x1, 0x6, (uint8_t)(t), 2); return; } // Device Info Service (start handle 0x07) else if ((att_type == GATT_PRIMARY_SERVICE_UUID) && (st_hd <= 0x07)) { uint8_t t[] = {0xa, 0x18}; att_server_rdByGrTypeRspPrimaryService(pdu_type, 0x7, 0xf, (uint8_t)(t), 2); return; } // Item Service (start handle 0x20) else if ((att_type == GATT_PRIMARY_SERVICE_UUID) && (st_hd <= 0x11)) { att_server_rdByGrTypeRspPrimaryService(pdu_type, 0x11, 0x15, (uint8_t*)(AttUuid128List[0].uuid128), 16); return; }
///error handle att_notFd( pdu_type, attOpcode, st_hd ); }
// // STEP 2: data coming // write response void ser_write_rsp(uint8_t pdu_type/reserved/, uint8_t attOpcode/reserved/, uint16_t att_hd, uint8_t attValue/app data pointer/, uint8_t valueLen_w/app data size/) { switch (att_hd) { case 0x12: // copy the first byte of written data into the item characteristic value memcpy(&itemCharacteristicValue, attValue, 1); bItemCharacteristicValueChanged = true; ser_write_rsp_pkt(pdu_type); /if the related character has the property of WRITE(with response) or TYPE_CFG, one MUST invoke this func/ break; case 0x14: // write to the Client Characteristic Configuration Descriptor memcpy(&cccd, attValue, 2); ser_write_rsp_pkt(pdu_type); default: att_notFd(pdu_type, attOpcode, att_hd ); /the default response, also for the purpose of error robust */ break; } }
// // STEP 3: Read data // read response void server_rd_rsp(uint8_t attOpcode, uint16_t attHandle, uint8_t pdu_type) { uint8_t d_len; uint8_t* ble_name = getDeviceInfoData(&d_len);
switch (attHandle) // hard code { case 0x04: // GAP name att_server_rd( pdu_type, attOpcode, attHandle, ble_name, d_len); break;
case 0x09: // MANU_INFO
att_server_rd( pdu_type, attOpcode, attHandle, (uint8_t*)(MANU_INFO), sizeof(MANU_INFO) - 1);
break;
case 0x0b: // FIRMWARE_INFO
att_server_rd(pdu_type, attOpcode, attHandle, GetFirmwareInfo(), strlen((const char*)GetFirmwareInfo()));
break;
case 0x0f: // SOFTWARE_INFO
att_server_rd(pdu_type, attOpcode, attHandle, (uint8_t*)(SOFTWARE_INFO), sizeof(SOFTWARE_INFO) - 1);
break;
case 0x12: // Item Characteristic Value
att_server_rd(pdu_type, attOpcode, attHandle, &itemCharacteristicValue, 1);
break;
case 0x13: // Item Characteristic User Description
att_server_rd(pdu_type, attOpcode, attHandle, (uint8_t*) itemCharacteristicUserDescription, sizeof(itemCharacteristicUserDescription));
break;
case 0x14: // Item Client Characteristic Configuration
{
att_server_rd(pdu_type, attOpcode, attHandle, cccd, 2);
}
break;
case 0x15: // Item Characteristic Presentation Format
att_server_rd(pdu_type, attOpcode, attHandle, (uint8_t*)itemCharacteristicPresentationFormat, sizeof(itemCharacteristicPresentationFormat));
break;
default:
att_notFd( pdu_type, attOpcode, attHandle );/*the default response, also for the purpose of error robust */
break;
} }
void ser_prepare_write(unsigned short handle, unsigned char* attValue, unsigned short attValueLen, unsigned short att_offset) {
}
void ser_execute_write(void) {
}
void server_blob_rd_rsp(uint8_t attOpcode, uint16_t attHandle, uint8_t dataHdrP, uint16_t offset) {
}
//return 1 means found int GetPrimaryServiceHandle(unsigned short hd_start, unsigned short hd_end, unsigned short uuid16, unsigned short hd_start_r, unsigned short hd_end_r) { return 0; }
void gatt_user_send_notify_data_callback(void) {
}
uint8_t getsoftwareversion(void) { return (uint8_t)SOFTWARE_INFO; }
static unsigned char gConnectedFlag = 0;
char GetConnectedStatus(void) { return gConnectedFlag; }
void ConnectStausUpdate(unsigned char IsConnectedFlag) //porting api { LED_ONOFF(!IsConnectedFlag);
if (IsConnectedFlag != gConnectedFlag) { gConnectedFlag = IsConnectedFlag; } }
void UsrProcCallback(void) //porting api { return; }
unsigned char aes_encrypt_HW(unsigned char _data, unsigned char _key) { return 0; }
Some progress: the characteristic can be found now after changing the handles many times :) But now the peripheral disconnects shortly after writing the value on both platforms. LightBlue gives the message "Disconnected. Data is stale". May i ask you again for ideas?
Version
Expected behaviour
After connecting to a peripheral, the device should use startNotification to write a value in a specific characteristic.
Actual behaviour
Connection to the peripheral is established and the items properties are available.
But startNotification throws the error message "Could not find characteritic with UUID xxxxxxxxx on service with UUID yyyyyyyy on peripheral with UUID zzzzzzzz"
On Android devices, everything works fine and the characteristic is available and can be written.
Steps to reproduce
Stack trace and console log
Error when using startNotification: "Could not find characteritic with UUID xxxxxxxxx on service with UUID yyyyyyyy on peripheral with UUID zzzzzzzz"