Provide DAN of IoTtalk2.0 and some examples.
The library will export a global variable window.iottalkjs
.
We provide minified file served from GitHub pages:
<script src="https://iottalk.github.io/iottalk-js/iottalkjs-v2.3.1.js"></script>
There is a pointer for latest master build, it's unstable. Please use it at your own risk.
<script src="https://iottalk.github.io/iottalk-js/iottalkjs.js"></script>
The full build artifacts are here: https://github.com/IoTtalk/iottalk-js/tree/gh-pages
- Dummy_Device
- Dummy_Device_Table: A much pretty demo of Dummy_Device.
- Smartphone DA: This is a demo of event-driven push.
npm i iottalk-js
or
yarn add iottalk-js
options
is an object
:
apiUrl
(string
): The CSM API URL.deviceModel
(string
)deviceName
(string
)deviceAddr
(string
): Should be a valid UUID string.persistentBinding
(bool
): Default isfalse
.username
(string
): The DA owner.extraSetupWebpage
(string
)deviceWebpage
(string
)onRegister
(function
): A callback function with signaturefunction (dan)
. The first argument is the instance ofiottalkjs.DAN.Client
.onDeregister
(function
): A callback function with signaturefunction (dan)
.onConnect
(function
): A callback invoked on MQTT broker connected. The signature isfunction (dan)
.onDisconnect
(function
): A callback function with signaturefunction (dan)
.pushInterval
(number
): The push interval in second.interval
(object
): The key is the device feature name instring
.idfList
(Array
): Should be a list ofidf, unit
pairs. Where aidf, unit
pair can be following format:[<function pointer>, <unit>]
: e.g.:[Dummy_Sensor, ['dB']]
[<df name>, <unit>]
: In this case, since the function pointer is not provided, the auto-push won't be applied. Please checkout the Smartphone example.
odfList
(Array
)
Example:
const Dummy_Sensor = () => { ... };
const Dummy_Control = () => { ... };
const da = new iottalkjs.DAI({
apiUrl: 'https://example.com/csm',
deviceModel: 'Dummy_Device',
deviceName: 'MyMagicDevice',
deviceAddr: '0a14943f-cc88-4f36-a441-dc3f42f03546',
persistentBinding: true,
idfList: [[Dummy_Sensor, ['dB']]],
odfList: [[Dummy_Control, ['dB']]],
});
Example of DF name conversion, the valid underscore suffix (_) in function name will be converted to df naming rules (-):
const Acceleration_I = () => { ... };
const da = new iottalkjs.DAI({
...
idfList: [Acceleration_I, ['g']],
inverval: {
'Acceleration-I': 42,
},
});
const da = new iottalkjs.DAI({ ... });
da.run();
idf
(string
): Name of outgoing IDF.data
The following command will output the build module into dir build-web
and build-node
.
yarn
yarn run build
For nodejs only build, there is a target build:node
.
For web only build, there is a target build:web
.
yarn login
yarn run build
rm examples/Dummy_Device/build examples/smartphone/build # the symlinks block the publishing
yarn publish
git checkout -- examples/Dummy_Device/build examples/smartphone/build