Giter Club home page Giter Club logo

iot-simulator's Introduction

IoT Simulator

==========

Description

You can quickly turn your phone(or any other device) into an Aliyun IoT device within 10 lines.

Follow the following steps:
  1. Visit Iot Console and create an advanced product.(REMEMBER YOUR PRODUCT KEY)
  2. Define functions of your product. For example, we can search and add a GeoLocation(地理位置)
  3. Visit Linkdevelop Console and create a project.
  4. Create a web application and put them in api.json.(AppKey and AppSecret is an important identity do api request)
Coding:
    public static void main(String[] args) {
        //去阿里云官网上创建一个产品,设置好地理位置属性。可以变相用做分组
        String productKey = "<your productKey>";
        String deviceName = "anyDeviceName";
        //自动创建设备的构造方法
        Simulator simulator = new Simulator(productKey, deviceName);
        //如果已经有了三元组(productKey, deviceName, deviceSecret)可以使用下面的构造方法
        // Simulator simulator = new Simulator("<your productKey>", "<your deviceName>", "<your deviceSecret>");
        simulator.connect(msgJson -> {
            System.out.println("received: " + msgJson);
            //可以变相当成mq使用,执行收到消息之后的逻辑

        });
        //可以放在带有定位的设备中,手机,手表等等。通过api获取经纬度上报
        UplinkMessage uplinkMessage = new UplinkMessage()
            .put("GeoLocation", new GeoLocation(122.250852f,30.193851f, 12f, 2));
            //可以根据产品定义上报额外属性
            //.put("PM25", 60)
            //.put("CO2Value", 123)
            //.put("HeatSwitch", 0)
            //.put("LightSwitch", 1);
        simulator.uplink(uplinkMessage);
    }
create you map

visit https://iot.console.aliyun.com/scene to create a scene. you will see your device's location.

enjoy!

iot-simulator's People

Contributors

hanl754 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.