文章目录
一、功能介绍
二、设计框图
三、实物展示
四、程序
一、功能介绍
基于树莓派的智能家居。智能家居用到的硬件有:树莓派4B、LD3320语音识别模块、pi 摄像头、继电器组、小灯、火焰传感器、蜂鸣器、电磁锁
采用了简单工厂模式的一个设计方式。稳定,拓展性更强,在C语言中,因为没有接口、类这一说法,所以这里采用了结构体来“等效替换”。有四个灯,所以我创建了四个灯控制.c程序。每一个程序文件中,都有一个设备结构体,每个程序文件的函数实现方法不同,当有新设备进入只需要在创建一个.c文件,改变函数实现方法即可。初始化的时候,通过链表将各个模块连接起来(头插法)。在要使用某个模块时,只需要使用链表遍历,找到所需模块去调用功能
具体功能是:
1、可通过ld3320语音模块的口令模式,口令+具体控制,通过串口把控制指令传给树莓派,来控制客厅、餐厅、二楼、浴室的灯
2、也可以通过socket客户端来发指令来控制灯的开关
3、火灾报警,当火焰传感器检测到火焰的时候,蜂鸣器会报警。
4、视频监控采用开源mjpg-Streamer来实现的,程序执行时创建一个视频监控的线程,用system函数调用启动脚本运行,监控画面可在http://172.20.10.8:8080去看到
5、人脸识别开锁,人脸识别功能是使用的翔云平台的人脸识别解决方案,需要安装libcurl 和 openSSl库来支持https协议,通过系统调用wget +http://172.20.10.8:8080/?action=snapshot -O ./huyu1.jpg 指令到树莓派的监控页面"去截取一帧保存到本地,获取图片的base64编码,工程文件夹下也有一张照片,huyu.jpg格式,相当于采集的人脸。也是获取图片的base64编码,通过sprintf函数将访问翔云需要的两张图片的base64编码与Key、secret、typeId、format拼接在一起,通过https协议去访问翔云平台, 识别成功后会将识别结果返回,通过回调函数readData将返回的字符串读到readBuff里,通过strstr去readbuff里找有没有字符’是’,如果识别成功就去控制电磁锁打开。
二、设计框图
效果展示:https://www.bilibili.com/video/BV1uD4y1C7PH?share_source=copy_web&vd_source=5e457ac82f63b0e36b8b9e2708807f31
三、实物展示
四、程序
1、InputCommand.h
#include<wiringPi.h>#include<stddef.h>structInputCommander{char commandName[128];char deviceName[128];char command[32];int(*Init)(structInputCommander*voicer,char*ipAdress,char*port);int(*getCommand)(structInputCommander*voicer);char log[1024];int fd;char port[12];char ipAddress[32];int sfd;structInputCommander*next;};structInputCommander*addVoiceControlToInputCommandLink(structInputCommander*phead);structInputCommander*addSocketControlToInputCommandLink(structInputCommander*phead);
2、controlDevices .h
#include<wiringPi.h>#include<stdio.h>structDevices{char deviceName[128];int status;int pinNum;int(*open)(int pinNum);int(*close)(int pinNum);int(*deviceInit)(int pinNum);int(*readStatus)(int pinNum);int(*changeStatus)(int status);void(*faceRecognition)();//人脸识别char*(*takePictureInit)();//用于摄像头char*(*getPicBase64)();//用于摄像头size_t(*readData)();//用于摄像头structDevices*next;};structDevices*addBathroomLightToDeviceLink(structDevices*phead);structDevices*addUpstairLightToDeviceLink(structDevices*phead);structDevices*addDiningroomLightToDeviceLink(structDevices*phead);structDevices*addLivingroomLightToDeviceLink(structDevices*phead);structDevices*addFireAlarmToDeviceLink(structDevices*phead);structDevices*addBeepToDeviceLink(structDevices*phead);structDevices*addLookToDeviceLink(structDevices*phead);structDevices*addCameraToDeviceLink(structDevices*phead);
3、mainPro.c
#include<stdio.h>#include<string.h>#include<stdlib.h>#include<unistd.h>#include<pthread.h>#include<sys/types.h>#include<sys/socket.h>#include<netinet/in.h>#include<arpa/inet.h>#include"controlDevices.h"#include"InputCommand.h"structInputCommander*pCommandHead =NULL;structDevices*pdeviceHead =NULL;structInputCommander*socketHandler =NULL;int c_fd;char*name =NULL;pthread_t cameraThread;structDevices*findDeviceByName(char*name,structDevices*phead){structDevices*tmp = phead;if(phead ==NULL){returnNULL;}else{while(tmp !=NULL){if(strcmp(tmp->deviceName,name)==0){return tmp;}
tmp = tmp->next;}returnNULL;}}structInputCommander*findCommandByName(char*name,structInputCommander*phead){structInputCommander*tmp = phead;if(phead ==NULL){returnNULL;}else{while(tmp !=NULL){if(strcmp(tmp->commandName,name)==0){return tmp;}
tmp = tmp->next;}returnNULL;}}void*camera_thread(void*datas)//摄像头线程{structDevices*cameraTemp;
cameraTemp =findDeviceByName("camera", pdeviceHead);//设备都要从工厂里面取出来if(cameraTemp ==NULL){//防止段错误的必需判断,当给指针赋值是,一定要考虑NULL的情况printf("find camera error\n");pthread_exit(NULL);//在线程中不用return}
cameraTemp->faceRecognition();//调用人脸识别函数}void*voice_thread(void*datas)//语音线程{int nread;structInputCommander*voiceHandler =NULL;structDevices*linkHandler =NULL;
voiceHandler =findCommandByName("voice",pCommandHead);if(voiceHandler ==NULL){printf("find voicehandler error\n");pthread_exit(NULL);}else{if(voiceHandler->Init(voiceHandler,NULL,NULL)<0){printf("voice init error\n");pthread_exit(NULL);}else{printf("%s init success!\n",voiceHandler->commandName);}while(1){memset(voiceHandler->command,'\0',sizeof(voiceHandler->command));
nread = voiceHandler->getCommand(voiceHandler);//读取来自语音模块的消息printf(" %s\n",voiceHandler->command);if(nread >1){if(strstr(voiceHandler->command,"KEL")!=NULL){//开二楼灯
linkHandler =findDeviceByName("upstairLight",pdeviceHead);
linkHandler->deviceInit(linkHandler->pinNum);
linkHandler->open(linkHandler->pinNum);printf("open upstairLight\n");}elseif(strstr(voiceHandler->command,"GEL")!=NULL){//关二楼灯
linkHandler =findDeviceByName("upstairLight",pdeviceHead);
linkHandler->close(linkHandler->pinNum);printf("close upstairLight\n");}elseif(strstr(voiceHandler->command,"KYS")!=NULL){//开浴室灯
linkHandler =findDeviceByName("bathroomLight",pdeviceHead);
linkHandler->deviceInit(linkHandler->pinNum);
linkHandler->open(linkHandler->pinNum);printf("open bathroomlight\n");}elseif(strstr(voiceHandler->command,"GYS")!=NULL){//关浴室灯
linkHandler =findDeviceByName("bathroomLight",pdeviceHead);
linkHandler->close(linkHandler->pinNum);printf("open bathroomlight\n");}elseif(strstr(voiceHandler->command,"KKT")!=NULL){//开客厅灯
linkHandler =findDeviceByName("livingroomLight",pdeviceHead);
linkHandler->deviceInit(linkHandler->pinNum);
linkHandler->open(linkHandler->pinNum);printf("open livingroomLight\n");}elseif(strstr(voiceHandler->command,"GKT")!=NULL){//关客厅灯
linkHandler =findDeviceByName("livingroomLight",pdeviceHead);
linkHandler->close(linkHandler->pinNum);printf("open livingroomLight\n");}elseif(strstr(voiceHandler->command,"KCT")!=NULL){//开餐厅灯
linkHandler =findDeviceByName("diningroomLight",pdeviceHead);
linkHandler->deviceInit(linkHandler->pinNum);
linkHandler->open(linkHandler->pinNum);printf("open diningroomLight\n");}elseif(strstr(voiceHandler->command,"GCT")!=NULL){//关餐厅灯
linkHandler =findDeviceByName("diningroomLight",pdeviceHead);
linkHandler->close(linkHandler->pinNum);printf("open diningroomLight\n");}elseif(strstr(voiceHandler->command,"KM")!=NULL){//开门pthread_create(&cameraThread,NULL,camera_thread,NULL);}elseif(strstr(voiceHandler->command,"DQK")!=NULL){//打开全部灯
linkHandler =findDeviceByName("upstairLight",pdeviceHead);
linkHandler->deviceInit(linkHandler->pinNum);
linkHandler->open(linkHandler->pinNum);
linkHandler =findDeviceByName("bathroomLight",pdeviceHead);
linkHandler->deviceInit(linkHandler->pinNum);
linkHandler->open(linkHandler->pinNum);
linkHandler =findDeviceByName("livingroomLight",pdeviceHead);
linkHandler->deviceInit(linkHandler->pinNum);
linkHandler->open(linkHandler->pinNum);
linkHandler =findDeviceByName("diningroomLight",pdeviceHead);
linkHandler->deviceInit(linkHandler->pinNum);
linkHandler->open(linkHandler->pinNum);printf("All closed\n");}elseif(strstr(voiceHandler->command,"DQG")!=NULL){//关闭全部灯
linkHandler =findDeviceByName("upstairLight",pdeviceHead);
linkHandler->close(linkHandler->pinNum);
linkHandler =findDeviceByName("bathroomLight",pdeviceHead);
linkHandler->close(linkHandler->pinNum);
linkHandler =findDeviceByName("livingroomLight",pdeviceHead);
linkHandler->close(linkHandler->pinNum);
linkHandler =findDeviceByName("diningroomLight",pdeviceHead);
linkHandler->close(linkHandler->pinNum);printf("All open\n");}elseif(nread ==0){printf("nodata from voice......\n");}//printf("%d\n",strlen(voiceHandler->command));}}}}void*read_thread(void*datas){int n_read;structDevices*linkHandler1 =NULL;memset(socketHandler->command,'\0',sizeof(socketHandler->command));
n_read =read(c_fd,socketHandler->command,sizeof(socketHandler->command));if(n_read>0){printf("get message:%d,%s\n",n_read,socketHandler->command);if(strstr(socketHandler->command,"KEL")!=NULL){//开二楼灯
linkHandler1 =findDeviceByName("upstairLight",pdeviceHead);
linkHandler1->deviceInit(linkHandler1->pinNum);
linkHandler1->open(linkHandler1->pinNum);printf("open upstairLight\n");}elseif(strstr(socketHandler->command,"GEL")!=NULL){//关二楼灯
linkHandler1 =findDeviceByName("upstairLight",pdeviceHead);
linkHandler1->close(linkHandler1->pinNum);printf("close upstairLight\n");}elseif(strstr(socketHandler->command,"KYS")!=NULL){//开浴室灯
linkHandler1 =findDeviceByName("bathroomLight",pdeviceHead);
linkHandler1->deviceInit(linkHandler1->pinNum);
linkHandler1->open(linkHandler1->pinNum);printf("open bathroomlight\n");}elseif(strstr(socketHandler->command,"GYS")!=NULL){//关浴室灯
linkHandler1 =findDeviceByName("bathroomLight",pdeviceHead);
linkHandler1->close(linkHandler1->pinNum);printf("close bathroomlight\n");}elseif(strstr(socketHandler->command,"KKT")!=NULL){//开客厅灯
linkHandler1 =findDeviceByName("livingroomLight",pdeviceHead);
linkHandler1->deviceInit(linkHandler1->pinNum);
linkHandler1->open(linkHandler1->pinNum);printf("open livingroomLight\n");}elseif(strstr(socketHandler->command,"GKT")!=NULL){//关客厅灯
linkHandler1 =findDeviceByName("livingroomLight",pdeviceHead);
linkHandler1->close(linkHandler1->pinNum);printf("close livingroomLight\n");}elseif(strstr(socketHandler->command,"KCT")!=NULL){//开餐厅灯
linkHandler1 =findDeviceByName("diningroomLight",pdeviceHead);
linkHandler1->deviceInit(linkHandler1->pinNum);
linkHandler1->open(linkHandler1->pinNum);printf("open diningroomLight\n");}elseif(strstr(socketHandler->command,"GCT")!=NULL){//关餐厅灯
linkHandler1 =findDeviceByName("diningroomLight",pdeviceHead);
linkHandler1->close(linkHandler1->pinNum);printf("close diningroomLight\n");}elseif(strstr(socketHandler->command,"KM")!=NULL){//开门//linkHandler1 = findDeviceByName("camera",pdeviceHead);//linkHandler1->takePictureInit();//linkHandler1->faceRecognition();pthread_create(&cameraThread,NULL,camera_thread,NULL);}elseif(strstr(socketHandler->command,"GM")!=NULL){//关门
linkHandler1 =findDeviceByName("lock",pdeviceHead);
linkHandler1->close(linkHandler1->pinNum);}elseif(strstr(socketHandler->command,"DQK")!=NULL){//打开全部灯
linkHandler1 =findDeviceByName("upstairLight",pdeviceHead);
linkHandler1->deviceInit(linkHandler1->pinNum);
linkHandler1->open(linkHandler1->pinNum);
linkHandler1 =findDeviceByName("bathroomLight",pdeviceHead);
linkHandler1->deviceInit(linkHandler1->pinNum);
linkHandler1->open(linkHandler1->pinNum);
linkHandler1 =findDeviceByName("livingroomLight",pdeviceHead);
linkHandler1->deviceInit(linkHandler1->pinNum);
linkHandler1->open(linkHandler1->pinNum);
linkHandler1 =findDeviceByName("diningroomLight",pdeviceHead);
linkHandler1->deviceInit(linkHandler1->pinNum);
linkHandler1->open(linkHandler1->pinNum);printf("All open\n");}elseif(strstr(socketHandler->command,"DQG")!=NULL){//关闭全部灯
linkHandler1 =findDeviceByName("upstairLight",pdeviceHead);
linkHandler1->close(linkHandler1->pinNum);
linkHandler1 =findDeviceByName("bathroomLight",pdeviceHead);
linkHandler1->close(linkHandler1->pinNum);
linkHandler1 =findDeviceByName("livingroomLight",pdeviceHead);
linkHandler1->close(linkHandler1->pinNum);
linkHandler1 =findDeviceByName("diningroomLight",pdeviceHead);
linkHandler1->close(linkHandler1->pinNum);printf("All closed\n");}elseif(n_read ==-1){perror("read");}}}void*socket_thread(void*datas)//socket线程{int n_read =0;pthread_t readThread;structsockaddr_in c_addr;memset(&c_addr,0,sizeof(structsockaddr_in));int clen =sizeof(structsockaddr_in);
socketHandler =findCommandByName("socketServer",pCommandHead);if(socketHandler ==NULL){printf("find socketHandler error\n");pthread_exit(NULL);}else{printf("%s init success!\n",socketHandler->commandName);}
socketHandler->Init(socketHandler,NULL,NULL);while(1){
c_fd =accept(socketHandler->sfd,(structsockaddr*)&c_addr,&clen);pthread_create(&readThread,NULL,read_thread,NULL);}}void*video_thread(void*datas)//视频监控线程{system("/home/pi/mjpg-streamer/mjpg-streamer-experimental/start.sh");pthread_exit(NULL);}void*fireAlarm_thread(void*datas)//火灾报警线程{int status;structDevices*firetmp =NULL;structDevices*beeptmp =NULL;
firetmp =findDeviceByName("fireAlarm",pdeviceHead);//寻找“火焰传感器”链表节点,返回给firetmp
beeptmp =findDeviceByName("beep",pdeviceHead);//寻找“蜂鸣器”链表节点,返回给buztmpwhile(1){
status = firetmp->readStatus(firetmp->pinNum);//读取“火焰传感器”状态if(status ==0){
beeptmp->deviceInit(beeptmp->pinNum);//检测到火焰或强光源
beeptmp->open(beeptmp->pinNum);//打开蜂鸣器printf("Warning of fire!!!\n");delay(1000);//延时1000毫秒=1秒}if(status ==1){//未检测到火焰、强光源或解除警报
beeptmp->close(beeptmp->pinNum);//关闭蜂鸣器}}}intmain(){//char name[128] = {'\0'};pthread_t voiceThread;pthread_t socketThread;pthread_t fireAlarmThread;pthread_t videoThread;pthread_t cameraThread;structDevices*tmp =NULL;if(wiringPiSetup()==-1){return-1;}//1. 指令工厂初始化
pCommandHead =addVoiceControlToInputCommandLink(pCommandHead);
pCommandHead =addSocketControlToInputCommandLink(pCommandHead);//2. 设备控制工厂初始化
pdeviceHead =addBathroomLightToDeviceLink(pdeviceHead);
pdeviceHead =addUpstairLightToDeviceLink(pdeviceHead);
pdeviceHead =addLivingroomLightToDeviceLink(pdeviceHead);
pdeviceHead =addDiningroomLightToDeviceLink(pdeviceHead);
pdeviceHead =addFireAlarmToDeviceLink(pdeviceHead);
pdeviceHead =addBeepToDeviceLink(pdeviceHead);
pdeviceHead =addLookToDeviceLink(pdeviceHead);
pdeviceHead =addCameraToDeviceLink(pdeviceHead);structDevices*tmpequiphead = pdeviceHead;if(tmpequiphead !=NULL){//设备工厂所有设备初始化
tmpequiphead->deviceInit(tmpequiphead->pinNum);
tmpequiphead = tmpequiphead->next;}//3.池建立//3.1 语音线程//int pthread_create(pthread_t *restrict tidp, const pthread_attr_t *restrict attr, void *(*start_rtn)(void *), void *restrict arg);pthread_create(&voiceThread,NULL,voice_thread,NULL);//3.2 socket线程pthread_create(&socketThread,NULL,socket_thread,NULL);//3.3 摄像头线程//printf("camera_thread1===============\n");pthread_create(&cameraThread,NULL,camera_thread,NULL);//3.4 火灾线程pthread_create(&fireAlarmThread,NULL,fireAlarm_thread,NULL);//3.视频监控 pthread_create(&videoThread,NULL, video_thread,NULL);pthread_join(voiceThread,NULL);pthread_join(socketThread,NULL);pthread_join(cameraThread,NULL);pthread_join(fireAlarmThread,NULL);pthread_join(videoThread,NULL);return0;}
4、upstairLight.c
#include"controlDevices.h"#include<stddef.h>/*struct Devices
{
char deviceName[128];
int status;
int (*open)();
int (*close)();
int (*deviceInit)();
int (*readStatus)()
int (*changeStatus)(int status);
struct Devices *next;
};
*/intupstairLightOpen(int pinNum){digitalWrite(pinNum,HIGH);}intupstairLightClose(int pinNum){digitalWrite(pinNum,LOW);}intupstairLightInit(int pinNum){pinMode(pinNum,OUTPUT);digitalWrite(pinNum,LOW);}intupstairLightStatus(int status){}structDevices upstairLight ={.deviceName ="upstairLight",.pinNum =21,.open = upstairLightOpen,.close = upstairLightClose,.deviceInit = upstairLightInit,.changeStatus = upstairLightStatus,.next =NULL};structDevices*addUpstairLightToDeviceLink(structDevices*phead){if(phead ==NULL){return&upstairLight;}else{
upstairLight.next = phead;
phead =&upstairLight;return phead;}}
5、bathroomLight.c
#include"controlDevices.h"#include<stddef.h>/*struct Devices
{
char deviceName[128];
int status;
int (*open)();
int (*close)();
int (*deviceInit)();
int (*readStatus)()
int (*changeStatus)(int status);
struct Devices *next;
};
*/intbathroomLightOpen(int pinNum){digitalWrite(pinNum,HIGH);}intbathroomLightClose(int pinNum){digitalWrite(pinNum,LOW);}intbathroomLightInit(int pinNum){pinMode(pinNum,OUTPUT);digitalWrite(pinNum,LOW);}intbathroomLightStatus(int status){}structDevices bathroomLight ={.deviceName ="bathroomLight",.pinNum =22,.open = bathroomLightOpen,.close = bathroomLightClose,.deviceInit = bathroomLightInit,.changeStatus = bathroomLightStatus,.next =NULL};structDevices*addBathroomLightToDeviceLink(structDevices*phead){if(phead ==NULL){return&bathroomLight;}else{
bathroomLight.next = phead;
phead =&bathroomLight;return phead;}}
6、livingroomLight.c
#include"controlDevices.h"#include<stddef.h>/*struct Devices
{
char deviceName[128];
int status;
int (*open)();
int (*close)();
int (*deviceInit)();
int (*readStatus)()
int (*changeStatus)(int status);
struct Devices *next;
};
*/intlivingroomLightOpen(int pinNum){digitalWrite(pinNum,HIGH);}intlivingroomLightClose(int pinNum){digitalWrite(pinNum,LOW);}intlivingroomLightInit(int pinNum){pinMode(pinNum,OUTPUT);digitalWrite(pinNum,LOW);}intlivingroomLightStatus(int status){}structDevices livingroomLight ={.deviceName ="livingroomLight",.pinNum =23,.open = livingroomLightOpen,.close = livingroomLightClose,.deviceInit = livingroomLightInit,.changeStatus = livingroomLightStatus,.next =NULL};structDevices*addLivingroomLightToDeviceLink(structDevices*phead){if(phead ==NULL){return&livingroomLight;}else{
livingroomLight.next = phead;
phead =&livingroomLight;return phead;}}
7、diningroomLight.c
#include"controlDevices.h"#include<stddef.h>/*struct Devices
{
char deviceName[128];
int status;
int (*open)();
int (*close)();
int (*deviceInit)();
int (*readStatus)()
int (*changeStatus)(int status);
struct Devices *next;
};
*/intdiningroomLightOpen(int pinNum){digitalWrite(pinNum,HIGH);}intdiningroomLightClose(int pinNum){digitalWrite(pinNum,LOW);}intdiningroomLightInit(int pinNum){pinMode(pinNum,OUTPUT);digitalWrite(pinNum,LOW);}intdiningroomLightStatus(int status){}structDevices diningroomLight ={.deviceName ="diningroomLight",.pinNum =24,.open = diningroomLightOpen,.close = diningroomLightClose,.deviceInit = diningroomLightInit,.changeStatus = diningroomLightStatus,.next =NULL};structDevices*addDiningroomLightToDeviceLink(structDevices*phead){if(phead ==NULL){return&diningroomLight;}else{
diningroomLight.next = phead;
phead =&diningroomLight;return phead;}}
8、fire.c
#include"controlDevices.h"#include<stddef.h>intfireAlarmInit(int pinNum){pinMode(pinNum,INPUT);digitalWrite(pinNum,HIGH);}intfireStatusRead(int pinNum){returndigitalRead(pinNum);}structDevices fireAlarm ={.deviceName ="fireAlarm",.pinNum =25,.deviceInit = fireAlarmInit,.readStatus = fireStatusRead,.next =NULL};structDevices*addFireAlarmToDeviceLink(structDevices*phead){if(phead ==NULL){return& fireAlarm;}else{
fireAlarm.next = phead;
phead =& fireAlarm;}}
9、beep.c
#include"controlDevices.h"structDevices*addBeepToDeviceLink(structDevices*phead);intbeepInit(int pinNum)//初始化函数{pinMode(pinNum,OUTPUT);//配置引脚为输出引脚digitalWrite(pinNum,LOW);//引脚输出低电平,即默认为关闭状态}intbeepOpen(int pinNum)//打开蜂鸣器函数{digitalWrite(pinNum,HIGH);}intbeepClose(int pinNum)//关闭蜂鸣器函数{digitalWrite(pinNum,LOW);}structDevices beep ={//蜂鸣器设备链表节点.deviceName ="beep",.pinNum =27,//树莓派gpio引脚27.deviceInit = beepInit,.open = beepOpen,.close = beepClose,.next =NULL};structDevices*addBeepToDeviceLink(structDevices*phead)//头插法将设备节点加入设备工厂链表函数{if(phead ==NULL){return&beep;}else{
beep.next = phead;
phead =&beep;return phead;}}
10、voiceControl.c
#include"InputCommand.h"#include<wiringPi.h>#include<wiringSerial.h>#include<stdio.h>#include<unistd.h>#include<stdlib.h>#include<string.h>intvoiceGetCommand(structInputCommander*voicer){int nread =0;//memset(voicer->command,'\0',sizeof(voicer->command));
nread =read(voicer->fd,voicer->command,sizeof(voicer->command));if(nread ==0){printf("usart for voice read over time!\n");}else{return nread;//读取到的指令是存放到voicer.command的}}intvoiceInit(structInputCommander*voicer,char*ipAdress,char*port){int fd;//printf("test init1\n");if((fd =serialOpen(voicer->deviceName,9600))==-1)//初始化串口,波特率9600{printf("open serial error\n");exit(-1);}
voicer->fd = fd;return fd;}structInputCommander voiceControl ={.commandName ="voice",.deviceName ="/dev/ttyAMA0",.command ={'\0'},.Init = voiceInit,.getCommand = voiceGetCommand,.log ={'\0'},.next =NULL};structInputCommander*addVoiceControlToInputCommandLink(structInputCommander*phead){if(phead ==NULL){return&voiceControl;}else{
voiceControl.next = phead;
phead =&voiceControl;}}
11、socketControl.c
版权归原作者 sunshime. 所有, 如有侵权,请联系我们删除。