cancel
Showing results for 
Search instead for 
Did you mean: 

WICED Studio Bluetooth

ns_4270701
New Contributor II

Development environment:

Windows 8.1 pro

Platform: CYW920719Q40EVB-01, CYBT-423028-02

IDE: Wiced Studio 6.2.1

1) I have prepared a custom "clientapp" application from "hello_client" reference wiced example code. (Firmware loaded to Wiced kit as mentioned above )

2) And prepared a custom "peripheral" application. And configured vendor specific service named "testservice" (128 UUID)

With two characteristics one with properties of READ and WRITE with READ WRITE permissions  & other characteristics with READ property and READ permission.

(Peripheral Firmware loaded to our custom board design using CYBT-423028-02 module)

// ***** Primary Service 'Generic Attribute'

#define HDLS_GENERIC_ATTRIBUTE                             0x0001

// ***** Primary Service 'Generic Access'

#define HDLS_GENERIC_ACCESS                                               0x0014

// ----- Characteristic 'Device Name'

#define HDLC_GENERIC_ACCESS_DEVICE_NAME                    0x0015

#define HDLC_GENERIC_ACCESS_DEVICE_NAME_VALUE       0x0016

// ----- Characteristic 'Appearance'

#define HDLC_GENERIC_ACCESS_APPEARANCE                      0x0017

#define HDLC_GENERIC_ACCESS_APPEARANCE_VALUE         0x0018            /*peripheraltest*/

// ***** Primary Service 'testservice'

#define HDLS_TESTSERVICE                                                   0x0028

// ----- Characteristic 'ReadWriteChar'

#define HDLC_TESTSERVICE_READWRITECHAR                 0x0029

#define HDLC_TESTSERVICE_READWRITECHAR_VALUE   0x002A

// ===== Descriptor 'User Description'

#define HDLD_TESTSERVICE_READWRITECHAR_USER_DESCRIPTION 0x002B      /*READWRITE*/

// ----- Characteristic 'BatStat'

#define HDLC_TESTSERVICE_BATSTAT                                0x002C

#define HDLC_TESTSERVICE_BATSTAT_VALUE                  0x002D   

// ===== Descriptor 'User Description'

#define HDLD_TESTSERVICE_BATSTAT_USER_DESCRIPTION       0x002E               /*BatteryStat*/

Success

A) Individually both Firmware works properly, I am able to read an write to devices.

b) I want to connect to Cypress kit to our custom board. I am succeeded to connect both the device, and discover the services and its starting and ending handles of peripheral device.

By this I am able to read the descriptor value by handle 0x002B  (value: READWRITE )and 0x002E ( value BatteryStat).

In peripheral device I had set the value in handle 0x002D which is "battery 90", I am able to read from other devices .

Query: I am unable to read or write to peripheral devices for specific handle

For READ Operation:

From Cypress kit I am unable to read the value of handle 0x002D, and getting the status from

Finction : "wiced_bt_gatt_status_t clientapp_gatt_op_comp_cb( wiced_bt_gatt_operation_complete_t *p_data )"

operation : read

Status : 0x0d  (WICED_BT_GATT_INVALID_ATTR_LEN)

Note: from any other devices (Mobile app cysmart) the values are easily readable.

For WRITE Operation:

From Cypress kit I am unable to write the value to the handle 0x002A,

Case 1:

        Prepared a packet to send

        p_write->handle   = 0x2A; /* write data  */

//        p_write->offset   = 0;

        p_write->len      = sizeof(mydata);                                        /mydata  = "3,1"/

        p_write->auth_req = GATT_AUTH_REQ_NONE;

        memcpy(p_write->value,&mydata,sizeof(mydata));

       wiced_bt_gatt_send_write ( g_client.conn_id, GATT_WRITE, p_write );                            //Trial 1

       and getting the status from

Finction : "wiced_bt_gatt_status_t clientapp_gatt_op_comp_cb( wiced_bt_gatt_operation_complete_t *p_data )"

operation : write

Status : 0x03  (WICED_BT_GATT_WRITE_NOT_PERMIT)

Case 2:

        Prepared a packet to send

        p_write->handle   = 0x2A; /* write data  */

//        p_write->offset   = 0;

        p_write->len      = sizeof(mydata);                                        /mydata  = "3,1"/

        p_write->auth_req = GATT_AUTH_REQ_NONE;

        memcpy(p_write->value,&mydata,sizeof(mydata));

       wiced_bt_gatt_send_write ( g_client.conn_id, GATT_WRITE_NO_RSP, p_write );                        //Trial 2    

and getting the status from

Finction : "wiced_bt_gatt_status_t clientapp_gatt_op_comp_cb( wiced_bt_gatt_operation_complete_t *p_data )"

operation : write

Status : 0x00

Expected Scenario : At the peripheral side on receiving "3,1" the LED light has to start blinking,

Actual Scenario      : but no activity of LED.

Note: from any other devices (Mobile app cysmart)  its works fine , LED start blinking.

0 Likes
1 Solution
ns_4270701
New Contributor II

Thank you for your response,

You have a custom "clientapp" (based on hello_client example) and a custom "peripheral" app with few services and characteristic.

"'I want to connect to Cypress Kit to our custom board"   ->  Did you mean, you want to connect "clientapp" (running on Cypress kit (CYW920719Q40EVB-01)) to the peripheral app (running on custom board ( CYBT-423028-02))?

  Yes.

Problem is solved and I succeeded to communicate over Bluetooth.  Read-Write operation done.

But I have other Queries are:

1. What encryption method should I use. Encryption and Bonding are two different cycles ? please share some example code, if possible.

2. What Frame format/ Frame structure should I use to communicate over Bluetooth?

3. What methods should I use for secure communication over Bluetooth?

View solution in original post

0 Likes
3 Replies
DheerajPK_41
Moderator
Moderator

HI,

Let me make it clear.

You have a custom "clientapp" (based on hello_client example) and a custom "peripheral" app with few services and characteristic.

"'I want to connect to Cypress Kit to our custom board"   ->  Did you mean, you want to connect "clientapp" (running on Cypress kit (CYW920719Q40EVB-01)) to the peripheral app (running on custom board ( CYBT-423028-02))?

Could you please share you project/code with us to understand the issue better ?

(If the code is confidential or do not want to post in the community publicly, I would recommend you to create a SFDC case)

Thanks,

-Dheeraj

0 Likes
ns_4270701
New Contributor II

Thank you for your response,

You have a custom "clientapp" (based on hello_client example) and a custom "peripheral" app with few services and characteristic.

"'I want to connect to Cypress Kit to our custom board"   ->  Did you mean, you want to connect "clientapp" (running on Cypress kit (CYW920719Q40EVB-01)) to the peripheral app (running on custom board ( CYBT-423028-02))?

  Yes.

Problem is solved and I succeeded to communicate over Bluetooth.  Read-Write operation done.

But I have other Queries are:

1. What encryption method should I use. Encryption and Bonding are two different cycles ? please share some example code, if possible.

2. What Frame format/ Frame structure should I use to communicate over Bluetooth?

3. What methods should I use for secure communication over Bluetooth?

View solution in original post

0 Likes
AnjanaM_61
Moderator
Moderator

Hi ns_4270701 ,

Depending upon your application and IO capabilities you can choose any of the Security modes defined by BT spec.

I would suggest you to go through our WICED ACADEMY lab manuals available here: GitHub - cypresssemiconductorco/CypressAcademy_WBT101_Files: Files for WICED Bluetooth 101 class 

Please go through WBT101-04B-BLE-Ntfy-Sec.pdf (CypressAcademy_WBT101_Files/WBT101-04B-BLE-Ntfy-Sec.pdf at master · cypresssemiconductorco/CypressAc... ) to understand the LE security methods available in our chip.

Regards