The error is coming ctxt is used initialized for sending. data to phone
Posted: Thu May 04, 2023 3:22 am
Hi there,
I have used bleprph for bonding and device read but when i call this function in code 'ctxt' may be used uninitialized [-Werror=maybe-uninitialized] error is coming.
I have used bleprph for bonding and
- static int
- gatt_svr_chr_access_sec_test(uint16_t conn_handle, uint16_t attr_handle,
- struct ble_gatt_access_ctxt *ctxt,
- void *arg);
- static const struct ble_gatt_svc_def gatt_svcs[] = {
- {.type = BLE_GATT_SVC_TYPE_PRIMARY,
- .uuid = BLE_UUID16_DECLARE(0x180), // Define UUID for device type
- .characteristics = (struct ble_gatt_chr_def[]){
- {.uuid = BLE_UUID16_DECLARE(0xFEF4), // Define UUID for reading
- .flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_READ_AUTHEN,
- .access_cb = device_read},
- {.uuid = BLE_UUID16_DECLARE(0xDEAD), // Define UUID for writing
- .flags = BLE_GATT_CHR_F_WRITE_NO_RSP | BLE_GATT_CHR_F_WRITE_AUTHEN,
- .access_cb = device_write},
- {0}}},
- {0}};
- static int device_read(uint16_t con_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt *ctxt, void *arg)
- {
- // send_data[6]="Hello";
- ctxt->om=0;
- os_mbuf_append(ctxt->om, &arg, sizeof(arg));
- for (int i =0;i < sizeof(arg);i++ ){
- printf("%c",(char)send_data[i]);
- }
- return 0;
- }
- void switch_send(void){
- struct ble_gatt_access_ctxt *ctxt;
- uint16_t con_handle =0;
- uint16_t attr_handle=0;
- switch(send_dat[0]){
- case 'A': send_data[0]='R';
- send_data[1]='E';
- send_data[2]='L';
- send_data[3]='A';
- send_data[4]='Y';
- send_data[5]=' ';
- send_data[6]='1';
- send_data[7]=' ';
- send_data[8]='O';
- send_data[9]='N';
- device_read(con_handle, attr_handle, ctxt, "RELAY 1 ON");
- break;