Quellcode durchsuchen

[add]support 128bit and 32bit uuid

区荣杰 vor 4 Jahren
Ursprung
Commit
98ddcad450
3 geänderte Dateien mit 3 neuen und 19 gelöschten Zeilen
  1. 0 2
      port/NIMBLE/bsal_nimble.c
  2. 1 13
      profiles/service/bsal_uart/bsal_srv_uart.c
  3. 2 4
      samples/ble_nus_app.c

+ 0 - 2
port/NIMBLE/bsal_nimble.c

@@ -281,7 +281,6 @@ static BSAL_STATUS bsal_int_srv_profile_reg_service(
         {
         {
             ble_uuid128_t *tmp_uuid = bsal_osif_malloc(sizeof(ble_uuid128_t));
             ble_uuid128_t *tmp_uuid = bsal_osif_malloc(sizeof(ble_uuid128_t));
             tmp_uuid->u.type = BLE_UUID_TYPE_128;
             tmp_uuid->u.type = BLE_UUID_TYPE_128;
-            //tmp_uuid->value = tmp_srv->uuid->u16.value;
             memcpy(tmp_uuid->value, tmp_srv->uuid->u128.value,16);
             memcpy(tmp_uuid->value, tmp_srv->uuid->u128.value,16);
             nimble_srvs->uuid = &tmp_uuid->u;
             nimble_srvs->uuid = &tmp_uuid->u;
         }
         }
@@ -324,7 +323,6 @@ static BSAL_STATUS bsal_int_srv_profile_reg_service(
                 {
                 {
                     ble_uuid128_t *tmp_uuid = bsal_osif_malloc(sizeof(ble_uuid128_t));
                     ble_uuid128_t *tmp_uuid = bsal_osif_malloc(sizeof(ble_uuid128_t));
                     tmp_uuid->u.type = BLE_UUID_TYPE_128;
                     tmp_uuid->u.type = BLE_UUID_TYPE_128;
-                    //tmp_uuid->value = tmp_srv->uuid->u16.value;
                     memcpy(tmp_uuid->value, tmp_srv->characteristics[x].uuid->u128.value,16);
                     memcpy(tmp_uuid->value, tmp_srv->characteristics[x].uuid->u128.value,16);
                     nimble_chrs[x].uuid = &tmp_uuid->u;
                     nimble_chrs[x].uuid = &tmp_uuid->u;
                 }
                 }

+ 1 - 13
profiles/service/bsal_uart/bsal_srv_uart.c

@@ -64,7 +64,6 @@ static void profile_callback(void *p)
     if (p_param->msg_type == BSAL_CALLBACK_TYPE_READ_CHAR_VALUE)
     if (p_param->msg_type == BSAL_CALLBACK_TYPE_READ_CHAR_VALUE)
     {
     {
         //NO DEAL had not finished
         //NO DEAL had not finished
-//              rt_kprintf("read_index = %d\n", p_param->off_handle);
         is_app_cb = true;
         is_app_cb = true;
     }
     }
     else if (p_param->msg_type == BSAL_CALLBACK_TYPE_WRITE_CHAR_VALUE)
     else if (p_param->msg_type == BSAL_CALLBACK_TYPE_WRITE_CHAR_VALUE)
@@ -78,12 +77,10 @@ static void profile_callback(void *p)
     }
     }
     else if (p_param->msg_type == BSAL_CALLBACK_TYPE_INDIFICATION_NOTIFICATION)
     else if (p_param->msg_type == BSAL_CALLBACK_TYPE_INDIFICATION_NOTIFICATION)
     {
     {
-//              rt_kprintf("CCCD off_handle = %d\n", p_param->off_handle);
         if (GATT_SVC_NUS_CHAR_CCCD_INDEX == p_param->off_handle)
         if (GATT_SVC_NUS_CHAR_CCCD_INDEX == p_param->off_handle)
         {
         {
             if (p_param->length == 2)
             if (p_param->length == 2)
             {
             {
-                //uint16_t ccdbit = (uint16_t)p_param->data;
                 is_app_cb = true;
                 is_app_cb = true;
             }
             }
         }
         }
@@ -206,7 +203,6 @@ void bsal_bleuart_uart_proc(void *stack_ptr, uint16_t conn_id)
     bsal_uuid_any_t uuid_srv;
     bsal_uuid_any_t uuid_srv;
     uuid_srv.u_type = BSAL_UUID_TYPE_128BIT;
     uuid_srv.u_type = BSAL_UUID_TYPE_128BIT;
     rt_memcpy(uuid_srv.u128.value, gatt_svr_chr_uart_read_uuid.value, 16);
     rt_memcpy(uuid_srv.u128.value, gatt_svr_chr_uart_read_uuid.value, 16);
-//    uuid_srv.u128.value = ;
     uint16_t start_handle = bsal_srv_get_start_handle(stack_ptr, uuid_srv);
     uint16_t start_handle = bsal_srv_get_start_handle(stack_ptr, uuid_srv);
 
 
     rt_kprintf("======== Welcome to enter bluetooth uart mode ========\n");
     rt_kprintf("======== Welcome to enter bluetooth uart mode ========\n");
@@ -236,16 +232,8 @@ void bsal_bleuart_uart_proc(void *stack_ptr, uint16_t conn_id)
 
 
         console_buf[off] = '\0';
         console_buf[off] = '\0';
         rt_kprintf("\n");
         rt_kprintf("\n");
-//              rt_kprintf("send connid = %d\n", conn_id);
-//              rt_kprintf("send start_handle = %d\n", start_handle);
-//              bsal_srv_write_data(p_param->stack_ptr, p_param->start_handle, p_param->off_handle, sizeof(console_buf), console_buf);
         bsal_srv_send_notify_data(stack_ptr, conn_id, start_handle, GATT_SVC_NUS_READ_INDEX, sizeof(console_buf), console_buf);
         bsal_srv_send_notify_data(stack_ptr, conn_id, start_handle, GATT_SVC_NUS_READ_INDEX, sizeof(console_buf), console_buf);
-//        om = ble_hs_mbuf_from_flat(console_buf, off);
-//        if (!om) {
-//            return;
-//        }
-//        ble_gattc_notify_custom(g_console_conn_handle,
-//                                g_bleuart_attr_read_handle, om);
+
         off = 0;
         off = 0;
     }
     }
 
 

+ 2 - 4
samples/ble_nus_app.c

@@ -69,8 +69,6 @@ static void bsal_app_all_callback(void *stack_ptr, uint8_t cb_layer, uint16_t cb
         if (cb_sub_event == BSAL_CB_STACK_READY)
         if (cb_sub_event == BSAL_CB_STACK_READY)
         {
         {
             //stack ready
             //stack ready
-            //   APP_PRINT_INFO0("GAP stack ready");
-
         }
         }
 
 
         break;
         break;
@@ -152,7 +150,7 @@ static void bsal_app_profile_callback(void *p)
     }
     }
     else if (bsal_param->msg_type == BSAL_CALLBACK_TYPE_WRITE_CHAR_VALUE)
     else if (bsal_param->msg_type == BSAL_CALLBACK_TYPE_WRITE_CHAR_VALUE)
     {
     {
-//        bsal_osif_printf_info("\r\n BSAL: THE DATA IS :%s\r\n", bsal_param->data);
+        bsal_osif_printf_info("\r\n BSAL: THE DATA IS :%s\r\n", bsal_param->data);
     }
     }
 }
 }
 
 
@@ -186,7 +184,7 @@ int bsal_nus_app(void)
     //5. srv_end
     //5. srv_end
     bsal_stack_le_srv_end(stack_ptr);    //end srv add
     bsal_stack_le_srv_end(stack_ptr);    //end srv add
 
 
-    //start stack
+    //6. start stack
     bsal_stack_startup(stack_ptr);    //start she
     bsal_stack_startup(stack_ptr);    //start she
 
 
     bsal_bleuart_init(stack_ptr, bsal_app_conn_handle);
     bsal_bleuart_init(stack_ptr, bsal_app_conn_handle);