BLE packets are mixed with Advertise and ScanResponse

Hi,

I am developing a device that BLE Advertise, and I scan the packet using CoreBluetooth in my app. When my device advertise two or more packets with ScanResponse at almost time, the results scanned in CoreBluetooth are not accurate. In other words, it delivers the result consisting of different Advertise packets and ScanResponse packets.

Packets delivered from CoreBluetooth

ADV + ScanResponse

Expected packet: 88571D0B84D906020430 + 373957

Actual packets: 88571D0B84D906020430 + 304633

The packets delivered in the CoreBluetooth is a mixture of 1st ADV data and 2nd ScanResp. values.

[1st ADV data] + [ScanResponse of 2nd ADV data]

Is this a CoreBluetooth bug? Or is it an issue of the device's advertise policy?

Attach the btsnoop log on my iPhone below.


### [1st ADV data]

Dec 02 14:00:14.395  HCI Event        0x0000  98:D7:42:00:15:0C  LE - Ext ADV - 1 Report - Normal - Public - 98:D7:42:00:15:0C  -68 dBm - Manufacturer Specific Data - Channel 38  
	Parameter Length: 57 (0x39)
	Num Reports: 0X01
	Report 0
		Event Type: Connectable Advertising - Scannable Advertising - Legacy Advertising PDUs Used - Complete - 
		Address Type: Public
		Peer Address: 98:D7:42:00:15:0C
		Primary PHY: 1M
		Secondary PHY: No Packets
		Advertising SID: Unavailable
		Tx Power: Unavailable
		RSSI: -68 dBm
		Periodic Advertising Interval: 0.000000ms (0x0)
		Direct Address Type: Public
		Direct Address: 00:00:00:00:00:00
		Data Length: 31
		Flags: 0x4
			BR/EDR Not Supported
		Data: 02 01 04 1B FF 75 00 42 0C 83 05 59 30 41 4A 54 32 31 30 01 04 88 57 1D 0B 84 D9 06 02 04 30 
Dec 02 14:00:14.395  HCI Event        0x0000                     00000000: 3E39 0D01 1326 000C 1500 42D7 9801 00FF  >9...&....B.....  
	00000000: 3E39 0D01 1326 000C 1500 42D7 9801 00FF  >9...&....B.....
	00000010: 7FBC 0000 0000 0000 0000 001F 0201 041B  ................
	00000020: FF75 0042 0C83 0559 3041 4A54 3231 3001  .u.B...Y0AJT210.
	00000030: 0488 571D 0B84 D906 0204 30              ..W.......0


###  [2nd ADV data]

Dec 02 14:00:14.407  HCI Event        0x0000  98:D7:42:00:15:0C  LE - Ext ADV - 1 Report - Normal - Public - 98:D7:42:00:15:0C  -60 dBm - Manufacturer Specific Data - Channel 39  
	Parameter Length: 57 (0x39)
	Num Reports: 0X01
	Report 0
		Event Type: Connectable Advertising - Scannable Advertising - Legacy Advertising PDUs Used - Complete - 
		Address Type: Public
		Peer Address: 98:D7:42:00:15:0C
		Primary PHY: 1M
		Secondary PHY: No Packets
		Advertising SID: Unavailable
		Tx Power: Unavailable
		RSSI: -60 dBm
		Periodic Advertising Interval: 0.000000ms (0x0)
		Direct Address Type: Public
		Direct Address: 00:00:00:00:00:00
		Data Length: 31
		Flags: 0x4
			BR/EDR Not Supported
		Data: 02 01 04 1B FF 75 00 42 0C 83 23 59 30 41 46 44 36 31 31 04 01 98 D7 42 00 15 0C 06 02 04 30 
Dec 02 14:00:14.407  HCI Event        0x0000                     00000000: 3E39 0D01 1327 000C 1500 42D7 9801 00FF  >9...'....B.....  
	00000000: 3E39 0D01 1327 000C 1500 42D7 9801 00FF  >9...'....B.....
	00000010: 7FC4 0000 0000 0000 0000 001F 0201 041B  ................
	00000020: FF75 0042 0C83 2359 3041 4644 3631 3104  .u.B..#Y0AFD611.
	00000030: 0198 D742 0015 0C06 0204 30              ...B......0


###  [ScanResponse of 2nd ADV data]

Dec 02 14:00:14.407  HCI Event        0x0000  98:D7:42:00:15:0C  LE - Ext ADV - 1 Report - Normal - Public - 98:D7:42:00:15:0C  -60 dBm - ST Station123 - Manufacturer Specific Data - Channel 39  
	Parameter Length: 48 (0x30)
	Num Reports: 0X01
	Report 0
		Event Type: Connectable Advertising - Scannable Advertising - Scan Response - Legacy Advertising PDUs Used - Complete - 
		Address Type: Public
		Peer Address: 98:D7:42:00:15:0C
		Primary PHY: 1M
		Secondary PHY: No Packets
		Advertising SID: Unavailable
		Tx Power: Unavailable
		RSSI: -60 dBm
		Periodic Advertising Interval: 0.000000ms (0x0)
		Direct Address Type: Public
		Direct Address: 00:00:00:00:00:00
		Data Length: 22
		Local Name: ST Station123
		Data: 0E 09 53 54 20 53 74 61 74 69 6F 6E 31 32 33 06 FF 75 00 30 46 33 
Dec 02 14:00:14.407  HCI Event        0x0000                     00000000: 3E30 0D01 1B27 000C 1500 42D7 9801 00FF  >0...'....B.....  
	00000000: 3E30 0D01 1B27 000C 1500 42D7 9801 00FF  >0...'....B.....
	00000010: 7FC4 0000 0000 0000 0000 0016 0E09 5354  ..............ST
	00000020: 2053 7461 7469 6F6E 3132 3306 FF75 0030   Station123..u.0
	00000030: 4633                                     F3
BLE packets are mixed with Advertise and ScanResponse
 
 
Q