获取蓝牙低功耗 (BLE) 设备通知的步骤是什么?

2024-01-02

我正在开发蓝牙低功耗 (BLE) 应用程序。我有一个测量体重的 BLE 设备(秤)。我能够连接该设备。但我不知道如何从中读取数据(重量值)。

我想知道我的应用程序是否连接到任何 BLE 设备,那么要通过哪些步骤获得设备通知才能获取更新的数据。

好的,以下是我正在使用的活动。

public class BlogBLEActivity extends Activity implements OnItemClickListener
{
    private final static String TAG = BlogBLEActivity.class.getSimpleName();

    private BluetoothAdapter bluetoothAdapter;
    BluetoothManager bluetoothManager;

    boolean hasBleFeature = false;

    TextView tvMessage;
    int messageId = R.string.doesnt_support_ble;
    int colorId = android.R.color.holo_red_light;

    private boolean mScanning;
    private Handler handler = new Handler();

    private static final long SCAN_PERIOD = 10000;
    private static final int REQUEST_ENABLE_BT = 1209;

    ListView listView;
    ArrayList<BluetoothDevice> listDevices;

    BleDeviceAdapter bleDeviceAdapter;

    TextView tvHumidity;
    TextView tvTemperature;
    TextView tvPressure;

    boolean isConnected = false;

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.blog_ble);

        initParameters();
        initViews();

        scanLeDevice(true);
    }

    @SuppressLint("NewApi")
    void initParameters()
    {
        hasBleFeature = getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE);
        Log.i(TAG, "hasBleFeature : " + hasBleFeature);

        if (hasBleFeature)
        {
            messageId = R.string.supports_ble;
            colorId = android.R.color.holo_blue_light; 
        } else
        {
            messageId = R.string.doesnt_support_ble;
            colorId = android.R.color.holo_red_light;
        }

        bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
        bluetoothAdapter = bluetoothManager.getAdapter();// BluetoothAdapter.getDefaultAdapter();

        if (bluetoothAdapter == null || !bluetoothAdapter.isEnabled())
        {
            Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
            startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
        }

        listDevices = new ArrayList<BluetoothDevice>();
        bleDeviceAdapter = new BleDeviceAdapter(this, listDevices);
    }

    void initViews()
    {
        tvHumidity = (TextView) findViewById(R.id.blog_ble_tv_humidity);
        tvTemperature = (TextView) findViewById(R.id.blog_ble_tv_temprature);
        tvPressure = (TextView) findViewById(R.id.blog_ble_tv_pressure);

        tvMessage = (TextView) findViewById(R.id.blog_ble_tv_message);
        tvMessage.setText(getResources().getString(messageId));
        tvMessage.setTextColor(getResources().getColor(colorId));

        listView = (ListView) findViewById(R.id.blog_ble_list_view);
        listView.setAdapter(bleDeviceAdapter);
        listView.setOnItemClickListener(this);
    }

    @SuppressLint("NewApi")
    void scanLeDevice(final boolean enable)
    {
        if (enable)
        {
            handler.postDelayed(new Runnable()
            {
                @SuppressLint("NewApi")
                @Override
                public void run()
                {
                    mScanning = false;
                    bluetoothAdapter.stopLeScan(leScanCallback);
                }
            }, SCAN_PERIOD);

            mScanning = false;
            bluetoothAdapter.startLeScan(leScanCallback);
        } else
        {
            mScanning = false;
            bluetoothAdapter.stopLeScan(leScanCallback);
        }
    }

    @SuppressLint("NewApi")
    private BluetoothAdapter.LeScanCallback leScanCallback = new BluetoothAdapter.LeScanCallback()
    {
        @Override
        public void onLeScan(final BluetoothDevice device, int rssi, byte[] scanRecord)
        {
            runOnUiThread(new Runnable()
            {
                @Override
                public void run()
                {
                    if (device != null)
                    {
                        bleDeviceAdapter.add(device);
                        bleDeviceAdapter.notifyDataSetChanged();
                    }
                }
            });
        }
    };

    class BleDeviceAdapter extends ArrayAdapter<BluetoothDevice>
    {
        public BleDeviceAdapter(Context context, List<BluetoothDevice> objects)
        {
            super(context, R.layout.row_ble_device, R.id.row_ble_device_tv_name, objects);
        }

        @SuppressLint("NewApi")
        @Override
        public View getView(int position, View convertView, ViewGroup parent)
        {
            View row = super.getView(position, convertView, parent);
            ViewHolder holder = (ViewHolder) row.getTag();
            if (holder == null)
            {
                holder = new ViewHolder(row);
                row.setTag(holder);
            }

            BluetoothDevice device = getDevice(position);
            holder.tvName.setText("" + device.getName());

            Log.i(TAG, "" + device.getName());
            return row;
        }
    }

    BluetoothDevice getDevice(int position)
    {
        return (BluetoothDevice) listView.getAdapter().getItem(position);
    }

    @SuppressLint("NewApi")
    @Override
    public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3)
    {
        BluetoothDevice device = getDevice(position);
        Toast.makeText(this, "" + device.getName(), Toast.LENGTH_SHORT).show();
        BluetoothGatt connectGatt = device.connectGatt(this, false, mGattCallback);

    }

    /* Client Configuration Descriptor */
    private static final UUID CONFIG_DESCRIPTOR = UUID.fromString("00002902-0000-1000-8000-00805f9b34fb");

    private static final UUID KITCHEN_SCALE_SERVICE = UUID.fromString("0000780a-0000-1000-8000-00805f9b34fb");
    private static final UUID KITCHEN_SCALE_FEATURE_CHAR = UUID.fromString("00008aa0-0000-1000-8000-00805f9b34fb");
    private static final UUID KITCHEN_SCALE_MEASUREMENT_CHAR = UUID.fromString("00008aa1-0000-1000-8000-00805f9b34fb");
    private static final UUID KITCHEN_SCALE_INTERMEDIATE_CHAR = UUID.fromString("00008aa2-0000-1000-8000-00805f9b34fb");

    /*
     * In this callback, we've created a bit of a state machine to enforce that
     * only one characteristic be read or written at a time until all of our
     * sensors are enabled and we are registered to get notifications.
     */
    @SuppressLint("NewApi")
    private BluetoothGattCallback mGattCallback = new BluetoothGattCallback()
    {

        /* State Machine Tracking */
        private int mState = 0;

        private void reset()
        {
            mState = 0;
        }

        private void advance()
        {
            mState++;
        }

        /*
         * Send an enable command to each sensor by writing a configuration
         * characteristic. This is specific to the SensorTag to keep power low
         * by disabling sensors you aren't using.
         */
        private void enableNextSensor(BluetoothGatt gatt)
        {
            BluetoothGattCharacteristic characteristic;
            switch (mState)
            {
            case 0:
                Log.i(TAG, "Enabling weight scale");
                characteristic = gatt.getService(KITCHEN_SCALE_SERVICE).getCharacteristic(KITCHEN_SCALE_FEATURE_CHAR);
                Log.i(TAG, "Feature Properties : "+characteristic.getProperties());
                characteristic.setValue(new byte[]
                { 0x09 });
                break;

            default:
                mHandler.sendEmptyMessage(MSG_DISMISS);
                Log.i(TAG, "All Sensors Enabled");
                return;
            }

            gatt.writeCharacteristic(characteristic);
        }

        /*
         * Read the data characteristic's value for each sensor explicitly
         */
        private void readNextSensor(BluetoothGatt gatt)
        {
            BluetoothGattCharacteristic characteristic;
            switch (mState)
            {
            case 0:
                Log.i(TAG, "Reading weight cal");
                characteristic = gatt.getService(KITCHEN_SCALE_SERVICE).getCharacteristic(KITCHEN_SCALE_MEASUREMENT_CHAR);
                break;

            default:
                mHandler.sendEmptyMessage(MSG_DISMISS);
                Log.i(TAG, "All Sensors Enabled");
                return;
            }

            gatt.readCharacteristic(characteristic);
        }

        /*
         * Enable notification of changes on the data characteristic for each
         * sensor by writing the ENABLE_NOTIFICATION_VALUE flag to that
         * characteristic's configuration descriptor.
         */
        private void setNotifyNextSensor(BluetoothGatt gatt)
        {
            BluetoothGattCharacteristic characteristic;
            switch (mState)
            {
            case 0:
                Log.i(TAG, "Set notify weight ");
                characteristic = gatt.getService(KITCHEN_SCALE_SERVICE).getCharacteristic(KITCHEN_SCALE_MEASUREMENT_CHAR);
                break;

            default:
                mHandler.sendEmptyMessage(MSG_DISMISS);
                Log.i(TAG, "All Sensors Enabled");
                return;
            }

            // Enable local notifications
            gatt.setCharacteristicNotification(characteristic, true);
            // Enabled remote notifications
            BluetoothGattDescriptor desc = characteristic.getDescriptor(CONFIG_DESCRIPTOR);
            desc.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
            gatt.writeDescriptor(desc);
        }

        @Override
        public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState)
        {
            Log.i(TAG, "Connection State Change: " + status + " -> " + connectionState(newState));
            if (status == BluetoothGatt.GATT_SUCCESS && newState == BluetoothProfile.STATE_CONNECTED)
            {
                /*
                 * Once successfully connected, we must next discover all the
                 * services on the device before we can read and write their
                 * characteristics.
                 */
                gatt.discoverServices();
                mHandler.sendMessage(Message.obtain(null, MSG_PROGRESS, "Discovering Services..."));
            } else if (status == BluetoothGatt.GATT_SUCCESS && newState == BluetoothProfile.STATE_DISCONNECTED)
            {
                /*
                 * If at any point we disconnect, send a message to clear the
                 * weather values out of the UI
                 */

                mHandler.sendEmptyMessage(MSG_CLEAR);
            } else if (status != BluetoothGatt.GATT_SUCCESS)
            {
                /*
                 * If there is a failure at any stage, simply disconnect
                 */
                gatt.disconnect();
            }
        }

        @Override
        public void onServicesDiscovered(BluetoothGatt gatt, int status)
        {
            Log.i(TAG, "Services Discovered: " + status);
            if (status == BluetoothGatt.GATT_SUCCESS)
            {
                Log.i(TAG, "No of services discovered: " + gatt.getServices().size());
                mHandler.sendMessage(Message.obtain(null, MSG_PROGRESS, "No of services discovered: " + gatt.getServices().size()));

                List<BluetoothGattService> services = gatt.getServices();
                for (BluetoothGattService bluetoothGattService : services)
                {
                    UUID uuid = bluetoothGattService.getUuid();
                    Log.e(TAG, ""+uuid.toString());
                    List<BluetoothGattCharacteristic> characteristics = bluetoothGattService.getCharacteristics();
                    for (BluetoothGattCharacteristic bluetoothGattCharacteristic : characteristics)
                    {
                        UUID uuidC = bluetoothGattCharacteristic.getUuid();
                        Log.i(TAG, "Gatt Properties : "+bluetoothGattCharacteristic.getProperties());
                        Log.i(TAG, ""+uuidC.toString());
                        CharacteristicHelper helper = new CharacteristicHelper(bluetoothGattCharacteristic);
                        Log.i(TAG, "isRead : "+helper.isRead());
                        Log.i(TAG, "isWrite : "+helper.isWrite());
                        Log.i(TAG, "isNotify : "+helper.isNotify());
                        Log.i(TAG, "isWriteNoResponse : "+helper.isWriteNoResponse());
                    }
                }
            }
            // mHandler.sendMessage(Message.obtain(null, MSG_PROGRESS,
            // "Enabling Sensors..."));
            /*
             * With services discovered, we are going to reset our state machine
             * and start working through the sensors we need to enable
             */
             reset();
             enableNextSensor(gatt);
        }

        @Override
        public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status)
        {
            Log.i(TAG, "onCharacteristicRead");
            // For each read, pass the data up to the UI thread to update the
            // display
            /**methodToUpdateUI().*/

            // After reading the initial value, next we enable notifications
            setNotifyNextSensor(gatt);
        }

        @Override
        public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status)
        {
            Log.i(TAG, "onCharacteristicWrite");
            // After writing the enable flag, next we read the initial value
            readNextSensor(gatt);
        }

        @Override
        public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic)
        {
            Log.i(TAG, "onCharacteristicChanged");
            /*
             * After notifications are enabled, all updates from the device on
             * characteristic value changes will be posted here. Similar to
             * read, we hand these up to the UI thread to update the display.
             */
        }

        @Override
        public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status)
        {
            Log.i(TAG, "onDescriptorWrite");
            // Once notifications are enabled, we move to the next sensor and
            // start over with enable
            advance();
            enableNextSensor(gatt);
        }

        @Override
        public void onReadRemoteRssi(BluetoothGatt gatt, int rssi, int status)
        {
            Log.i(TAG, "Remote RSSI: " + rssi);
        }

        private String connectionState(int status)
        {
            switch (status)
            {
            case BluetoothProfile.STATE_CONNECTED:
                return "Connected";
            case BluetoothProfile.STATE_DISCONNECTED:
                return "Disconnected";
            case BluetoothProfile.STATE_CONNECTING:
                return "Connecting";
            case BluetoothProfile.STATE_DISCONNECTING:
                return "Disconnecting";
            default:
                return String.valueOf(status);
            }
        }
    };

    /*
     * We have a Handler to process event results on the main thread
     */
    private static final int MSG_PROGRESS = 201;
    private static final int MSG_DISMISS = 202;
    private static final int MSG_CLEAR = 301;
    private Handler mHandler = new Handler()
    {
        @SuppressLint("NewApi")
        @Override
        public void handleMessage(Message msg)
        {
            BluetoothGattCharacteristic characteristic;
            switch (msg.what)
            {
            case MSG_PROGRESS:
                tvMessage.setText((String) msg.obj);
                break;
            case MSG_DISMISS:
                tvMessage.setText("Service Enabled");
                break;
            case MSG_CLEAR:
                tvMessage.setText("");
                break;
            }
        }
    };
}

在我的活动中,首先我正在扫描所有可用设备并准备 ListView。单击列表项后,我连接到该特定设备。当设备状态变为已连接时,我就会发现服务。我有设备服务及其特征的 UUID。但我不确定如何写入任何特定特征或启用或从中读取数据。 虽然我已经尝试过这个事情,但我没有看到任何成功。

如果有人对此有任何想法,请帮助我。


有一个需要我使用的设备

descriptor.setValue(BluetoothGattDescriptor.ENABLE_INDICATION_VALUE)

代替

descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE)

正如这个问题所解释的

Android BLE API:未收到 GATT 通知 https://stackoverflow.com/questions/17910322/android-ble-api-gatt-notification-not-received

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

获取蓝牙低功耗 (BLE) 设备通知的步骤是什么? 的相关文章

  • 通过附加上下文改进 Android 语音识别

    据我了解 Android API 使用谷歌语音识别服务进行语音转文本 我已经学习了 API 我发现它非常简单 只需将语音转换为单词数组即可 有什么方法可以提高识别率 我的意思是 如果我知道上下文 我可以向服务发送一些参数以提高识别率吗 或者
  • 如何获取存储在MySQL中的经纬度位置并在Android地图应用程序中使用它

    我试图获取存储在 MySQL 中的纬度和经度位置 我想将这些值用于我的 Android 地图应用程序 这是我的代码 Java脚本 Button direction Button findViewById R id btnDir direct
  • 两个 ListView 和 ScrollView

    我离这里很近 我已经尝试了很多东西 但无法让它发挥作用 我这里有两个列表视图 我想要的是每个列表视图显示其全部内容 我不希望列表视图可滚动 我想要保持列表视图可滚动的滚动视图 我能得到的最接近的结果 这是错误的 是每个列表视图都是可滚动的
  • 为什么 BLE 4.2 比 BLE 4.1 更快

    我已阅读技术规范 并试图了解为什么 BLE 4 2 比 BLE 4 1 更快 我们能否发送大于 20 字节的数据包 或者连接间隔是否更快 我试图了解是什么让 BLE 4 2 更快 与早期相比 蓝牙 4 2 中唯一提供更高吞吐量的是链路层的长
  • 如何每分钟运行一次BroadcastReceiver?

    我正在开发一个应用程序来每分钟监控网络 我正在为此使用广播接收器 我想每分钟后执行一次 BroadcastReceiver 我该怎么做 我可以在 BroadcastReceiver 中使用 Thread sleep 吗 在android中持
  • 将 HTML5 转换为独立的 Android 应用

    我有一个动态HTML5不包含任何外部资源的文档 文档内没有编码图像 CSS 和脚本 这个 HTML5 应用程序在互联网浏览器上运行良好 我想知道是否有可能convert this HTML5 应用程序转换成独立的 Android 应用程序
  • 有多少用户获得了更新的应用版本

    我最近将新版本的 Android 应用程序推送到了 Play 商店 并想看看有多少用户已经成功获取更新 似乎有关于 Android 版本和正在使用的设备的统计数据 但我似乎无法找到有关我的用户正在使用的应用程序版本的任何信息 Go to h
  • Recyclerview 和处理不同类型的行膨胀

    我正在尝试与新的工作RecyclerView 但我找不到一个例子RecyclerView不同类型的行 卡片视图变得膨胀 With ListView我覆盖getViewTypeCount and getItemViewType 用于处理不同类
  • 从android中的另一个广播接收器注册广播接收器

    目前我有广播接收器用于监听呼叫状态事件 我已经注册了广播接收器AndroidManifest xml如下所示
  • Android 上的 setTimeOut() 相当于什么?

    我需要等效的代码setTimeOut call function milliseconds 对于安卓 setTimeOut call function milliseconds 您可能想查看定时任务 http developer andro
  • 使用 notificationManager.getActiveNotifications() 获取状态栏通知

    我正在使用以下方式获取所有状态栏通知notificationManager getActiveNotifications 但它只是返回应用程序锁定的通知 每当在什么应用程序或任何其他应用程序中发生通知时 此功能不会向我提供其他应用程序的主动
  • Android Market支持QHD

    使用摩托罗拉 Atrix 4G 无法下载我发布的应用程序并安装在手机上 建议的答案是这样做
  • 如何在 Android 中将 EditText 绘制到画布上?

    我想画画 EditText username new EditText context 到我画布上的特定位置 protected void onDraw Canvas canvas 是否可以在基础上画出x y在我的 Java 文件中协调而不
  • 使用通用图像加载器加载的图像上的黑色背景

    如下所示 第一张图片是链接的默认图片http goldentrail towardstech com assets images membersimage buttons eat png http goldentrail towardste
  • 在 AChartEngine 中单击时突出显示饼图切片

    我想在用户单击时突出显示 更改颜色 饼图特定切片 我可以在示例 下面的代码 中发现可以显示切片的索引和确切的点 但是给切片重新着色怎么样 mChartView setOnClickListener new View OnClickListe
  • 从 RxAndroid 1.x 迁移到 2.x(包括 RxJava)

    我有一个运行 RxAndroid 1 x 的项目 一切正常 我正在尝试迁移到 2 x 版本 我的等级文件 dependencies compile fileTree dir libs include jar compile com andr
  • 方向更改时视图高度/宽度值错误?

    我实现了 onConfigurationChanged 来读取方向配置更改时视图高度和宽度的值 Override public void onConfigurationChanged Configuration newConfig supe
  • 如何限制 Android 设备网络速度以进行测试

    我正在测试一个 Android 应用程序 该应用程序在低质量网络上管理其内容时遇到一些问题 我无法验证问题是否仍然存在 因为以我家的网络速度 120mb s 在我设法开始复制路线之前 所有内容都已经下载完毕 在这种情况下 不能选择使用 An
  • 如何在运行时将元数据信息写入Android Manifest

    我知道可以编辑 Android 清单组件 例如 将其设置为启用 禁用等 我想在运行时将元值标签插入到 Android 清单的应用程序标签中 我怎样才能直接写入android清单 这是我想直接写入我的应用程序的 Android 清单中的字符串
  • 我用 java 7 android studio 替换 java 8 错误?

    为什么我用 JAVA 7 替换 JAVA 8 Android studio 错误 gt Error Error converting bytecode to dex Cause Dex cannot parse version 52 byt

随机推荐

  • django 模板中的 user.is_authenticated 遇到问题

    很抱歉 如果您在我之前问这个问题时尝试帮助我 不得不删除该问题 因为由于某种原因我不被允许编辑其他信息 我正在努力在我的 Django 网站上实现用户身份验证 一切正常 我的视图 模型 url 等都设置好了 用户可以注册 登录 注销 我遇到
  • 将 MarvinFramework 添加到 Tomcat7 上的 Web 应用程序

    我有一个JerseyWeb 应用程序运行于Tomcat并想要整合MarvinFramework用于图像处理 基本上我想减少噪音 灰度和缩放图像以进行进一步处理 The 马文框架 http marvinproject sourceforge
  • Cmder bash脚本执行

    我在 Windows 中创建了基本脚本 bin bash echo Hello 我正在使用 Cmder ConEmu 衍生品 我尝试使用 chmod 更改权限 但它们是相同的 我不知道如何执行这个脚本 正常的 Linux 方式是 hello
  • R 编译错误的 RGL 包

    尝试在 arch linux x86 64 上为 r 编译 rgl 我只复制了安装的错误部分 这是我最近更新 R 后发生的 知道如何解决这个问题吗 g I usr include R DNDEBUG DHAVE PNG H I usr in
  • 按位置列出观测值数量

    这里需要帮助 我正在尝试创建一个新列 使用纬度和经度列出餐厅 200 米范围内的餐厅数量 我在 stackoverflow 上找不到任何东西 而且我不是 R 忍者 任何帮助 将不胜感激 head business id restaurant
  • 带有azure ad的net core使用oidc和登录后浏览器后退按钮导致异常

    因此 我有一个新创建的 netcore 应用程序链接到我的 azure Active Directory 帐户 中间件设置如下 app UseCookieAuthentication new CookieAuthenticationOpti
  • 正确处理 React Hooks 以将摄像机流式传输到 HTML 视频元素

    我一直在尝试编写一个 React Hook 来处理从用户相机捕获的流式视频到 HTML 视频元素 我无法找到处理初始化和取消初始化相机和 HTML 视频元素的最佳方法 我尝试在挂钩末尾添加清理功能 但我的尝试最终导致视频反复重新初始化或出现
  • 使用 Codedom 生成 C# 自动属性

    有没有办法使用 Codedom 生成 C 自动属性or也许我可以使用另一组库 您可以使用 CodeSnippetTypeMember 类来实现此目的 例如 CodeTypeDeclaration newType new CodeTypeDe
  • 了解自动实现的属性

    我有一个使用自动实现属性的简单类 Public Class foo public foo public string BarName get set 显然 我在整个类中使用了变量 BarName 现在需要在设置属性值时添加逻辑 它必须全部大
  • opencv 对象跟踪的边界框定义

    如何定义采用 opencv tracker init 函数的边界框对象 是吗 xcenter ycenter boxwidht boxheight or xmin ymin xmax ymax or ymin xmin ymax xmax
  • 如何在 SwiftUI 中的 ForEach 中嵌入的 HStack 中设置相对宽度?

    我想创建属性列表 不使用列表视图 每个属性都是一个 HStack 其中包含两个文本 名称和值 我希望名称文本始终占整个 HStack 宽度的 30 而值文本则使用其余的水平空间 每个属性的高度取决于内容 我尝试通过以下观点来实现它 stru
  • 与多个包共享全局定义的数据库连接

    我读过一些关于如何处理数据库连接的 StackOverflow 答案 因为它是一个池 所以我们可以全局定义它并在多个 goroutine 中使用它 而且它是安全的 我遇到的问题是我已将 REST API 拆分为多个包 这些包中的每一个都需要
  • 我可以为 PHP 中的 $_POST 变量赋值吗?

    例如 我使用 POST 变量将数据插入数据库 就在这个查询之前 我有一些测试 如果它们是真的 我想调整那个 隐藏的 POST 值 Ex if baby dragon eats children POST hidden value grape
  • 删除锁定的互斥体

    我有一个包含多个资源的程序 需要通过它们自己的互斥锁来锁定 在这个程序中 可能会发生当 mutex for资源A被锁住了 资源A已在另一个线程中删除 以下代码尝试重现我尝试完成的逻辑 include
  • 如何在 JavaScript 中将 JSON 转换为数组

    我想将 JSON 转换为数组 并通过以下方式返回值 控制台 log 数据 值为 data object data object object 所以 我通过以下方式转换为 JSON console log JSON stringify dat
  • 从 Java 1.4 迁移到 Java 1.5+ 时避免 BigDecimal 的问题

    我最近将 Java 1 4 应用程序迁移到 Java 6 环境 不幸的是 我遇到了一个问题BigDecimal存储在Oracle数据库中 总而言之 当我尝试存储 7 65E 7 大十进制值 76 500 000 00 在数据库中 Oracl
  • 在 Java 中将常规日期转换为儒略日期,反之亦然

    我编写了一个简单的代码 将常规日期转换为儒略日期 对于需要相同转换的人来说 这是代码 public int convertToJulian String unformattedDate Unformatted Date ddmmyyyy i
  • 有没有办法直接从 C# 应用程序将文件写入 Azure Blob 存储?

    我正在尝试创建一个新的 C 控制台应用程序 直接从代码写入 blob 存储 我能够创建本地文件并将其上传到 blob 但要求是将内容直接写入 Blob 而不是创建文件并上传到 Blob 我无法实现这一点 我搜索了相关的网络资源 但找不到任何
  • 如何将 Symfony 发行版下载为 Zip 存档?

    我尝试下载 symfony 已有 2 个小时 但找不到可供下载的 zip 文件 我无法在我的网络上使用作曲家 这就是我想要 zip 的原因 我花了很多时间去 symfony 网站上的下载章节 但找不到任何 lts 版本的 zip 只有评估包
  • 获取蓝牙低功耗 (BLE) 设备通知的步骤是什么?

    我正在开发蓝牙低功耗 BLE 应用程序 我有一个测量体重的 BLE 设备 秤 我能够连接该设备 但我不知道如何从中读取数据 重量值 我想知道我的应用程序是否连接到任何 BLE 设备 那么要通过哪些步骤获得设备通知才能获取更新的数据 好的 以