Toy Info
getMyToysInfo
Description
Get the information of toy list.
Parameters
Attribute Type Default Required Introduction success function No Callback function for successful API call fail function No Callback function for failed API call Success callback function will receive an object with the following attributes:
Attribute Type Introduction toyList Array Toy List Success callback function received parameters data example:
{ "toyList": [ { "showName": "Lush", "alias": "mylove", "firmwareVersion": "", "type": "lush", "toyId": "6c5cb14619b1", "battery": "98", "status": "0", "isSupportFeedbackMode": true, "sendOrder": function (v) {}, "stop": function () {} }, { "showName": "Ridge", "alias": "", "firmwareVersion": "", "type": "ridge", "toyId": "e0798d436ab4", "battery": "98", "status": "1", "isSupportFeedbackMode": true, "sendOrder": function (v) {}, "stop": function () {} } ] }
Fail callback function will receive an object with the following attributes:
Attribute | Type | Introduction |
---|---|---|
code | string | Error code |
msg | string | Error message |
Example
const toyManager = appGallery.getToyManager() // Get the toy information toyManager.getMyToysInfo({ success(res) { console.log(res.toyList) }, fail(err) { console.error(err.code) console.error(err.msg) }, })
getMyToysInfoAsync
Description
The Promisify version of getMyToysInfo.
Return Values
Promise
Example
const toyManager = appGallery.getToyManager() toyManager.getMyToysInfoAsync().then(res=>{ console.log(res.toyList) }).catch(err=>{ console.error(err.code) console.error(err.msg) })
onMyToysChange
- Description
Set up a listener to receive updates on the connection status or quantity of toys. This will allow you to retrieve the latest information about your toys.
Parameters
Attribute Type Default Required Introduction callback function Yes Listener function for toy connection status or quantity changes. The callback function will receive an object with the following attributes:
Attribute Type Introduction toyList Array Toy List Example
const toyManager = appGallery.getToyManager() // Listen to changes in my toys toyManager.onMyToysChange(function (res) { console.log(res.toyList) })
openMyToysDialog
Description
Open the pop-up window of my toy page.
Example
const toyManager = appGallery.getToyManager() // Open My Toy Page toyManager.openMyToysDialog()
Toy List
When using getMyToysInfo
to get toy list or onMyToysChange
to listen for changes in the toy list, you will get data related to the toy list.
For each item in a toy list are as follows:
Attribute | Type | Introduction |
---|---|---|
showName | string | Toy Name |
alias | string | Toy Alias, empty string if not available |
firmwareVersion | string | Toy Firmware Version |
type | string | Toy Type, lowercase letters |
toyId | string | Toy MAC Address, lowercase letters, e.g. 6c5cb14619b1 |
battery | string | Toy Battery Level, percentage value without the percentage sign |
status | string | Toy Connection Status ("-1": Disconnected, "0": Connecting, "1": Connected) |
isSupportFeedbackMode | boolean | Toy Feedback Mode Support (true/false) |
sendOrder | function | Send simple command (0-100). Parameter: number or object. If it is a number, it is automatically converted to a complete command. If it is an object, it is executed by a specific command, for example, {v: value, t: value}. |
stop | function | Stop toy vibration |