zoukankan      html  css  js  c++  java
  • Nordic Bluetooth 切换到DFU Mode

      转义Nordic文档:关于如何切换BLE如何切换到DFU Mode。

      下面的流程图展示了如何将蓝牙切换到DFU Mode:

     

      如图所示,需要满足两个条件:

      1)打开中央设备的notificaton功能(即订阅notify的characteristic)

      2)给设备发送Start DFU命令:0x01xx(xx取值为01 SoftDevice/02 Bootloader/03 SoftDevice Bootloader/04 Application),一般使用0x0104就好。

      Xamarin.Form示例代码如下:

      

    var notifyDFUCharacter = await DFUservice.GetCharacteristicAsync(Guid.Parse(Rlm1BleControlPointCharUuid));
                    notifyDFUCharacter.ValueUpdated += ((o, args) =>
                    {
                        var bytes = args.Characteristic.Value;
                        string text = "";
                        for (int i = 0; i < bytes.Length; i++)
                        {
                            text += ($"0x{bytes[i].ToString("X2")},");
                        }
                        Debug.WriteLine($"**********DFU {text.TrimEnd(',')} notify");
    
                        Rlm1DFUNotifyHandel(DFUservice, bytes);
                    });
                    await notifyDFUCharacter.StartUpdatesAsync();
    
                        //4 switch to DFU mode
                        await Task.Delay(5 * 100);
                        const byte opCodeStartDfu = 0x01;
                        const byte imageType = 0x04;
    
                        var writeDFUCharacter = await DFUservice.GetCharacteristicAsync(Guid.Parse(Rlm1BleControlPointCharUuid));
                        await writeDFUCharacter.WriteAsync(new byte[] { opCodeStartDfu, imageType });
                    
    

      

  • 相关阅读:
    纸牌游戏----小猫钓鱼
    数据结构-----栈
    浅谈队列
    排序算法实例
    排序算法之------快速排序
    排序算法之----冒泡排序
    Visual Studio-基本使用
    C++-GUID from string
    OS-Windows CMD生成文件夹目录结构
    OS-Windows10 DownLoad
  • 原文地址:https://www.cnblogs.com/zuimengaitianya/p/15338789.html
Copyright © 2011-2022 走看看