iphone – iOS蓝牙LE peripheralManager didReceiveWriteRequests的例子

iphone – iOS蓝牙LE peripheralManager didReceiveWriteRequests的例子,第1张

概述我需要一个函数didReceiveWriteRequests的示例实现,当中央iOS设备写入’writeValue:’时,它会在蓝牙iOS外设上运行. 但我搜索网络,找不到例子. Apple文档仍然没有示例代码. 我搞定了.这是我的工作代码: // Processes write command received from a central.- (void)peripheralManager: 我需要一个函数dIDReceiveWriteRequests的示例实现,当中央iOS设备写入’writeValue:’时,它会在蓝牙iOS外设上运行.

但我搜索网络,找不到例子. Apple文档仍然没有示例代码.

解决方法 我搞定了.这是我的工作代码:

// Processes write command received from a central.- (voID)peripheralManager:(CBPeripheralManager *)peripheral dIDReceiveWriteRequests:(NSArray *)requests{    CBATTRequest*       request = [requests  objectAtIndex: 0];    NSData*             request_data = request.value;    CBCharacteristic*   write_char = request.characteristic;    //CBCentral*            write_central = request.central;    //NSUInteger            multi_message_offset = request.offset;    // Face commands this PWR RX to advertise serno UUID?    int total_write_requests = 0;    if([ write_char.UUID isEqual: [CBUUID UUIDWithString: YOUR_CHaraCTERISTIC_UUID]] )    {        // Read desired new_state data from central:        unsigned char* new_state = (unsigned char*)[request_data   bytes];        my_new_state = new_state[0];        #endif        NSLog(@"        - advertise serno UUID: %s",my_new_state ? "TRUE" : "FALSE" );        // Select UUID that includes serno of PWR RX,for advertisements:        ++total_write_requests;    }    if( total_write_requests )        [peripheral respondToRequest:request    withResult:CBATTErrorSuccess];  // result = success    else    {        NSLog(@"_no_write_request_FAulT !!");    }}
总结

以上是内存溢出为你收集整理的iphone – iOS蓝牙LE peripheralManager didReceiveWriteRequests的例子全部内容,希望文章能够帮你解决iphone – iOS蓝牙LE peripheralManager didReceiveWriteRequests的例子所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1060457.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存