树莓派与Android端APP进行有线通信并实现控制与反馈

如何实现通信

首先,我们要意识到一点,Android与树莓派都是独立的linux系统,二者通信其实是两台独立设备之间的通信,可以有三种方式:
1)有线通信
2)无线通信
3)蓝牙通信

1、基于USB有线通信方式下的Android设备控制树莓派

设置树莓派

Add the following lines into your network configuration:

vi /etc/network/interfaces
allow-hotplug usb0
iface usb0 inet dhcp

When you would have already connected all devices, and you do not want to reboot, just restart the network:

/etc/init.d/networking restart

连接安卓设备

Connect your Android Tablet to a Raspberry Pi USB port via a micro-USB cable. Power your Raspberry Pi with a standard USB power supply. You can use any DC USB power supply.

设置安卓允许USB分享

Enable USB tethering on your Android tablet.

Settings → Connections → Tethering and Wi-Fi hotspot → USB tethering

Now the Raspberry automatically gets an IP address via its USB0 port. The Android tablet behaves like a NAT router. This should work both when your tablet is connected to Wi-Fi or to a mobile 3G/4G network.

2、基于***无线通信***方式下的Android设备控制树莓派

在树莓派上安装相应的服务器框架,实现GET/POST请求响应

3、基于***蓝牙通信***方式下的Android设备控制树莓派

基于GATT通信协议,实现蓝牙连接;
在树莓派中写好响应命令,在安卓设备备中发送请求调用相应的请求
具体参考书籍2

参考:
1、https://elinux.org/How_to_use_an_Android_tablet_as_a_Raspberry_Pi_console_terminal_and_internet_router
2、书籍 Raspberry Pi Android Peoject

  • 0
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值