Skip to content

Instantly share code, notes, and snippets.

@duythien
Last active November 29, 2018 07:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save duythien/b4a6df38a087a1208080e8d87b2185ca to your computer and use it in GitHub Desktop.
Save duythien/b4a6df38a087a1208080e8d87b2185ca to your computer and use it in GitHub Desktop.
iot

Tham số bắt buộc

Cần cung cấp thông tin tenantId và token để lây data, để lấy các tham số đó liện hệ qua hello@faciot.com hoặc fcduythien@gmail.com

http://api.faciot.com/v1/data_devices?tenantId=xxx&token=xxxx

Gửi data

Gửi data theo phương thức POST http://api.faciot.com/v1/data_devices/new?tenantId=xxxx&token=xxxxx

{
    "message" : "Máy sản xuất bị hổng",
    "devices_id": "02:42:40:5d:f6:ca",
    "status": "delivered",
    "keycode": "xxxxx"
}

Kiểm tra trạng thái

Để kiểm tra trạng thái các máy sensor nhà xưởng có bị lỗi hay không bạn gửi một request GET http://api.faciot.com/v1/devices/status?tenantId=1&keycode=A, thì kết quả trả về

{
   "status":"delivered",
   "items":{
      "id":"1",
      "status":"delivered",
      "devicesId":"02:42:b5:a4:62:ef",
      "message":"Máy đàng bị hư",
      "customMessage":null,
      "name":"Server status 1B",
      "keycode":"A",
      "tenantId":"1"
   }
}

Có nghĩa là có một máy nào đó đang bị hư, nếu status là click thì máy đó ok

Kiểm tra chi tiết một sensor

Để kiểm tra trạng thái thiết bị(sensor) có bị hư hay không, bạn gửi một request GET http://api.faciot.com/v1/data_devices?tenantId=1&devicesId=02:42:40:5d:f6:ca

{
  "data": [
    {
      "id": "2",
      "status": "click",
      "devicesId": "02:42:40:5d:f6:ca",
      "message": "0",
      "customMessage": null,
      "name": "Server status 1A",
      "tenantId": "1"
    }
  ],
  "meta": {
    "pagination": {
      "total": 1,
      "count": 1,
      "per_page": 1,
      "current_page": 1,
      "total_pages": 1,
      "links": {}
    }
  }
}

Trong đó field status dùng để kiểm tra

  • click: tức có người đang xuống kiểm tra máy
  • delivered: máy đang hỏng cần có người xuống kiểm tra, lúc này cần báo động tiếng chuông cho bộ phận kỹ thuật b

Frontend

rồi sau đó http://dev.faciot.com:8000/ để coi thây đổi

nếu muốn change màu sắc thì thây đôi "delivered" thành "click" và ngược lai

Có thể dung window để test https://www.getpostman.com/

@duythien
Copy link
Author

selection_027

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment