LSUDPDataDetail 0.0.6

LSUDPDataDetail 0.0.6

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布上次发布2016年12月

Maintained by CoderLSWang.



  • CoderLSWang

一个框架,使用一行代码解决 UDP 或 TCP 通信时十六进制、十进制、NSData 等数据转换问题的工具类库。

这是一个在 UDP 或 TCP 通信时,在 16 进制、10 进制、NSData 等数据之间的转换发送等工具处理类库。

UDP 指令中包含通信的地址、设备 Id、发送的数据等具体指令协议解读, 请查看 Demo,或者查阅 我的博客

image image

一. 安装

  • CocoaPods:pod 'LSUDPDataDetail'
  • 手动导入:将 LSUDPDataDetail 文件夹拖入项目中,导入头文件:#import "LSUDPDataDetail.h"

二. 例子

//指令的发送
- (void)sendCombustibleGasCommand
{
    //address:333333333333333303d0
    //Node address of the smart devices and sensors is not binding, if a sensor node chassis changed, then the sensor's address has changed
    //智能设备中的节点地址和传感器不是绑定一起的,如果某个传感器的节点底盘换了,那么这个传感器的地址也换了,所以这里是动态的

    NSString *addressHexStr = @"333333333333333303d0";
    NSData *addressData = [LSUDPDataDetail commandByteDataFromHexString:addressHexStr];
    [self combustibleGasCommandData:addressData];

}

//The data of nodes will coming here , if u want to control node (smart home/sensor), u need to get the address of the node (device).This address is get from here.And sensor data is also get from here.
//节点发过来的数据都会来到这里,控制节点(智能家居/传感器)需要拿到节点的地址(设备刚入网的时候),便是在这里获取。读取传感器发过来的采集到的数据也是在这里获取

- (void)udpSocket:(GCDAsyncUdpSocket *)sock didReceiveData:(NSData *)data
fromAddress:(NSData *)address
withFilterContext:(nullable id)filterContext
{

    //Selection of sensors, when the equipment send collectd data / 设备发送来采集的数据时,对传感器的甄选

    NSString *commandHexStr = [LSUDPDataDetail getHexStringFromData:data withRange:NSMakeRange(2, 6)];
    if ([commandHexStr isEqualToString:@"545243"]) {//TRC :The command header / 命令头
    NSLog(@"dataHexStr = %@",dataHexStr);
    }

}

三. 要求

iOS7及以上系统可使用. ARC环境.

四. 更多

如果你发现了一个 bug,请创建一个 issue。
欢迎提出 pull requests。
更多详细信息请查看 demo。
如果你发现了 bug,请提一个 issue。
欢迎给我提 pull requests。