枚举的测试demo

#include<stdio.h>

typedef enum test_enum
{
    one = 1,
    two
}test_enum;

void test_print(test_enum a)
{
    switch (a)
    {
    case one:
        printf("this is one\n");
        break;
    case two:
        printf("this is two\n");
    default:
        printf("no value match\n");
        break;
    } 
}

int main()
{   
    test_print(1);
    return 0;
}

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
Windows 平台提供了 Bluetooth Test Tools 工具,它包含了多种蓝牙测试的工具和示例代码。以下是在 Windows 10 环境下编写的 C++ 蓝牙测试示例代码,可以作为基础框架进行开发和测试: ```c++ #include <windows.h> #include <bluetoothapis.h> #include <stdio.h> #pragma comment(lib, "Bthprops.lib") int main(){ // 初始化 COM 环境 HRESULT hr = CoInitialize(NULL); if (FAILED(hr)){ printf("Failed to initialize COM environment\n"); return 1; } // 创建 Bluetooth API 对象 BLUETOOTH_FIND_RADIO_PARAMS radioParams = {sizeof(BLUETOOTH_FIND_RADIO_PARAMS)}; HANDLE hRadio = NULL; HBLUETOOTH_RADIO_FIND hFind = BluetoothFindFirstRadio(&radioParams, &hRadio); if (hFind == NULL){ printf("Failed to find Bluetooth radio\n"); CoUninitialize(); return 1; } // 枚举配对设备列表 BLUETOOTH_DEVICE_SEARCH_PARAMS searchParams = {sizeof(BLUETOOTH_DEVICE_SEARCH_PARAMS)}; searchParams.fReturnAuthenticated = TRUE; searchParams.fReturnRemembered = TRUE; searchParams.fReturnConnected = TRUE; searchParams.fIssueInquiry = TRUE; searchParams.cTimeoutMultiplier = 2; HANDLE hDeviceFind = BluetoothFindFirstDevice(&searchParams, &bthDevice); if (hDeviceFind == NULL){ printf("Failed to find Bluetooth device\n"); BluetoothFindRadioClose(hFind); CoUninitialize(); return 1; } // 枚举服务列表 BLUETOOTH_DEVICE_INFO deviceInfo = {sizeof(BLUETOOTH_DEVICE_INFO)}; deviceInfo.Address = bthDevice.Address; deviceInfo.ulClassofDevice = bthDevice.ulClassofDevice; HBLUETOOTH_AUTHENTICATION_REGISTRATION hAuth = BluetoothRegisterForAuthentication(&deviceInfo, &pbthOobData, &hRegHandle, NULL); if (hAuth == NULL){ printf("Failed to register for Bluetooth authentication\n"); BluetoothFindDeviceClose(hDeviceFind); BluetoothFindRadioClose(hFind); CoUninitialize(); return 1; } // 关闭资源 BluetoothUnregisterAuthentication(hAuth, hRegHandle); BluetoothFindDeviceClose(hDeviceFind); BluetoothFindRadioClose(hFind); CoUninitialize(); return 0; } ``` 这段代码主要实现了以下功能: 1. 初始化 COM 环境。 2. 枚举蓝牙设备列表。 3. 枚举配对设备列表。 4. 枚举服务列表。 5. 关闭资源。 需要注意的是,以上示例代码仅作为基础框架参考,具体实现需要根据具体需求进行修改和扩展。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

秃秃秃秃哇

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值