message.js 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. module.exports = {
  2. getPosition: getPosition,
  3. getDeviceInfo: getDeviceInfo,
  4. }
  5. // payloads.other: {"songInfoID":"843265795768623127","songFrom":"4","songAlbumID":"","artist":"巴洛克古典乐","title":"巴洛克古典乐","url":"http://speed.radio1964.cn/hls/1fmottosbaroquemusicradiozug.m3u8","albumURI":"http://airsmart-photo1.oss-cn-shanghai.aliyuncs.com/img/20211122/98101225b3cb4a0fb5728159ce4ca6d5.png","realUrl":"http://speed.radio1964.cn/hls/1fmottosbaroquemusicradiozug.m3u8","channel":5,"Duration":0,"RelTime":0,"PlayState":1,"PlayMode":0,"SongType":2,"userid":"1","channelType":1,"platformId":4,"platformName":"海外电台","isVip":0,"playable":1,"unplayableMsg":"","unplayableCode":0,"vipIconType":0,"vipIconTypeName":""}
  6. function getPosition(other, canllback) {
  7. var actionIndex = null;
  8. const strings = require('../strings');
  9. var channelData = getCurrentPages()[0].getChannelData();
  10. if (!strings.isEmpty(channelData)) {
  11. channelData.map((v, index) => {
  12. if (v.channelNum === other.channel) {
  13. actionIndex = index;
  14. }
  15. });
  16. }
  17. canllback(actionIndex);
  18. };
  19. // payloads.other: {"Guid":"AIrSMArT_7cdfa1fd3af0","ProdModel":"MW-2AX(WIFI)","sim_iccid":"","esim_iccid":"","SoftVer":"3.0.7","Firmware":"RTOS","Power":50,"lowBatteryNtf":0,"Volume":27,"Mute":0,"pauseShutdown":0,"PlayState":1,"PlayMode":0,"devName":"猫王小王子OTR-X","deviceId":"","deviceSecret":"","is_tts_enable":1,"SignalQuality":100,"CardIndex":0,"CardSum":0,"NetModel":2,"is_netmode_auto":2,"Imei":"","mid":"","deviceDSN":"1044250776739909632","userid":"1","user_id_white":"1039072","alarm":[{"alarm_id":"0","alarm_name":"open","current_timestamp":"2024-12-12 00:00:00","on_off_timestamp":"16:19:25","operation":"on","song_uri":"","weekly_repeat":"0","enable":"0","action":"update","week_actives":[0,0,0,0,0,0,0]},{"alarm_id":"1","alarm_name":"open","current_timestamp":"2024-12-11 20:00:48","on_off_timestamp":"07:00:00","operation":"on","song_uri":"","weekly_repeat":"0","enable":"1","action":"update","week_actives":[0,0,0,0,0,0,0]}]}
  20. function getDeviceInfo(payloads) {
  21. var other = payloads.other;
  22. var SrcDeviceName = payloads.SrcDeviceName;
  23. ///连上就调用2次 payloads.SrcDeviceName:AIrSMArT_7cdfa1fcbb24
  24. var deviceList = getCurrentPages()[0].getDeviceList();
  25. if (!strings.isEmpty(deviceList)) {
  26. var currentDeviceId = "";
  27. /// 获取需要连接的那个设备,获取设备名称
  28. for (var i = 0; i < deviceList.length; i++) {
  29. if (SrcDeviceName) {
  30. var device = deviceList[i];
  31. var deviceId = device.deviceId;
  32. var splitDeviceId = deviceId.split("BLUFI_");
  33. if (splitDeviceId.length == 2) {
  34. var index = SrcDeviceName.indexOf(splitDeviceId[1]);
  35. ///彻底连接成功
  36. if (index !== -1) {
  37. currentDeviceId = deviceId;
  38. var ProdModel = other.ProdModel;
  39. var devName = other.devName;
  40. if (device.ProdModel != ProdModel || device.devName != devName) {
  41. isUpdate = true;
  42. device.ProdModel = ProdModel;
  43. device.devName = devName;
  44. }
  45. break;
  46. }
  47. }
  48. }
  49. }
  50. /// 去更新选中目标
  51. if (!strings.isEmpty(currentDeviceId)) {
  52. for (var i = 0; i < deviceList.length; i++) {
  53. var device = deviceList[i];
  54. var deviceId = device.deviceId;
  55. if (deviceId == currentDeviceId) {
  56. getCurrentPages()[0].refreshCurrentDevice(device);
  57. break;
  58. }
  59. }
  60. }
  61. }
  62. };