Matter SDK Coverage Report
Current view: top level - ble - BleError.cpp (source / functions) Coverage Total Hit
Test: SHA:b879ecb8e99e175eea0a293a888bda853da2b19c Lines: 100.0 % 85 85
Test Date: 2025-01-17 19:00:11 Functions: 100.0 % 2 2

            Line data    Source code
       1              : /*
       2              :  *
       3              :  *    Copyright (c) 2020 Project CHIP Authors
       4              :  *    Copyright (c) 2019 Google LLC.
       5              :  *
       6              :  *    Licensed under the Apache License, Version 2.0 (the "License");
       7              :  *    you may not use this file except in compliance with the License.
       8              :  *    You may obtain a copy of the License at
       9              :  *
      10              :  *        http://www.apache.org/licenses/LICENSE-2.0
      11              :  *
      12              :  *    Unless required by applicable law or agreed to in writing, software
      13              :  *    distributed under the License is distributed on an "AS IS" BASIS,
      14              :  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      15              :  *    See the License for the specific language governing permissions and
      16              :  *    limitations under the License.
      17              :  */
      18              : 
      19              : /**
      20              :  *    @file
      21              :  *      This file contains functions for working with BLE Layer errors.
      22              :  */
      23              : 
      24              : #define _CHIP_BLE_BLE_H
      25              : #include "BleError.h"
      26              : 
      27              : #include <lib/core/ErrorStr.h>
      28              : 
      29              : namespace chip {
      30              : namespace Ble {
      31              : 
      32              : /**
      33              :  * Register a text error formatter for BLE Layer errors.
      34              :  */
      35           68 : void RegisterLayerErrorFormatter()
      36              : {
      37              :     static ErrorFormatter sBleLayerErrorFormatter = { FormatLayerError, nullptr };
      38              : 
      39           68 :     RegisterErrorFormatter(&sBleLayerErrorFormatter);
      40           68 : }
      41              : 
      42          656 : bool FormatLayerError(char * buf, uint16_t bufSize, CHIP_ERROR err)
      43              : {
      44          656 :     const char * desc = nullptr;
      45              : 
      46          656 :     if (!err.IsPart(ChipError::SdkPart::kBLE))
      47              :     {
      48          629 :         return false;
      49              :     }
      50              : 
      51              : #if !CHIP_CONFIG_SHORT_ERROR_STR
      52           27 :     switch (err.AsInteger())
      53              :     {
      54            3 :     case BLE_ERROR_ADAPTER_UNAVAILABLE.AsInteger():
      55            3 :         desc = "BLE adapter unavailable";
      56            3 :         break;
      57            1 :     case BLE_ERROR_NO_CONNECTION_RECEIVED_CALLBACK.AsInteger():
      58            1 :         desc = "No chip over BLE connection received callback set";
      59            1 :         break;
      60            1 :     case BLE_ERROR_CENTRAL_UNSUBSCRIBED.AsInteger():
      61            1 :         desc = "BLE central unsubscribed";
      62            1 :         break;
      63            1 :     case BLE_ERROR_GATT_SUBSCRIBE_FAILED.AsInteger():
      64            1 :         desc = "GATT subscribe operation failed";
      65            1 :         break;
      66            1 :     case BLE_ERROR_GATT_UNSUBSCRIBE_FAILED.AsInteger():
      67            1 :         desc = "GATT unsubscribe operation failed";
      68            1 :         break;
      69            1 :     case BLE_ERROR_GATT_WRITE_FAILED.AsInteger():
      70            1 :         desc = "GATT write characteristic operation failed";
      71            1 :         break;
      72            1 :     case BLE_ERROR_GATT_INDICATE_FAILED.AsInteger():
      73            1 :         desc = "GATT indicate characteristic operation failed";
      74            1 :         break;
      75            1 :     case BLE_ERROR_CHIPOBLE_PROTOCOL_ABORT.AsInteger():
      76            1 :         desc = "BLE transport protocol fired abort";
      77            1 :         break;
      78            1 :     case BLE_ERROR_REMOTE_DEVICE_DISCONNECTED.AsInteger():
      79            1 :         desc = "Remote device closed BLE connection";
      80            1 :         break;
      81            1 :     case BLE_ERROR_APP_CLOSED_CONNECTION.AsInteger():
      82            1 :         desc = "Application closed BLE connection";
      83            1 :         break;
      84            1 :     case BLE_ERROR_NOT_CHIP_DEVICE.AsInteger():
      85            1 :         desc = "BLE device doesn't seem to support chip";
      86            1 :         break;
      87            1 :     case BLE_ERROR_INCOMPATIBLE_PROTOCOL_VERSIONS.AsInteger():
      88            1 :         desc = "Incompatible BLE transport protocol versions";
      89            1 :         break;
      90            1 :     case BLE_ERROR_INVALID_FRAGMENT_SIZE.AsInteger():
      91            1 :         desc = "Invalid fragment size";
      92            1 :         break;
      93            1 :     case BLE_ERROR_START_TIMER_FAILED.AsInteger():
      94            1 :         desc = "Start timer failed";
      95            1 :         break;
      96            1 :     case BLE_ERROR_CONNECT_TIMED_OUT.AsInteger():
      97            1 :         desc = "Connect handshake timed out";
      98            1 :         break;
      99            1 :     case BLE_ERROR_RECEIVE_TIMED_OUT.AsInteger():
     100            1 :         desc = "Receive handshake timed out";
     101            1 :         break;
     102            1 :     case BLE_ERROR_INVALID_MESSAGE.AsInteger():
     103            1 :         desc = "Invalid message";
     104            1 :         break;
     105            1 :     case BLE_ERROR_FRAGMENT_ACK_TIMED_OUT.AsInteger():
     106            1 :         desc = "Message fragment acknowledgement timed out";
     107            1 :         break;
     108            1 :     case BLE_ERROR_KEEP_ALIVE_TIMED_OUT.AsInteger():
     109            1 :         desc = "Keep-alive receipt timed out";
     110            1 :         break;
     111            1 :     case BLE_ERROR_NO_CONNECT_COMPLETE_CALLBACK.AsInteger():
     112            1 :         desc = "Missing required callback";
     113            1 :         break;
     114            1 :     case BLE_ERROR_INVALID_ACK.AsInteger():
     115            1 :         desc = "Received invalid BLE transport protocol fragment acknowledgement";
     116            1 :         break;
     117            1 :     case BLE_ERROR_REASSEMBLER_MISSING_DATA.AsInteger():
     118            1 :         desc = "BLE message reassembler did not receive enough data";
     119            1 :         break;
     120            1 :     case BLE_ERROR_INVALID_BTP_HEADER_FLAGS.AsInteger():
     121            1 :         desc = "Received invalid BLE transport protocol header flags";
     122            1 :         break;
     123            1 :     case BLE_ERROR_INVALID_BTP_SEQUENCE_NUMBER.AsInteger():
     124            1 :         desc = "Received invalid BLE transport protocol sequence number";
     125            1 :         break;
     126            1 :     case BLE_ERROR_REASSEMBLER_INCORRECT_STATE.AsInteger():
     127            1 :         desc = "BLE message reassembler received packet in incorrect state";
     128            1 :         break;
     129              :     }
     130              : #endif // !CHIP_CONFIG_SHORT_ERROR_STR
     131              : 
     132           27 :     FormatError(buf, bufSize, "Ble", err, desc);
     133              : 
     134           27 :     return true;
     135              : }
     136              : 
     137              : } /* namespace Ble */
     138              : } /* namespace chip */
        

Generated by: LCOV version 2.0-1