20160122_jeffrey - silenceuncrio/diary GitHub Wiki

Index

  • 0955 - IoT-早上跟 Ward 把繼電器跟插座實際接了起來
  • 1050 - 南京物联传感技术有限公司-是個強勁的指標對手
  • 1055 - 讓 SQLite 在 IoT 這一塊發光發熱
  • 1330 - 準備個 sql file 建立 IoT Platform 需要的 table
  • 1400 - 跟 CURL 串起來

0955

早上跟 Ward 把繼電器跟插座實際接了起來
半小時就搞定了
超有成就感ㄚ... 那種扎實的感覺

1050

昨天開完 IoT 週會後

手上拿著一本 南京物联传感技术有限公司 的型錄

剛剛隨手翻了翻... 是個強勁的指標對手
跟著他們的腳步做產品就對了
光型錄的編排就相當有參考價值

1055

扎扎實實的讓 SQLite 在 IoT 這一塊發光發熱吧

1330

來準備個 sql file 建立我們 IoT Platform 需要的 table

昨天已經將 table 的 definitions 準備好了

CREATE TABLE Boxes (
    BoxId         INTEGER   PRIMARY KEY   NOT NULL,
    BoxName       TEXT   NOT NULL,
    BoxLocation   TEXT   NOT NULL,
    BoxConfig_    TEXT   NOT NULL
);

CREATE TABLE Things (
    ThingId        INTEGER   PRIMARY KEY,
    ThingType      INTEGER   NOT NULL,
    ThingStatus_   TEXT   NOT NULL,
    BoxId          INTEGER   NOT NULL   REFERENCES Boxes( BoxId )
);

CREATE TABLE OpenDetectors (
    OpenId        INTEGER   PRIMARY KEY,
    OpenConfig_   TEXT   NOT NULL,
    OpenStatus_   TEXT   NOT NULL,
    ThingId       INTEGER   NOT NULL   REFERENCES Things( ThingId )
);

加工一下

iot_init.sql

BEGIN TRANSACTION;

CREATE TABLE IF NOT EXISTS Boxes (
    BoxId         INTEGER   PRIMARY KEY   NOT NULL,
    BoxName       TEXT   NOT NULL,
    BoxLocation   TEXT   NOT NULL,
    BoxConfig_    TEXT   NOT NULL
);

CREATE TABLE Things (
    ThingId        INTEGER   PRIMARY KEY,
    ThingType      INTEGER   NOT NULL,
    ThingStatus_   TEXT   NOT NULL,
    BoxId          INTEGER   NOT NULL   REFERENCES Boxes( BoxId )
);

CREATE TABLE OpenDetectors (
    OpenId        INTEGER   PRIMARY KEY,
    OpenConfig_   TEXT   NOT NULL,
    OpenStatus_   TEXT   NOT NULL,
    ThingId       INTEGER   NOT NULL   REFERENCES Things( ThingId )
);

COMMIT;

手動新增個幾筆資料吧

sqlite> INSERT INTO Boxes(BoxId, BoxName, BoxLocation, BoxConfig_) VALUES(1, 'Ward', 'front door', 'mode: on');
sqlite> INSERT INTO Things(ThingId, ThingType, ThingStatus_, BoxId) VALUES(1, 0, 'status...', 1);
sqlite> INSERT INTO OpenDetectors(OpenId, OpenConfig_, OpenStatus_, ThingId) VALUES(1, 'open config ...', 'open status ...', 1);
sqlite> .tables
Boxes          OpenDetectors  Things
sqlite> select * from boxes;
BoxId       BoxName     BoxLocation  BoxConfig_
----------  ----------  -----------  ----------
1           Ward        front door   mode: on
sqlite> select * from things;
ThingId     ThingType   ThingStatus_  BoxId
----------  ----------  ------------  ----------
1           0           status...     1
sqlite> select * from opendetectors;
OpenId      OpenConfig_      OpenStatus_      ThingId
----------  ---------------  ---------------  ----------
1           open config ...  open status ...  1
sqlite>

1400

來跟前幾天的 CURL - example - get_common.c 串起來