Java实现天猫精灵与智能设备的对接

2023-05-16

       天猫精灵与公司智能设备的对接。刚接到这个任务的时候对于一个刚毕业一个月的应届生我来说,有点像巨石,不过经历了10多天的自己琢磨,还是终于把这个新东西搞出来了。楼主是学的java,但在查询相关文章的时候发现没有一篇是用java实现的。所以在这里写一篇关于实现的文章阐述一下这个对接里面所需要的一些细节以及,实现流程。首先我们需要了解的是Aligenie开发者平台。

https://open.bot.tmall.com/ 

这里有必要贴一张整个接入的流程图

 

这个平台的登录可以用淘宝账号登录。登录后

我们需要先进行技能的创建,点击添加新技能

技能信息这一栏信息我就不做过多的阐述自己随便填一下就是了。作为测试取名Test或者什么其他的都OK。填写完成后点击下一步:

这个页面对开发者来说真的可谓是重中之重。

第一栏账户授权链接应填写我们开发者为Aligenie平台提供的授权登录页面(自己编写)

第二栏,第三栏Client ID和Client Secret这里设置的作用就是平台识别你新建技能用的可以自己随便填写。

Aceess Token URL这个地址需要解释一下官方文档中标识如下:

这个地址其实就是当你完成授权登录这一步后会返回一个code值,然后将code值添加进OAuth2.0请求中将整个请求转发给

你填写AccessTokenURL方法接口中去。通过传递的code换取访问令牌

https://XXXXX/token?grant_type=authorization_code&client_id=XXXXX&client_secret=XXXXXX&code=XXXXXXXX&redirect_uri=https%3A%2F%2Fopen.bot.tmall.com%2Foauth%2Fcallback

 

最后一个必填项 开发者网关地址是当平台接受到你的返回的AccessToken后要将平台的智能家居协议发送到的一个接口。该接口用来接收协议然后按照官方文档给出的返回json体的格式返回你要接入的智能设备的一些参数。

上述的设备发现请求就是平台向网关地址中Post协议。而下面的就是你需要返回的东西。注册技能的地址填写就这么几个要点。

这边填写完后先不用上线什么的先做一个本地的测试再说。填完后我们返回技能主页会出现该技能的图标点进去。这时我们需要测试自己的技能,点击账户配置会跳转到你所写的登录页面。登录页的账号密码填写公司中存储的用户的账号密码就可。

当跳转到这个界面时我们看网址信息

http://www.XXXXX.com/test2/merchantHTML/merchantlogin.jsp?redirect_uri=https%3A%2F%2Fopen.bot.tmall.com%2Foauth%2Fcallback%3FskillId%3D18105%26token%3DMjM0MDgzODYwMEFGRUhJTkZEVlE%3D&client_id=hbsycjn2010&response_type=code&state=0.5252341172795741

从redirect后的信息都是平台为我们自己加上的。登录成功后我们需要将请求转发给我们生成Code并生成与Code对应的AcessToken的这个接口中为平台反馈AcessToken。

我这里用的是SSM框架实现的

 

userService.java

package com.obj.service;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.obj.dao.userDao;
import com.obj.entity.user;

@Service
public class userService {
	@Resource
	private userDao userdao;
	
	public user UserLogin(String username,String password)
	{
		return userdao.UserLogin(username, password);
	}
	
	public user IdentifyUsername(String username)
	{
		return userdao.IdentifyUsername(username);
	}
	public user IdentifyPassword(String username,String password)
	{
		return userdao.IdentifyPassword(username, password);
	}
}

userDao.java

package com.obj.dao;
import com.obj.entity.*;
public interface userDao {
	public user UserLogin(String username,String password);
	public user IdentifyUsername(String username);
	public user IdentifyPassword(String username,String password);
	
}

 

userMapper.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper  
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"  
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">  
<mapper namespace="com.obj.dao.userDao">    
    <resultMap type="user" id="userResult">  
    	<result property="Id" column="Id"/> 
        <result property="username" column="username"/>  
        <result property="password" column="password"/> 
    </resultMap>  
    
     <select id="UserLogin" parameterType="String" resultType="user">  
        select * from user where user=#{0} and password=#{1}  
    </select> 
    <select id="IdentifyUsername" parameterType="String" resultType="user">  
        select * from user where user=#{0}; 
    </select> 
    <select id="IdentifyPassword" parameterType="String" resultType="user">  
        select * from user where user=#{0} and password=#{1}  
    </select> 
</mapper>

testController.java

package com.obj.controller;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.UUID;

import javax.annotation.Resource;  
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.oltu.oauth2.as.issuer.MD5Generator;
import org.apache.oltu.oauth2.as.issuer.OAuthIssuer;
import org.apache.oltu.oauth2.as.issuer.OAuthIssuerImpl;
import org.apache.oltu.oauth2.as.request.OAuthAuthzRequest;
import org.apache.oltu.oauth2.as.request.OAuthTokenRequest;
import org.apache.oltu.oauth2.as.response.OAuthASResponse;
import org.apache.oltu.oauth2.client.OAuthClient;
import org.apache.oltu.oauth2.client.URLConnectionClient;
import org.apache.oltu.oauth2.client.request.OAuthBearerClientRequest;
import org.apache.oltu.oauth2.client.request.OAuthClientRequest;
import org.apache.oltu.oauth2.client.response.OAuthAccessTokenResponse;
import org.apache.oltu.oauth2.client.response.OAuthResourceResponse;
import org.apache.oltu.oauth2.common.OAuth;
import org.apache.oltu.oauth2.common.error.OAuthError;
import org.apache.oltu.oauth2.common.exception.OAuthProblemException;
import org.apache.oltu.oauth2.common.exception.OAuthSystemException;
import org.apache.oltu.oauth2.common.message.OAuthResponse;
import org.apache.oltu.oauth2.common.message.types.GrantType;
import org.apache.oltu.oauth2.common.message.types.ResponseType;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.obj.entity.application;
import com.obj.entity.user;
import com.obj.service.applicationService;
import com.obj.service.userService;



@Controller
@RequestMapping("/Test")
public class testController {
	
	@Resource
	public userService userservice;
	@Resource
	public applicationService applicationservice;
	
	String grant_type = "authorization";
	String clientId ="xxxxx";
	String clientSecret = "xxxxx";
    String accessTokenUrl = "http://www.xxxx.com:8081/index.jsp";
    String userInfoUrl = null;
    String redirectUrl = "https://open.bot.tmall.com/oauth/callback";
    String response_type = "code";
    String code= null;
    String cutURL = "http://www.xxxx.com:8081/test2/merchantHTML/merchantlogin.jsp?";
    String OAuthURL = "http://www.xxxx.com:8081/test2/Test/responseCode.do?";
    int cutlength = cutURL.length();

    
    
    
    @RequestMapping("/userlogin")
    public String userlogin(HttpServletRequest request) throws IOException, OAuthSystemException
    {
    	String url = request.getHeader("referer");
    	System.out.println("请求跳转地址:"+url);
    	
    	
    	String username = request.getParameter("username");
    	String password = request.getParameter("password");

    	
    	user IdentifyUsername = userservice.IdentifyUsername(username);
    	user IdentifyPassword = userservice.IdentifyPassword(username, password);
    	if(IdentifyUsername != null )
    	{
    		if(IdentifyPassword != null)
    		{
    			System.out.println("登录成功!");
    			String outURL = java.net.URLDecoder.decode(url, "GBK");
    			System.out.println("decode后跳转的地址:"+outURL);
    			int outlength = outURL.length();
    			String responseURL = outURL.substring(cutlength, outlength);
    			System.out.println(responseURL);
    			OAuthURL = OAuthURL + responseURL;
    			System.out.println("decode后要跳转的地址:"+OAuthURL);
    			return "redirect:" + OAuthURL;
    		}
    		else
    		{
    			System.out.println("密码错误!");
    		}
    	}
    	else
    	{
    		System.out.println("用户名不存在!");
    	}
    
		return "redirect:/";
    }
    
    @RequestMapping("/responseCode")
	public Object toShowUser(Model model, HttpServletRequest request) throws IOException{
		System.out.println("----------服务端/responseCode--------------------------------------------------------------");
	      try {
	    	//构建OAuth 授权请求  
	          OAuthAuthzRequest oauthRequest = new OAuthAuthzRequest(request); 
	          oauthRequest.getClientId();
	          oauthRequest.getResponseType();
	          oauthRequest.getRedirectURI();
	          String token = oauthRequest.getParam("token");
	          
	          System.out.println(oauthRequest.getClientId());
	          System.out.println(oauthRequest.getResponseType());
	          System.out.println(oauthRequest.getRedirectURI());
	          System.out.println(oauthRequest.getParam("token"));
	       
	          
	      if(oauthRequest.getClientId()!=null&&oauthRequest.getClientId()!="")
	        {
	        	//设置授权码  
		          String authorizationCode = UUID.randomUUID().toString().replace("-", "").substring(0, 18);
		          System.out.println(authorizationCode);
		        //利用oauth授权请求设置responseType,目前仅支持CODE,另外还有TOKEN  
		          String responseType = oauthRequest.getParam(OAuth.OAUTH_RESPONSE_TYPE);
		        //进行OAuth响应构建
		          OAuthASResponse.OAuthAuthorizationResponseBuilder builder =
		                    OAuthASResponse.authorizationResponse(request, HttpServletResponse.SC_FOUND);
		        //设置授权码
		          builder.setParam("token", token);	   
		          builder.setParam("state","11");
		          builder.setCode(authorizationCode);
		        //得到到客户端重定向地址
		          String redirectURI = oauthRequest.getParam(OAuth.OAUTH_REDIRECT_URI);
		        //构建响应
		          final OAuthResponse response = builder.location(redirectURI).buildQueryMessage();
		          System.out.println("服务端/responseCode内,返回的回调路径:"+response.getLocationUri());
		          System.out.println("----------服务端/responseCode--------------------------------------------------------------");
		         String responceUri =response.getLocationUri();
		         System.out.println(responceUri);
		        //根据OAuthResponse返回ResponseEntity响应
		            HttpHeaders headers = new HttpHeaders();
		           
		            try {
						headers.setLocation(new URI(response.getLocationUri()));
						
					} catch (URISyntaxException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
		            
		            String strURL = "http://www.xxxx.com/test2/Test/responseAccessToken.do?grant_type=authorization_code&client_id=hbsycjn2010&client_secret=ainipinxin&redirect_uri=https://open.bot.tmall.com/oauth/callback&code=" + authorizationCode;
		            URL url = new URL(strURL);
		            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
					connection.setDoOutput(true);
					connection.setDoInput(true);
					connection.setUseCaches(false);
					connection.setInstanceFollowRedirects(true);
					connection.setRequestMethod("POST"); // 设置请求方式
					connection.setRequestProperty("Accept", "application/json"); // 设置接收数据的格式
					connection.setRequestProperty("Content-Type", "application/json"); // 设置发送数据的格式
					connection.connect();	
					
		            
		            
		            
		            return "redirect:"+responceUri;
		           // https://open.bot.tmall.com/oauth/callback?skillId=18105&code=0b58444322e04d9c8e&state=11&token=MjM0MDgzODYwMEFGRUhJTkZEVlE%3D
	        }
			
		} catch (OAuthSystemException e) {
			e.printStackTrace();
		} catch (OAuthProblemException e) {
			e.printStackTrace();
		}
	      System.out.println("----------服务端/responseCode--------------------------------------------------------------");
		return null;	
	}
	
    @RequestMapping(value = "/responseAccessToken",method = RequestMethod.POST)  
	public HttpEntity token(HttpServletRequest request) throws OAuthSystemException{
    	JSONObject jsonObject = new JSONObject();
		System.out.println("--------服务端/responseAccessToken-----------------------------------------------------------");
		OAuthIssuer oauthIssuerImpl=null;
		 OAuthResponse response=null;
		//构建OAuth请求  
	      try {
			OAuthTokenRequest oauthRequest = new OAuthTokenRequest(request);
			String authCode = oauthRequest.getParam(OAuth.OAUTH_CODE); 
			String clientSecret = oauthRequest.getClientSecret();
			if(clientSecret!=null||clientSecret!=""){
				//生成Access Token
	            oauthIssuerImpl = new OAuthIssuerImpl(new MD5Generator());
	            final String accessToken = oauthIssuerImpl.accessToken();
	            final String refreshToken = oauthIssuerImpl.refreshToken();
	            
	            jsonObject.put("access_token", accessToken);
	            jsonObject.put("refresh_token", refreshToken);
	            jsonObject.put("expires_in", 1760000);
	            System.out.println(jsonObject.toString());
	            
	            System.out.println("--oooo---");
	          //生成OAuth响应
	            response = OAuthASResponse
	                    .tokenResponse(HttpServletResponse.SC_OK)
	                    .setAccessToken(accessToken)
	                    .setRefreshToken(refreshToken)
	                    .setParam("expires_in", "17600000")
	                    .buildJSONMessage();
	            System.out.println(response.getBody());
	    
			}
		
            
			System.out.println("--------服务端/responseAccessToken-----------------------------------------------------------");
			
          //根据OAuthResponse生成ResponseEntity
            return new ResponseEntity(response.getBody(), HttpStatus.valueOf(response.getResponseStatus()));
			
		} catch (OAuthSystemException e) {
			response = OAuthASResponse
                    .tokenResponse(HttpServletResponse.SC_OK)
                    .setParam("error", "101")
                    .setParam("error_description", "内部错误")
                    .buildJSONMessage();
			
			// TODO Auto-generated catch block
			jsonObject.put("error", 101);
			jsonObject.put("error_dercription", "内部错误");
			 System.out.println(jsonObject.toString());
			return new ResponseEntity(response.getBody(), HttpStatus.valueOf(response.getResponseStatus()));
		} catch (OAuthProblemException e) {
			// TODO Auto-generated catch block
			response = OAuthASResponse
                    .tokenResponse(HttpServletResponse.SC_OK)
                    .setParam("error", "102")
                    .setParam("error_description", "参数错误")
                    .buildJSONMessage();
			jsonObject.put("error", 102);
			jsonObject.put("error_dercription", "参数错误");
			 System.out.println(jsonObject.toString());
			 return new ResponseEntity(response.getBody(), HttpStatus.valueOf(response.getResponseStatus()));
		}
	    // System.out.println("--------服务端/responseAccessToken-----------------------------------------------------------");
		
	    // return null;
		
	}
   
    @RequestMapping(value ="/getMessage",method = RequestMethod.POST)
    @ResponseBody
    public JSONObject getMessage(HttpServletRequest request, HttpServletResponse response,BufferedReader br)
    {
    	
    	//System.out.println("hi");
    	//Header部分
    	JSONObject MerchineList = new JSONObject();
    	JSONArray jSONArray = new JSONArray();
    	JSONObject header = new JSONObject();
    	JSONObject payload = new JSONObject();
    	List<JSONObject> devices =  new ArrayList();
    	List<JSON> properties = new ArrayList();
    	List actions = new ArrayList();
    	JSONObject extentions = new JSONObject();
        System.out.print(request.getHeaderNames());
        Enumeration<?> enum1 = request.getHeaderNames();
        while (enum1.hasMoreElements()) {
          String key = (String) enum1.nextElement();
          String value = request.getHeader(key);
          System.out.println(key + "\t" + value);
        }
        //body部分
        String inputLine;
        String str = "";
        try {
          while ((inputLine = br.readLine()) != null) {
            str += inputLine;
          }
          br.close();
        } catch (IOException e) {
          System.out.println("IOException: " + e);
        }
        System.out.println("str:" + str);
        JSONObject recieveHeader = new JSONObject();
        recieveHeader = JSON.parseObject(str);
        String str1 = recieveHeader.getString("header");
        System.out.println("header:" + recieveHeader.getString("header"));
        JSONObject recieveMessageId = new JSONObject();
        recieveMessageId = JSON.parseObject(str1);
        System.out.println("messageId:" + recieveMessageId.getString("messageId"));
        
        header.put("namespace", "AliGenie.Iot.Device.Discovery");
        header.put("name", "DiscoveryDevicesResponse");
        header.put("messageId", recieveMessageId.getString("messageId"));
        header.put("payLoadVersion", "1");
        
        
        JSONObject device = new JSONObject();
        JSONObject propertie = new JSONObject();
       
        
        device.put("deviceId", "34ea34cf2e63");
        device.put("deviceName", "单孔插座");
        device.put("deviceType", "outlet");
        device.put("zone", "test");
        device.put("brand", "test");
        device.put("model", "test");
        device.put("icon", "https://ss0.bdstatic.com/94oJfD_bAAcT8t7mm9GUKT-xh_/timg?image&quality=100&size=b4000_4000&sec=1531878000&di=c989660f4b827a0049c3b7aec4fe38e1&src=http://img.czvv.com/sell/599adfe4d2f0b1b2f118606f/20170905113247194.jpg");
        
       
        
        propertie.put("name", "powerstate");
        propertie.put("value", "off");
        properties.add(propertie);
        device.put("properties", properties);
        
        actions.add("TurnOn");
        actions.add("TurnOff");
        device.put("actions", actions);
        
        
        extentions.put("extension1", "tset");
        extentions.put("extension2", "test");
        device.put("extentions", extentions);
        
        devices.add(device);
        payload.put("devices", devices);
        
        MerchineList.put("header", header);
        MerchineList.put("payload", payload);
        System.out.println(MerchineList.toString());
        return MerchineList;
       
      }
      
}

点击登录并授权,如果在生成CODE,通过生成的CODE换取AccessToken返回给平台这几步上都没有差错则会跳转到一下界面。

此时说明已经将智能设备接入到了平台中。这是你可以操作自己的天猫精灵,说打开单孔插座,天猫精灵就会做出相应的反应同样会发送一条JSON数据段给你的开发者网关地址。以上便是整个接入的过程。

web开发的小伙伴在第一次跳转到这个界面的时候可能会出现您还没有智能设备接入的空白界面。不要急着质疑是不是自己的代码写错了。这时你可以打开手机上的天猫精灵APP在App中点击智能设备看看有没有相关的智能设备接入进去,如果没有这时再返回去仔细的检查代码。

 

 

 

 

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Java实现天猫精灵与智能设备的对接 的相关文章

  • JIEMI人体美化技术-职业重要

    地址 xff1a https app6ca5octe2206 pc xiaoe tech com detail v 6221b726e4b02b825850f9f6 3 AI技术在快手人像美化中的应用 AI美化难点 xff1a 手淘场景下的
  • 中兴捧月算法挑战赛-RAW夜景图像去噪总结

    最终排名 85 1159 网址 xff1a https zte hina com zte denoise 无缘复赛 xff0c 太菜了 xff0c 不好意思说自己学去噪的了 xff0c 代码会开源 xff0c 但是感觉没什么人看吧 尝试过的
  • 论文笔记:MPRNet: Multi-Stage Progressive Image Restoration

    相关方法 单阶段 多阶段 注意力 方法 将图像分割为不重叠的patches xff1a 四个用于第一阶段 xff0c 两个用于第二阶段 xff0c 原始图像用于最后一阶段 残差学习 xff1a X S 61 I
  • 论文笔记:NAFNet: Simple Baselines for Image Restoration

    向孙老师致敬 xff01 相关工作 图像恢复模型体系结构比较 方法 块内 Intra block 结构比较 xff1a 其中Channel Attention CA xff0c Simplified Channel Attention SC
  • 在Ubuntu 22.04 Jammy Jellyfish Linux上流畅安装VMware tools

    安装 VMware Tools 软件可以更好提升我们的虚拟机使用体验 xff0c 但是在使用VMware自带的linux iso安装VMware Tools后 xff0c 无端会报各种错误 本文将会提供一个使用官方源的途径进行安装的简单指引
  • 研究生投稿被拒经历

    2021 7 25 投稿IEEE JSTARS 2021 7 27 被拒 xff08 查重率不过 xff09 2021 9 7 投稿Remote Sensing赠刊1 2021 9 10 被拒 xff08 创新度不够 xff09 2021
  • 垃圾+虚假会议大全https://waset.org/conferences,千万别投

    这个垃圾网站上面的会议全是假的 xff01 xff01 xff01 千万别投 xff01 xff01 xff01 https waset org conferences 投稿前 我研究领域是 xff1a 不确定性量化和灵敏度分析 学院的毕业
  • CVPR 2022 图像恢复论文

    地址 xff1a https openaccess thecvf com CVPR2022 https openaccess thecvf com CVPR2022 workshops NTIRE Blind2Unblind Self Su
  • 项目代码训练教程

    配置好matconvnet后 xff0c deep model下有三个文件夹 xff0c 分别是我们的方法 xff1a FOC SDeCNN try和SDeCNN方法 xff1a HSI SDeCNN train1 2 3 HSI SDeC
  • 每日一篇论文推荐

    每日一篇论文推荐 7 5 Unsupervised Hyperspectral Denoising Based on Deep Image Prior and Least Favorable Distribution7 6 WINNet W
  • ISP图像信号处理 | GAMES204-计算成像

    图像信号处理 GAMES204 计算成像 Dead Pixel CorrectionBlack Level CompensationAnti aliasingLens Shading CorrectionNoise Reduction3AS
  • np.max()、np.argmax()、np.maximum()、np.min()、np.argmin()、np.minimum()、np.sum()

    numpy专题 最值 求和 最大值np max np argmax np maximum 求和np sum 网上已经有很多对于这几个函数的讲解资料 xff0c 但总感觉讲得有些乱 xff0c 特别是对于高维数组 xff0c 如果指定了某个轴
  • Cortex-M3 (NXP LPC1788)之EEPROM存储器

    EEPROM是一种非易失性存储器 xff0c 主要用于存储相对少量的数据 xff0c 如存储一些系统的配置信息 通过系统的EEPROM控制模块可以轻松的进行EERPOM的存储控制 要正确使用EEPROM需要配置掉电寄存器EEPWRDWN确定
  • sqlalchemy.exc.ArgumentError: Could not parse rfc1738 URL from string

    错误信息 sqlalchemy exc ArgumentError Could not parse rfc1738 URL from string 原 flask sqlacodegen mysql root 64 127 0 0 1 fo
  • 面试题汇总:网络编程

    1 tcp和udp的区别 xff1f xff08 1 xff09 TCP面向连接 xff08 如打电话要先拨号建立连接 xff09 UDP是无连接的 xff0c 即发送数据之前不需要建立连接 xff1b xff08 2 xff09 TCP提
  • CentOS7 安装学之思开源考试系统Mysql版

    环境介绍 序号项目版本1操作系统CentOS Linux release 7 9 2009 Core 2redis7 0 03Mysqlmysql Ver 8 0 29 for Linux on x86 64 MySQL Community
  • Cisco catalyst 交换机升级步骤

    交换机升级步骤 1 准备一个FAT32的U盘 2 到cisco官网上下载交换机镜像 3 将U盘插到交换机上 xff0c 登入交换机concole输入dir usbflash0 xff1a 找到该镜像 xff0c 注意镜像不要放在中文目录下
  • 【性能】【内存】zram解读

    1 背景 nbsp 通过压缩长时间不在前台的进程来节省内存占用 不会像swap一样频繁操作闪存 也可以减少IO操作节省资源 延长闪存寿命 不过内存压缩是一种用时间换空间 的方式 cpu解压缩过程也是需要消耗少量cpu资源 尽管当前andro
  • wifi连接过程抓包

    下面是一次wifi连接过程发送数据的抓包 xff0c 有些包没抓到 xff0c 但还是比较全的 1 4包 xff0c 探测请求 响应过程 STA发出探测请求包Probe ReqAP做出回应 xff0c 发出探测响应包Probe Rsp 5
  • mbedtls学习(6)RSA算法

    RSA算法 RSA算法是一种非对称加密算法 xff0c 特点时加密解密算法不同且加密解密密钥不同 xff0c 即一般公钥加密 xff0c 私钥解密 下面时RSA算法关键参数 n 模数 xff0c 位长度为1024比特或者2048比特e 公开

随机推荐

  • LVGL lv_label标签控件(5)

    lv label 相关API在lv label h中 文本模式 span class token keyword enum span span class token punctuation span span class token co
  • LVGL lv_page页面控件(23)

    lv page 页面控件 xff0c 是由2个lv cont容器控件构成 xff0c 其中一个容器作为lv page页面控件的背景层 xff0c 另一个容器作为lv page页面控件的载体 xff0c 此载体存放其他任何子对象 xff0c
  • FreeRTOS消息队列、信号量、互斥量、递归互斥量实现步骤

    文章目录 消息队列消息队列结构读队列步骤写队列步骤 作用 信号量信号量结构 获取信号量释放信号量 互斥量 xff08 锁 xff09 互斥量结构 获取互斥量释放互斥量 递归互斥量 xff08 递归锁 xff09 获取递归互斥量释放递归互斥量
  • GDB调试宏

    参考 GDB需要调试宏只需用 g3选项编译 g 默认选项 xff0c 同 g2 g0 不生成任何调试信息 xff0c 和编译时不加 g 是一样的 g1 生成最少量的调试信息 xff0c 这些信息足够用来通过backtrace查看调用栈符号信
  • GDB格式化打印结构体

    参考 GDB pretty print set print pretty on GDB 打印数组索引 set print array span class token operator span indexes on 例子 span cla
  • 8080接口

    文章目录 简介引脚写时序读时序 简介 8080接口是由英特尔设计 xff0c 是一种并行 异步 半双工通信协议 xff0c 作用是用于外扩RAM ROM xff0c 后面也用于LCD接口 引脚 写时序 先拉低选中器件 xff0c 如果要写入
  • Centos 7离线安装最新版mysql

    测试环境 CentOS Linux release 7 9 2009 Core 1 准备工作 下载离线安装包 xff1a 1 1 浏览器打开地址 xff1a https dev mysql com downloads mysql 1 2 选
  • C语言UDP socket编程

    C语言UDP socket编程 UDP 服务器步骤如下 xff1a 1 创建等链接套接字fd 61 socket 2 绑定待链接套接字bind fd 服务器ip和端口 3 等待信息recvfrom fd 对端地址 UDP 客户端步骤如下 x
  • MQTT学习笔记(4)报文分析之PUBLISH

    PUBLISH xff08 发布消息 xff09 含义 xff1a 客户端到服务端或者服务端到客户端发布消息控制报文 xff0c 是双向的 一 固定报头 DUP 重发标志 当DUP被设置为0 xff0c 表示客户端或者服务器是第一次发送这个
  • MQTT学习笔记(6)搭建本地MQTT服务器

    目前主流的Broker有以下3个 xff1a Mosquitto xff1a https mosquitto org VerneMQ xff1a https vernemq com EMQTT xff1a http emqtt io 我们使
  • nrf52832学习笔记(4)修改蓝牙名称,掉电不丢失

    这篇主要介绍如何在手机端修改设备参数 xff0c 比如设备名称 且实现掉电不丢失 思路 xff1a 把需要修改的参数发送给设备 xff0c 设备根据uuid来分辨是参数 xff0c 并保存在flash中 xff0c 重启服务 xff0c 这
  • IIC协议总结

    这篇总结下IIC协议 简介 IIC xff0c Inter Integrated Circuit xff0c 集成电路总线 xff0c 需要2根线连接拓扑 xff0c 是半双工 xff0c 适用于 34 字节型 34 设备 特点 拓扑如下
  • ros+gazebo学习(持续更新)

    由于实习需要 xff0c 开始学习ROS的东西 这篇博客主要是记录在ROS 43 gazebo学习中遇到的各种坑 xff08 掩面 xff09 xff0c 希望能对一些也在该领域的同志提供一点小小帮助 安装问题 xff08 gazebo 4
  • TX2 ubuntu18.04 arm64架构 桌面系统为lxde 系统为轻量级 成功安装ros

    如标题所述 xff1a 硬件采用 xff1a TX2 ubuntu18 04 arm64架构 桌面系统为lxde 来安装ros xff0c 安装了两次都意外失败了 xff0c 后来终于找到了问题 在ros wiki 官网 xff08 htt
  • 解决NVIDIA jetson NX 板卡安装镜像之后,SD卡容量变小的问题

    解决NVIDIA jetson NX 板卡安装镜像之后 xff0c SD卡容量变小的问题 问题描述 xff1a 本人使用的SD卡为64G xff0c 安装了一个约30g的 img镜像 xff0c 之后插入NX板卡 xff0c 系统正常启动
  • USB接线定义和链接摄像头

    原文链接 xff1a https www cnblogs com chinalantian articles 2131361 html 写本文的意义在于了解USB的接线定义和实现使用手机数据线读取摄像头图像 USB接口定义 颜色 一般的排列
  • C语言 VC6.0控制台编写一个贪吃蛇游戏

    最近看到有人发布贪吃蛇的编码实现 xff0c 想到了自己多年之前也实现过一个 xff0c 发布在这里 xff0c 做一下回忆 C语言面向过程编码 xff0c 基本功能实现以函数为单位 xff0c 重点就是各个函数的设计和实现 本篇使用VC6
  • 笔记本外接键盘解决方案:禁用笔记本自带键盘

    适用场景 xff1a 笔记本外接键盘时 xff0c 有时会将外接键盘放置在笔记本自带键盘上 xff0c 加上现代笔记本设计轻薄 xff0c 外接键盘 xff08 尤其是108键的 xff09 在使用过程中经常触碰自带键盘 xff0c 禁用自
  • ROS节点解析GPS数据:GPRMC/GPFDP/HEADINGA

    数据解析 xff0c 肯定是要知道数据格式的 xff1a 数据格式参考 xff1a xff08 前人已经总结的比较齐全了 xff09 https blog csdn net u010384390 article details 784320
  • Java实现天猫精灵与智能设备的对接

    天猫精灵与公司智能设备的对接 刚接到这个任务的时候对于一个刚毕业一个月的应届生我来说 xff0c 有点像巨石 xff0c 不过经历了10多天的自己琢磨 xff0c 还是终于把这个新东西搞出来了 楼主是学的java xff0c 但在查询相关文