提供一个开放和统一的框架,通过 Web 互连物联网设备、数据和应用程序,如果您需要软件和硬件之间的通信,可能您的位置就在这里。
主要目标是使用高级编程语言以及协议和低级细节的抽象来监视和控制廉价硬件,如Arduino、ESP8266、RaspberryPI 和类似平台,本地(离线)或云端。
[hidecontent type="logged" desc="隐藏内容:登录后可查看"]
#include <OpenDevice.h>
void setup(){
ODev.name("ODevSerial");
ODev.addDevice("LED1", 13, Device::DIGITAL);
ODev.begin(); // by default call Serial.begin() and while(!Serial) on Leonardo
}
void loop(){
ODev.loop();
}
#include <ESP8266WiFi.h> // Enable ESP8266 Wifi
#include <PubSubClient.h> // MQTT
#include <ArduinoOTA.h> // Enable Remote Updates
#include <OpenDevice.h>
const char* ssid = "ap-name";
const char* password = "1";
void setup() {
ODev.enableDebug();
ODev.name("ODev-Thing1");
ODev.apiKey("6bde80c3");
ODev.server("192.168.3.106"); // MQTT Remote server
ODev.addDevice("Thing1:LED", 2, Device::DIGITAL);
WiFi.mode(WIFI_AP_STA);
WiFi.begin(ssid, password);
ODev.begin(WiFi);
}
void loop() {
ODev.loop();
}
配置的设备将使用任何可用连接(usb、蓝牙、wifi、mqtt)自动与服务器同步
服务器作为独立应用程序运行,您也可以使用docker运行
您可以使用客户端库直接(USB、蓝牙)或通过服务器(MQTT)使用 Java/Android/Javascript 或 Rest 控制设备
public class BlinkDeviceDemo extends LocalDeviceManager {
public static void main(String[] args) { launch(args); }
public void start() throws IOException {
Device led = new Device(1, Device.DIGITAL);
connect(out.usb()); // Connect to first USB port available
while(true){
led.on();
delay(500);
led.off();
delay(500);
}
}
}
但不仅如此…… (你也可以用 javascript 和其他语言来做。)
[/hidecontent]