Hi,
I am trying to modify the Zephyr central_hrs module so that it will print out the name of any peripheral it discovers and eventually store them in some 2D array. The problem is that I can't get it to work properly. I found this post: How to read advertising BLE devices' name? which does let you print out device names. The issue is that they are using the generic "central" example and bt_data_parse() eats the pointer to the advertisement data you give it so it can't be reused. In "central_hr" you already have an essential call to bt_data_parse() in order to establish a connection. The obvious solution to this is to create "struct net_buf_simple ad_temp" and copy the advertisement data structure into it but all attempts to do so have failed. Everything I have tried has either given me a memory fault or or just given me garbled characters. I also tried modifying the existing bt_data_parse() callback function in "central_hr" but to little success. I don't know if this is more a zephyr or a straight up C fundamentals question but any help copying the advertisement data into a temporary net_buf_simple struct would be greatly appreciated. I will post the relevant code I have below:
This is the central_code. In this state it the code seems to memory fault and I am not sure why:
And then here is the relevant stuff on the peripheral code: