Files
ifish/Ifish/models/wifiModel/sendmaseegemodel/appLogin.m
T
2017-08-15 16:59:01 +08:00

56 lines
1.7 KiB
Objective-C

//
// appLogin.m
// Ifish
//
// Created by imac on 15/10/13.
// Copyright © 2015年 imac. All rights reserved.
//
#import "appLogin.h"
#include "dataContorl.h"
@implementation appLogin
- (NSString *)description
{
NSDate * senddate=[NSDate date];
NSCalendar*cal=[NSCalendar currentCalendar];
NSUInteger unitFlages=NSDayCalendarUnit|NSMonthCalendarUnit|NSYearCalendarUnit;
NSDateComponents*conpnent=[cal components:
unitFlages fromDate:senddate];
NSInteger year=[conpnent year];
NSInteger month=[conpnent month];
NSInteger day=[conpnent day];
// 小于十时 day 或小于十月 前加零
if (day<10) {
if (month<10) {
self.dateString=[NSString stringWithFormat:@"%ld0%ld0%ld",(long)year,(long)month,(long)day];
}else{
self.dateString=[NSString stringWithFormat:@"%ld%ld0%ld",(long)year,(long)month,(long)day];
}
}else{
// 当 day 大于等于十时
if (month<10) {
self.dateString=[NSString stringWithFormat:@"%ld0%ld%ld",(long)year,(long)month,(long)day];
}else{
self.dateString=[NSString stringWithFormat:@"%ld%ld%ld",(long)year,(long)month,(long)day];
}
}
// 转十六进制
NSString*hextring=[dataContorl hexStringFromString:self.dateString];
self.messagetype=@"00";
self.functionCode=@"00";
self.crc16String=@"0000";// CRC16校验码
self.massagelegth=@"19";
return [NSString stringWithFormat:@"%@%@%@%@%@%@%@",self.messagetype,self.functionCode, self.sendmacId,self.resavemacId,self.massagelegth,hextring,self.crc16String];
}
@end