Smart Bluetooth Forum Discussions
Dear All,
I have a problem.How to send a 16 bytes notification?
now,my code only can send a 4-bytes notification.
Is there any error with my code?
My code and GATT definition are as below:
#define OEM_HANDLE_SERV_BATT_MONITOR 0x0500
#define OEM_UUID_SERV_BATT_MONITOR 0x2B, 0x6B, 0xFA, 0xD1, 0x7C, 0x30, 0x2D, 0x94, 0x62, 0x4C, 0x84, 0x38, 0xCE, 0xB7, 0x87, 0x00
// 0087B7CE-3884-4C62-942D-307CD1FA6B2B
#define OEM_HANDLE_CHAR_BATT_MONITOR 0x0501
#define OEM_HANDLE_VALUE_BATT_MONITOR 0x0502
#define OEM_UUID_CHAR_SERV_BATT_MONITOR 0x03, 0xD8, 0xD7, 0x92, 0x4E, 0x58, 0xF1, 0x87, 0x56, 0x4C, 0x28, 0x35, 0x7A, 0xC4, 0xF9, 0x4B
// 4BF9C47A-3528-4C56-87F1-584E92D7D803
//Battery Monitor Service
PRIMARY_SERVICE_UUID128 (OEM_HANDLE_SERV_BATT_MONITOR, OEM_UUID_SERV_BATT_MONITOR),
// Characteristic: battery monitoring
CHARACTERISTIC_UUID128(OEM_HANDLE_CHAR_BATT_MONITOR,
OEM_HANDLE_VALUE_BATT_MONITOR,
OEM_UUID_CHAR_SERV_BATT_MONITOR,
LEGATTDB_CHAR_PROP_READ | LEGATTDB_CHAR_PROP_NOTIFY,
LEGATTDB_PERM_READABLE ,8),
0x00, 0x00, 0x00,0x00, 0x00, 0x00,0x00, 0x00,
if (bleprofile_ReadHandle (OEM_HANDLE_VALUE_BATT_MONITOR, &db_pdu) == 0)
{
//ble_trace0("read batt handle is true \n");
// save to GATT DB for sync with GATT read request
for(i=0;i<EC_REPORT_SIZE;i++)
{
db_pdu.pdu = ec_report;
}
db_pdu.len=8;
//EC_REPORT_SIZE
if(bleprofile_WriteHandle (OEM_HANDLE_VALUE_BATT_MONITOR, &db_pdu)==0)
ble_trace1("read batt handle is true %x\n",db_pdu.pdu [0]);
bleprofile_sendNotification (OEM_HANDLE_VALUE_BATT_MONITOR,db_pdu.pdu, db_pdu.len);
}
Show LessI tried to connect to a the WICED Sense tag using the bluez gattool on ubuntu 14.04 LTS and have consistently gotten a failure indicating that device is busy, even though there are no other connections. Attached is the hcidump output. Any insight would be appreciated. Thanks!
HCI sniffer - Bluetooth packet analyzer ver 2.5
device: hci0 snap_len: 1500 filter: 0xffffffffffffffff
< HCI Command: LE Create Connection (0x08|0x000d) plen 25
bdaddr 00:10:18:01:25:B9 type 0
interval 96 window 48 initiator_filter 0
own_bdaddr_type 0 min_interval 40 max_interval 56
latency 0 supervision_to 42 min_ce 0 max_ce 0
> HCI Event: Command Status (0x0f) plen 4
LE Create Connection (0x08|0x000d) status 0x00 ncmd 2
> HCI Event: LE Meta Event (0x3e) plen 19
LE Connection Complete
status 0x00 handle 3585, role master
bdaddr 00:10:18:01:25:B9 (Public)
> ACL data: handle 3585 flags 0x02 dlen 16
L2CAP(d): cid 0x0005 len 12 [psm 0]
0000: 12 01 08 00 40 00 60 00 00 00 f4 01 ....@.`.....
< ACL data: handle 3585 flags 0x00 dlen 10
L2CAP(d): cid 0x0005 len 6 [psm 0]
0000: 13 01 02 00 00 00 ......
< HCI Command: LE Connection Update (0x08|0x0013) plen 14
0000: 01 0e 40 00 60 00 00 00 f4 01 00 00 00 00 ..@.`.........
> ACL data: handle 3585 flags 0x02 dlen 6
SMP: Security Request (0x0b)
auth req 0x01
< ACL data: handle 3585 flags 0x00 dlen 11
SMP: Pairing Request (0x01)
capability 0x03 oob 0x00 auth req 0x01
max key size 0x10 init key dist 0x05 resp key dist 0x05
Capability: NoInputNoOutput (OOB data not present)
Authentication: Bonding (No MITM Protection)
Initiator Key Distribution: LTK CSRK
Responder Key Distribution: LTK CSRK
> HCI Event: Command Status (0x0f) plen 4
LE Connection Update (0x08|0x0013) status 0x00 ncmd 2
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 3585 packets 1
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 3585 packets 1
> ACL data: handle 3585 flags 0x02 dlen 11
SMP: Pairing Response (0x02)
capability 0x03 oob 0x00 auth req 0x01
max key size 0x10 init key dist 0x05 resp key dist 0x05
Capability: NoInputNoOutput (OOB data not present)
Authentication: Bonding (No MITM Protection)
Initiator Key Distribution: LTK CSRK
Responder Key Distribution: LTK CSRK
< ACL data: handle 3585 flags 0x00 dlen 21
SMP: Pairing Confirm (0x03)
key b70b609c96505b47605bd9b5d703f0b2
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 3585 packets 1
> ACL data: handle 3585 flags 0x02 dlen 21
SMP: Pairing Confirm (0x03)
key 3a0aa66d48c9a061df3375f9b3dbe012
< ACL data: handle 3585 flags 0x00 dlen 21
SMP: Pairing Random (0x04)
random 0a952700f91dc309a6c2100559defabd
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 3585 packets 1
> ACL data: handle 3585 flags 0x02 dlen 21
SMP: Pairing Random (0x04)
random 956d3be0bad5c2aea3d726bde39dbcab
< HCI Command: LE Start Encryption (0x08|0x0019) plen 28
0000: 01 0e 00 00 00 00 00 00 00 00 00 00 37 70 04 3c ............7p.<
0010: 2d 36 ee f4 b0 22 29 c7 1a fc f1 31 -6...")....1
> HCI Event: Command Status (0x0f) plen 4
LE Start Encryption (0x08|0x0019) status 0x3a ncmd 1
Error: Controller Busy
< HCI Command: Disconnect (0x01|0x0006) plen 3
handle 3585 reason 0x05
Reason: Authentication Failure
> HCI Event: Command Status (0x0f) plen 4
Disconnect (0x01|0x0006) status 0x00 ncmd 1
> HCI Event: Disconn Complete (0x05) plen 4
status 0x00 handle 3585 reason 0x16
Reason: Connection Terminated by Local Host
Show LessBLE standard specifies the Inter Frame Space (T_IFS) to be 150 usec.
In a scanning situation, the standard contains a diagram where SCAN_REQ -> T_IFS -> SCAN_RSP (attached is a diagram from the standard).
Does this mean the responding device will send out the SCAN_RSP exactly 150 usec after it receives SCAN_REQ?
150 usec seems like a very short time for message processing. Or is it a minimum value so it could still take as long as msec?
Thanks,
Andrew
Show LessHello everybody,
we're working on an iOS app that will transfer and receive data via Bluetooth LE over custom services and characteristics. These are implemented using SDK 2.2.0 on an BCM90276S module. This will transfer the data via PUART to a MCU.
If the app writes to a characteristic, the write handler is called and the received data is transferred to the MCU, this does work. If the MCU wants to communicate with the app, it writes data via PUART into the BLE module, which works, too.
This puts the received data into the GATT DB and sends a notification.
Now the app gets multiple notifications and is confused - as are we.
So I have two questions:
This is the code that sends the Notification after receiving it from the PUART:
BLEPROFILE_DB_PDU tempPDU;
bleprofile_ReadHandle(handle, &tempPDU); //read to tempPDU
memcpy(tempPDU.pdu, data, tempPDU.len); //memcpy new data to tempPDU
bleprofile_WriteHandle(handle, &tempPDU); //write new data to GATT DB
if (blecm_getAvailableTxBuffers() > 0) //check if TX buffer is not full
{
bleprofile_sendNotification(handle, data, length); //sent notification
}
Does bleprofile_WriteHandle automatically generate a notification if the characteristic has a LEGATTDB_CHAR_PROP_NOTIFY?
And does a bleprofile_WriteHandle issue a write_handle_callback?
I'm registering one, that will send the received characteristic via PUART:
legattdb_regWriteHandleCb((LEGATTDB_WRITE_CB)my_ble_write_handler);
Would a possible work around be the following:
legattdb_deRegWriteHandleCb((LEGATTDB_WRITE_CB)my_ble_write_handler);
bleprofile_WriteHandle(handle, &tempPDU);
legattdb_regWriteHandleCb((LEGATTDB_WRITE_CB)my_ble_write_handler);
Thanks for your help!
Best regards
Hannes Baumgart
Show LessHi everyone,
Issue:
I noticed that the wiced sense stops sending advertising sometimes after one or two seconds and do always complete the advertising durations of 10 seconds + 10 seconds.
Test description:
Note that there is no connection happening, as the connection stops the gpio interrupt and stops the led from blinking and make a buzz.
The led keeps blinking, without packets sent, once it stops after 10+10 seconds, the wake up wakes it and another test of counting advertised packets start.
Advertisement recapitulation:
This is a reminder and also to chekc if I have something wrong.
On wake up, the wiced sense tag will be sending advertisement at high rate for one duration, then at a lower rate for another duration.
in the "wiced_sense_cfg" table:
- high_undirect_adv_interval : 32 => 32 x 625 us => one every 20 ms
- high_undirect_adv_duration : 10 => 10 seconds, so we would expect 500 advertisements during this period
- low_undirect_adv_interval : 1024 => one every 640 ms
- low_undirect_adv_duration : 10 seconds, so we would expect about 15
Issue description and logs:
1) High at 32 slots
with 20 ms delay, the advertisements are very unsteady, and stop sometimes much sooner than expected. So for 500 packets expected, I made multiple retries and here is the list of how many I get every time :
Number of Adv Packets received on every test |
---|
28 5 161 152 271 156 |
Note that the advertisements were interrupted even after the run following the build without battery, so totally powered from usb, so I don't think this is a battery issue.
2) High at 160 slots
with 160 slots which take us up to 100 ms, the advertising is much more stable, but sometimes (once every two to three tests), I still get interruptions and no more advertising.
The attached file adv_160_Good.txt, shows the good case, where no problems happen, just to confirm the numbers
The attached file adv_160_Bad-Stop.txt, simply shows one example of when the advertising was stopped
3) High at 320 slots
everything is working fine
Issue uncertainties:
I would totally agree with any one criticizing this test as not using a billion euro official testing equipment, but a simple tool. However, statistically speaking, I made multiple crosss validations, used different devices, the tool might skip some packets, some times, but it is very unlikely that it get 100% of packets till time t, then 0% afterwards. And that is why I am asking for other opinions maybe some others have a better explanation.
Reference binary:
These deep tests were lead with a modified source, but a similar behavior was observed with all binaries, I hereby would ask if any binary can be used for reference. If I use an out of the box tag (I do have one), maybe someone will ask, no do the update, which update ? My latest tests included wiced_sense.c.From_WICED_Sense_SDK 2.1_1.3Final and wiced_sense.c.From_WICED-Smart-SDK-2.2.1
Thank you already for reading so far, your comments are appreciated.
Wassim
Show LessHi,
Nordic offers Nordic UART Service (NUS) Application as an example that emulates a serial port over BLE.
Could somebody share code to realise similar functionality on BCM20732S, please?
Adafruit has adopted it in their BLE modules.
And it is gaining popularity. There are already several iOS Apps supporting it.
Cordova's Bluetooth Serial plugin supports it so I can expect even more apps are coming.
https://github.com/don/BluetoothSerial/blob/master/src/ios/BLEDefines.h
I'd like to develop BLE hardware supporting compatible UART like service based on BCM20732S.
But my skills are limited to implement it myself...
I know ACKme and iDevices offer BLE modules with UART like service but I'd like to stick with BCM20732S for the price. (If I had to use a module, I'd use Nordic based module anyway!).
Show LessHi all,
My table is like this:
const BLE_PROFILE_CFG contact_exchg_cfg =
{
/*.fine_timer_interval =*/ CONTACT_EXCHG_FINE_TIMER, // 500 ms
/*.default_adv =*/ 4, // HIGH_UNDIRECTED_DISCOVERABLE
/*.button_adv_toggle =*/ 0, // pairing button make adv toggle (if 1) or always on (if 0)
/*.high_undirect_adv_interval =*/ 200, // slots (320 = every 200 ms)
/*.low_undirect_adv_interval =*/ 200, // slots
/*.high_undirect_adv_duration =*/ 4, // seconds
/*.low_undirect_adv_duration =*/ 4, // seconds
/*.high_direct_adv_interval =*/ 0, // seconds
/*.low_direct_adv_interval =*/ 0, // seconds
/*.high_direct_adv_duration =*/ 0, // seconds
/*.low_direct_adv_duration =*/ 0, // seconds
...
};
where one can see that High and Low advertising parameters are identical and set to 125 ms interval.
If I call
bleprofile_Discoverable(HIGH_UNDIRECTED_DISCOVERABLE, NULL);
I do get an interval of 125 ms, which is what I expected.
But if I call
bleprofile_Discoverable(LOW_UNDIRECTED_DISCOVERABLE, NULL);
I see an interval of 1 s (and I did NOT expect to see that).
Why is it different? Now I'm confused about this "high" vs. "low" advertising. Why did it divide the frequency (multiplied the interval) by 8?
Thanks,
Gil
Show LessHi BCM,
We find some info in the Community, which inform developper to to check thread and stack size in APP layer.
The lib DIR: /WICED-Smart-SDK/Wiced-Smart/tier2/brcm/libraries/inc/thread_and_mem_mgmt.h
My question is:
1. blecm_SetApplicationThreadStackSizeInWords() to get the stack size,
The callback functions in our APP layer, such as timer callback, connection up/down callback, gatt etc., all of these use this one Application thread ?
Eg. /// Default is 256 = 1024 byte stack and this is the minimum recommended.
if we define a temp buffer in gatt or callback function in APP layer, whose size is 1025B, Would it cause this thread stack overflow ?
Many thank...maxsong
Show LessIs there a way to get the temperature at which a BCM2073X is operating?