RDSDeviceCmd.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. //
  2. // RDSDeviceCmd.h
  3. // RuiZhi
  4. //
  5. // Created by Rayson on 2020/6/12.
  6. // Copyright © 2020 RDIOT. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. typedef NS_ENUM(NSUInteger, RDSMsgType) {
  10. MsgDevicePairing = 0x81,// 配对
  11. MsgModel = 0x82, // 模式修改
  12. MsgRecordForNum = 0x83, // 设备记录
  13. MsgDelRecord = 0x84, // 删除记录
  14. //MsgHeartbeat = 0x85,
  15. MsgModelReported = 0x86, // 模式上报
  16. MsgTempReported = 0x87, // 记录上报
  17. MsgChangeTempUnit = 0x88, // 切换温度单位 华氏度摄氏度
  18. MsgArchiveRecord = 0x89, // 设备记录个数
  19. MsgUnbindDevice = 0x8d, // 解绑设备配对
  20. MsgOtaNotify = 0x10, // 设备进行固件升级,APP在此期间不需要向设备发送心跳
  21. };
  22. typedef NS_ENUM(NSUInteger, RDSBindStep) {
  23. Step1 = 0x01, // 设备等待wifi信息
  24. Step2 = 0x02, // 正在连接wifi
  25. Step3 = 0x03, // 注册设备中
  26. Step4 = 0x04, // 注册房间中
  27. Step5 = 0x05, // 配网完成
  28. };
  29. @class RDSDeviceReply, RDSTempRecord;
  30. typedef void(^RDSCmdReceiveCmdFinish)(RDSDeviceReply *reply);
  31. @interface RDSDeviceCmd : NSObject
  32. @property (nonatomic, copy) NSString *header;
  33. @property (nonatomic, copy) NSString *leng;
  34. @property (nonatomic, copy) NSString *cmd;
  35. @property (nonatomic, copy) NSString *sn;
  36. @property (nonatomic, copy) NSString *content;
  37. @property (nonatomic, copy) NSString *checksum;
  38. // 接收 解析设备回复
  39. @property (nonatomic, assign) RDSMsgType msgType;
  40. @property (nonatomic, strong) RDSDeviceReply *reply; // 用通知发送
  41. @property (nonatomic, copy) void(^onReceiveCmdFinish)(RDSDeviceReply *reply);
  42. #pragma mark - 给设备发送指令
  43. #pragma mark - 解析接收设备指令
  44. +(void) rds_receiveData:(NSData *)data finish:(RDSCmdReceiveCmdFinish)finish;
  45. @end
  46. @interface RDSDeviceReply : NSObject
  47. @property (nonatomic, strong) NSString *msg;
  48. @property (nonatomic, assign) RDSMsgType msgType;
  49. @property (nonatomic, assign) RDSBindStep bindStep;
  50. @property (nonatomic, strong) NSString *deviceCode;
  51. @property (nonatomic, assign) int code;
  52. @end