javaweb通过串口和单片机进行通信:分别有Javaweb远程控制空调Javaweb远程控制门开关里面没有单片机的代码,只有Javaweb的有什么问题发我邮箱问我,备注好是找例子网,945750315@qq.com
package com.hciot.modules.door;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RestController;import com.hciot.util.CommUtil;/** * @ClassName: DoorController * @Description: TODO 控制层 * @Author: ZhouRunFeng * @Email: 243971236@qq.com * @Date: 2019年6月19日 下午8:22:11 * * @Copyright: 2019 www.hciot.com Inc. All rights reserved. */@RestControllerpublic class DoorController {@Autowiredprivate CommUtil comm;@RequestMapping("/open") public String open() throws Exception {// 断开comm.send("55 01 01 02 00 00 00 59");new Thread(new Runnable() {@Overridepublic void run() {try {Thread.sleep(2000);// 吸合comm.send("55 01 01 01 00 00 00 58");} catch (InterruptedException e) {e.printStackTrace();}}}).start();return "开门成功"; }}
评论