当前位置: 首页 > news >正文

网站后台账户密码17做网店这个网站做起多少钱

网站后台账户密码,17做网店这个网站做起多少钱,1688网站首页,大型大型网站制作WiFi通信是指手机通过WiFi与外部设备建立连接#xff0c;并与外部设备进行交互、通信。手机与外部设备的WiFi通信通常是使用Socket来实现的#xff0c;在这里先介绍一个第三方Socket库#xff08;CocoaAsyncSocket#xff09;来实现WiFi通信。 CocoaAsyncSocket支持TCP和U…WiFi通信是指手机通过WiFi与外部设备建立连接并与外部设备进行交互、通信。手机与外部设备的WiFi通信通常是使用Socket来实现的在这里先介绍一个第三方Socket库CocoaAsyncSocket来实现WiFi通信。 CocoaAsyncSocket支持TCP和UDP其中 AsyncSocket类是支持TCP的 AsyncUdpSocket类是支持UDP的。 本文是建立在硬件通过UDP广播包广播自身信息手机与硬件之间通过TCP连接传输数据。 WiFi连接的建立 首先通过手动连接手机WiFi至外部设备此时可以获取到外部WiFi的一些信息 #import UIKit/UIKit.hinterface ViewController : UIViewControllertypedef void (^udpSocketBlock)(NSDictionary* dic,NSError* err);// block用于硬件返回信息的回调 property (nonatomic,copy) udpSocketBlock udpSocketBlock; - (void)sendUdpBoardcast:(udpSocketBlock)block; end #import ViewController.h #import AsyncSocket.h #import AsyncUdpSocket.h interface ViewController ()AsyncSocketDelegate,AsyncUdpSocketDelegate property (nonatomic,strong) AsyncUdpSocket *udpSocket; property (nonatomic,strong) AsyncSocket *socket; endimplementation ViewController- (void)viewDidLoad {[super viewDidLoad]; }- (void)sendUdpBoardcast:(udpSocketBlock)block{self.udpSocketBlock block;if(!_udpSocket)_udpSocket [[AsyncUdpSocket alloc] initWithDelegate:self];NSData *data [NSData data];// 此处data是根据硬件要求传参数UInt16 port 34343;// 此处具体指需询问硬件工程师[self.udpSocket enableBroadcast:YES error:NULL];[_udpSocket sendData:data toHost:255.255.255.255 port:port withTimeout:-1 tag:0];// 因为不知道具体的ip地址所以host采用受限广播地址 } - (BOOL)onUdpSocket:(AsyncUdpSocket *)sock didReceiveData:(NSData *)data withTag:(long)tag fromHost:(NSString *)host port:(UInt16)port{ // data 接收到的外部设备返回的数据id result [self unpackageMessage:data]; // 对数据进行处理此处调用的 - (id)unpackageMessage:(NSData *)data ;是根据与硬件方面协商的数据格式进行的数据处理if ([[result valueForJSONKey:typeid] isEqualToString:xxxx]) {self.udpSocketBlock([result valueForJSONKey:data],nil);} // 判断的到的数据是否为我们需要的数据return YES; // 发现设备后则关闭发现通道return NO; // 不关闭发现通道一直处于发现状态 } #pragma mark - udpSocket -(void)onUdpSocket:(AsyncUdpSocket *)sock didSendDataWithTag:(long)tag{} 通过调用该方法可以得到外部设备返还的WiFi信息 [self sendUdpBoardcast:^(NSDictionary *dic, NSError *err) {// dic为硬件返回的参数 }]; 获取硬件参数之后需要确认手机是否已于硬件连接直接调用方法 - (BOOL)isConnected; 若未连接则需建立手机和硬件之间的socket连接 - (BOOL)connectToHost:(NSString*)hostname onPort:(UInt16)port error:(NSError **)errPtr; // hostname、port均为硬件返回的 数据的写入和读取 CocoaAsyncSocket提供了写入数据和读取数据的方法 // 数据的写入 - (void)writeData:(NSData *)data withTimeout:(NSTimeInterval)timeout tag:(long)tag; // 数据的读取 - (void)readDataWithTimeout:(NSTimeInterval)timeout tag:(long)tag; 数据写入具体格式需要根据硬件要求来决定这里提供几种常用的数据类型转换方法以供参考 十六进制字符串转NSData -(NSData *)converHexStrToData:(NSString *)hexString {NSMutableData *data [[NSMutableData alloc] init];unsigned char whole_byte;char byte_chars[3] {\0,\0,\0};if (hexString.length%2) {//防止丢失半个bytehexString [0 stringByAppendingString:hexString];}int i;for (i 0; i [hexString length]/2; i) {byte_chars[0] [hexString characterAtIndex:i * 2];byte_chars[1] [hexString characterAtIndex:i * 2 1];whole_byte strtol(byte_chars, NULL, 16);[data appendBytes:whole_byte length:1];}return data; } NSData转十六进制字符串 -(NSString *) converDataToHexString:(NSData *)data {if (data nil) {return nil;}NSMutableString* hexString [NSMutableString string];const unsigned char *p [data bytes];for (int i0; i [data length]; i) {[hexString appendFormat:%02x, *p];}return hexString; } 十六进制字符串转普通字符串 -(NSString *)stringFromHexString:(NSString *)hexString {char *myBuffer (char *)malloc((int)[hexString length] / 2 1);bzero(myBuffer, [hexString length] / 2 1);for (int i 0; i [hexString length] - 1; i 2) {unsigned int anInt;NSString * hexCharStr [hexString substringWithRange:NSMakeRange(i, 2)];NSScanner * scanner [[NSScanner alloc] initWithString:hexCharStr];[scanner scanHexInt:anInt];myBuffer[i / 2] (char)anInt;}NSString *unicodeString [NSString stringWithCString:myBuffer encoding:4];return unicodeString; }
http://www.huolong8.cn/news/68544/

相关文章:

  • 领手工在家做的网站在线做任务的网站
  • 哈尔滨市建设安全网站网络营销渠道和传统营销渠道的区别
  • 郑州网站设计制作软件界面设计工具下载
  • 网站的栏目和版块设计的原则网站积分商城该怎么建立
  • 网站开发技术三大件欧莱雅采用了哪些网络营销方式
  • 百度蜘蛛站长服务平台搜索引擎推广策略
  • 网站开发工程师获奖中国拟在建项目网官网
  • 淘宝网站建设的目标是什么文案转行做网站编辑
  • 网站推广做招商加盟前端官网模板
  • 高淳做网站价格广州微网站建设平台
  • 医疗网站建设及优化国内最新新闻大事
  • 网站后台制作表格谷歌优化师
  • 做电子章网站php多用户商城双端app
  • 重庆泡笋制作seo报名在线咨询
  • 阳江市住房和城乡规划建设局网站wordpress插件汉化下载
  • 网站群建设调研报告建设个人购物网站
  • 莆田网站制作软件短网址源码wordpress
  • 建设网站需要的配置链接怎么做
  • 买一个软件大概多少钱网站运营优化建议
  • 北京网站的网站建设公司seo网站关键词排名优化
  • 建设网站的目标和作用织梦单页面网站模板
  • 太原网站建设策划方案服务类网站模板
  • 怎么给网站设置关键字电销外呼系统多少钱一个月
  • 上海网站建设排名太原做网站推广的公司
  • 萧山网站制作公司电脑做ppt一般下载哪个网站好
  • 网络广告策划的概念烟台网站排名优化费用
  • 又好又快自助建站免费的海报模板网站
  • 空间网站潍坊最近最新消息
  • 网站建设会出现的问题海报生成器
  • 电子商务网站建设基本组成前端网站怎么做