物联网:Android端控制ZigBee实现生产环境自动控制

这两天一直在搞ZigBee终于算是摸出来了一点经验,先来个命令贴这儿

//继电器命令1 2 3有规律很好记,每次写完查一下是不是9个
final static char[] fan0open={
  0xff,0xf5,0x05,0x02,0x01,0x00,0x00,0x01,0x03};
final static char[] fan0close={
  0xff,0xf5,0x05,0x02,0x01,0x00,0x00,0x02,0x02};
final static char[] fan1open={
  0xff,0xf5,0x05,0x02,0x02,0x00,0x00,0x01,0x02};
final static char[] fan1close={
  0xff,0xf5,0x05,0x02,0x02,0x00,0x00,0x02,0x01};
final static char[] fan2open={
  0xff,0xf5,0x05,0x02,0x03,0x00,0x00,0x01,0x01};
final static char[] fan2close={
  0xff,0xf5,0x05,0x02,0x03,0x00,0x00,0x02,0x02};

这次是根据一个任务书写的,任务要求如下:

香菇培育区域(生产车间)生产环境自动控制

该任务根据香菇的生长环境要求空气湿度60~70%,温度为25℃。模拟实现香菇培育区域(生产车间)生产环境自动控制系统。新建Android项目,利用提供的软件资源,按下面设计要求,完成生产环境自动控制模块的开发。
设计要求:
 认真阅读“竞赛资料\任务3\开发调用资源\题2\ZigBee模块调用库\ ZigBee库说明.pdf”文档。
 创建项目后将文件夹及文件“armeabi\libuart.so”导入libs中;
 将文件zigbeelibrary.jar导入libs中;
 当接在ZigBee底板上的人体红外探测器感应到有人时,根据提供的图片素材,界面上门打开,照明灯亮(背景图片中两盏照明灯);没有人时候反之,选手可根据逻辑切换图片。说明:界面上的门动画效果在竞赛资料中提供多张图片,如果可按逻辑实现门打开的完整动画效果,酌情加分。
 提供“逻辑控制”和“手动控制”功能
 以下是逻辑控制要求:
 当温度低于25℃启动加热器(1#风扇转动模拟)。
 当温度超过25℃启动制冷器(2#风扇转动模拟)。
 加热器(1#风扇)、制冷器(2#风扇)、门、照明灯均可用手动进行控制。
 将开发好的程序部署到移动互联终端,应用程序名称为“生产环境智能控制”。

任务不是很多但是也足足码了200多行,大修改了3次,最终稳定了这版,还是老样子直接代码贴出来: 布局:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/pg_bg_night"
    tools:context=".MainActivity" >
    <ToggleButton
        android:id="@+id/tb_switch"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:textOff="手动控制"
        android:textOn="逻辑控制" />
    <Button
        android:id="@+id/btn_exit"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:text="退出" />
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_marginRight="150dp"
        android:layout_marginTop="98dp"
        android:layout_toLeftOf="@+id/btn_exit"
        android:orientation="vertical" >
        <TextView
            android:id="@+id/tv_temp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text
  • 2
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值