Connection won't work

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
ChGa_3545231
Level 2
Level 2
First like given

Hi there,

I am trying to establish a connection between my PSOC and a BlueRadios Sensor -Sensorbug-.

After establishing the connection the next thing would be to read out the light data which the sensor measures.

I am trained in C and learned - learning it in school and so I thought I could do this without a problem.

But I realized pretty soon that I was wrong especially the API's for the BLE Kit are driving me crazy.

So I tried to establish the connection with my code, which I is posted down here, but it won't connect.

And I am coming to a point where I don't know what to do anymore, I am stuck and would need some help.

My code always stops at the same position.

It always tries to match the given MSD with the one he reads. But they don't match and I don't know why. Espescially because I don't know what that data is for and what exactly to give in. I tried to read it out of the datasheet but there is some data called MSD but not company specific data and manufactuerer specific data.

Thanks

Chris

0 Likes
1 Solution

Hello Chris,

We can compare with Advertisement data or Scan response data.

If Peripheral is advertising and Central is scanning during this period Central will send scan request to peripheral then peripheral sends the scan response data as shown in image.

pastedImage_0.png

Please make sure that the comparison is properly happening in the Central side. For example, if you are considered to compare with the advertisement data please make sure that according to the indexes correct values are assigned or not in Central. For example, w.r.t above advertisement data ScanReport.data[1]=0x01 , ScanReport.data[2]=0x05 , ScanReport.data[3]=0x03 , ScanReport.data[8]=0xFF.....

Thanks,

P Yugandhar.

View solution in original post

0 Likes
12 Replies
Yugandhar
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 5 likes given

Hello Chris,

In this project, the central will connect to the peripheral by checking the MSD and other scan response data. But the Lux sensor (peripheral) the values are different so the central can't detect.

Please try to detect using the Lux Sensor(peripheral) Address i.e.,  in the scan response report try to check with the Sensor Address and then connect.

Thanks,

P Yugandhar.

0 Likes

Thank you,

I did this and tried to compare the macros with the values but there is one problem.

case CYBLE_EVT_GAPC_SCAN_PROGRESS_RESULT:

                scanReport=  *(CYBLE_GAPC_ADV_REPORT_T*)eventParam;

                

                /*Check for the Manufacturer specific data in scan response*/

                if(scanReport.data[1] == MANUFACTURER_SPECIFIC_DATA && scanReport.data[2] == COMPANY_LSB &&                                           scanReport.data[3] == COMPANY_MSB  && scanReport.data[4] == MAN_SPEC_DATA_LSB && scanReport.data[5] ==                   MAN_SPEC_DATA_MSB)

                {

scnaReport should have stored the manufacturer data to compare it with the macros. But it only has 1 value stored in data -> 0x02 which means scanable undirected advertising.

At this point I am a bit confused because it isn't like in the example project where it compares the advertising data.

Is there a other function which gives me the result I am searching for or am I using it wrong?

Thanks

0 Likes

Hello Chris,

In the GitHub, Our project "Day013_Client_Server" has two projects "Client and Server-Peripheral" and "Client and Server-Central" . Peripheral has some scan response data so the Central will compare these data with the ScanReport data(which we get during scanning) and then identify the Peripheral. For your Sensor these values are different so the Central can't identify.

Please go through the Client and Server-Peripheral project, in this Peripheral project scan response data is as shown in below image

pastedImage_3.png

The Central will compare these values with the ScanReport data and then connect to Peripheral.

Thanks,

P Yugandhar.

0 Likes

Thanks for that but I already did that.

I looked up in the datasheet and scanned with cysmart what the msd is and fsved it as macros.

The thing is that my ScanReport only has 1 value - 0x02 which stands for scanable undirected advertisement.

So where's the thing I am missing out?

Chris

0 Likes

Hello Chris,

Can you try to compare ScanReport with your sensor Address by using "ScanReport.peerBdAddr[ ]" which gives Address report. The structure of scanreport is as defined below.

struct CYBLE_GAPC_ADV_REPORT_T

Data Fields

• CYBLE_GAPC_ADV_EVENT_T eventType

• uint8 peerAddrType

• uint8 * peerBdAddr

• uint8 dataLen

• uint8 * data

• int8 rssi

Please refer the component datasheet for more details.

Thanks,

P Yugandhar.

0 Likes

Hi,

thank you.

So you say that I should compare the peeradress.

But why? I wanted to compare the advertisement data in which the msd is and not the peer adress data?

Am I missing something out?

Thanks,

Chris

0 Likes

Hello Chris,

In your sensor datasheet the scan response data is shown in below image.

pastedImage_1.png

So in the central device you have to compare with these scan response data values only.

Can you please send me the scan report data of your Peripheral which you see in CySmart dongle.

Thanks,

P Yugandhar.

0 Likes

Hi,

advertisement data.PNGadvertisement data 2.PNGscan response data.PNGSensorbug.PNG

thank you again.

I thought that it stores the scan respones data OR the advertisement data.

Because that is what it says in the datasheet under

advertisement report api.PNG

0 Likes

The point is that I just want to compare the ad data which the pheripheral sends -> the MSD which I already figured out via CySmart -> with the data that the central gets - the ad data in which the 3rd part the 12 byte long msd should be -> and if I am not wrong it says in the datasheet that CYBLE_GAPC_ADV_REPORT_T -> data should have stored the ad data AND / OR the scan repsonse data.

Thanks CHris

0 Likes

Hello Chris,

We can compare with Advertisement data or Scan response data.

If Peripheral is advertising and Central is scanning during this period Central will send scan request to peripheral then peripheral sends the scan response data as shown in image.

pastedImage_0.png

Please make sure that the comparison is properly happening in the Central side. For example, if you are considered to compare with the advertisement data please make sure that according to the indexes correct values are assigned or not in Central. For example, w.r.t above advertisement data ScanReport.data[1]=0x01 , ScanReport.data[2]=0x05 , ScanReport.data[3]=0x03 , ScanReport.data[8]=0xFF.....

Thanks,

P Yugandhar.

0 Likes

Hi,

thanks.

It finally works and I understand now why it didn't at first.

I come till the point: CyBle_GapcStopScan();

And after that it should generate: CYBLE_EVT_GAPC_SCAN_START_STOP:

but it doesn't and I can't find why.

I looked it up in the API Document but there it only says it generates this event.

Is there some kind of condition to it that I don't fullfil?

Thanks

Chris

0 Likes

Hello Chris,

Please make sure that CyBle_ProcessEvents() function is continuously calling or not.

Thanks,

P Yugandhar.

0 Likes