**

微信小程序+阿里云+stm32f407的一个项目##

小程序参考了大神半颗心脏的博客和资料,
小程序多个页面推送数据
因为自己做小程序是类似商城的一个demo,
其中数据需要与单片机进行交互,而且需要再两个页面进行交互,
只能把连接阿里云的部分放在app.js中,通过使用 onfire.js 这个东西来实现多个页面实时监听app.js中的数据,
代码部分

其中小程序联网接阿里云那部分也是参考了那个博主的巧借阿里云物联网平台的免费连接,从微信小程序颜色采集控制 esp8266 输出七彩灯效果
这个文章,可以去博主的github中下载源码,
下面贴出 onfire.js 的源码

/**Copyright (c) 2016 hustcc http://www.atool.org/License: MIT https://github.com/hustcc/onfire.js
**/
/* jshint expr: true */
!function (root, factory) {if (typeof module === 'object' && module.exports)module.exports = factory();elseroot.onfire = factory();
}(typeof window !== 'undefined' ? window : this, function () {var __onfireEvents = {},__cnt = 0, // evnet counterstring_str = 'string',function_str = 'function',hasOwnKey = Function.call.bind(Object.hasOwnProperty),slice = Function.call.bind(Array.prototype.slice);function _bind(eventName, callback, is_one, context) {if (typeof eventName !== string_str || typeof callback !== function_str) {throw new Error('args: '+string_str+', '+function_str+'');}if (! hasOwnKey(__onfireEvents, eventName)) {__onfireEvents[eventName] = {};}__onfireEvents[eventName][++__cnt] = [callback, is_one, context];return [eventName, __cnt];}function _each(obj, callback) {for (var key in obj) {if (hasOwnKey(obj, key)) callback(key, obj[key]);}}/***  onfire.on( event, func, context ) -> Object*  - event (String): The event name to subscribe / bind to*  - func (Function): The function to call when a new event is published / triggered*  Bind / subscribe the event name, and the callback function when event is triggered, will return an event Object**/function on(eventName, callback, context) {return _bind(eventName, callback, 0, context);}/***  onfire.one( event, func, context ) -> Object*  - event (String): The event name to subscribe / bind to*  - func (Function): The function to call when a new event is published / triggered*  Bind / subscribe the event name, and the callback function when event is triggered only once(can be triggered for one time), will return an event Object**/function one(eventName, callback, context) {return _bind(eventName, callback, 1, context);}function _fire_func(eventName, args) {if (hasOwnKey(__onfireEvents, eventName)) {_each(__onfireEvents[eventName], function(key, item) {item[0].apply(item[2], args); // do the functionif (item[1]) delete __onfireEvents[eventName][key]; // when is one, delete it after triggle});}}/***  onfire.fire( event[, data1 [,data2] ... ] )*  - event (String): The event name to publish*  - data...: The data to pass to subscribers / callbacks*  Async Publishes / fires the the event, passing the data to it's subscribers / callbacks**/function fire(eventName) {// fire eventsvar args = slice(arguments, 1);setTimeout(function () {_fire_func(eventName, args);});}/***  onfire.fireSync( event[, data1 [,data2] ... ] )*  - event (String): The event name to publish*  - data...: The data to pass to subscribers / callbacks*  Sync Publishes / fires the the event, passing the data to it's subscribers / callbacks**/function fireSync(eventName) {_fire_func(eventName, slice(arguments, 1));}/*** onfire.un( event ) -> Boolean*  - event (String / Object): The message to publish* When passed a event Object, removes a specific subscription.* When passed event name String, removes all subscriptions for that event name(hierarchy)** Unsubscribe / unbind an event or event object.** Examples**  // Example 1 - unsubscribing with a event object*  var event_object = onfire.on('my_event', myFunc);*  onfire.un(event_object);**  // Example 2 - unsubscribing with a event name string*  onfire.un('my_event');**/function un(event) {var eventName, key, r = false, type = typeof event;if (type === string_str) {// cancel the event name if existif (hasOwnKey(__onfireEvents, event)) {delete __onfireEvents[event];return true;}return false;}else if (type === 'object') {eventName = event[0];key = event[1];if (hasOwnKey(__onfireEvents, eventName) && hasOwnKey(__onfireEvents[eventName], key)) {delete __onfireEvents[eventName][key];return true;}// can not find this event, return falsereturn false;}else if (type === function_str) {_each(__onfireEvents, function(key_1, item_1) {_each(item_1, function(key_2, item_2) {if (item_2[0] === event) {delete __onfireEvents[key_1][key_2];r = true;}});});return r;}return true;}/***  onfire.clear()*  Clears all subscriptions**/function clear() {__onfireEvents = {};}return {on: on,one: one,un: un,fire: fire,fireSync: fireSync,clear: clear};
});

其中小程序的后台数据库用的是微信小程序云开发,参考的是哔哩哔哩上的编程小石头的视频
讲的非常好,自己是一点基础都没有就学会了,
stm32f407连接阿里云这部分的工程是自己在网上找的103的例程修改的,有需要的私聊我,转载说明出处。
邮箱:2549368652@qq.com

微信小程序+阿里云+stm32f407的一个项目相关推荐

  1. 最详细的【微信小程序+阿里云Web服务】开发部署指引(十一):开发小程序设置功能

    文章目录 前言 一.功能说明 二.设置界面代码实现 1.创建界面Page 2.WXML 3.JS 4.WXSS 三.参数控制逻辑代码实现 1.自动跳转卡片 2.自动播放声音 专题文章链接 前言 案例的 ...

  2. 最详细的【微信小程序+阿里云Web服务】开发部署指引(四):搭建服务端数据库

    文章目录 前言 一.连接主机数据库 二.创建数据表结构 三.准备测试数据 专题文章链接 前言 做完了前面的注册申请工作,今天我们开始进行程序的开发. 这篇文章,我们要完成的是服务端数据库表的创建. 一 ...

  3. 最详细的【微信小程序+阿里云Web服务】开发部署指引(一):准备开始

    文章目录 前言 案例说明 专题文章链接 前言 作为一个程序开发的老鸟,有时候想使用微信小程序,开发实现一些实用的小功能.由于小程序往往需要有后台数据的支持,所以一般还需要搭建一个Server服务器,来 ...

  4. 最详细的【微信小程序+阿里云Web服务】开发部署指引(十二):开发小程序用户反馈功能

    文章目录 前言 一.功能说明 二.代码实现 1.创建界面Page 2.WXML 3.JS 4.WXSS 专题文章链接 前言 案例的运行效果,可以扫码观看: 本篇文章,我们将实现应用的用户反馈功能. 一 ...

  5. 微信小程序 阿里云服务器 非物联网平台自建MQTT代理服务器控制树莓派LED

    微信小程序 阿里云服务器 非物联网平台自建MQTT代理服务器控制树莓派LED 本人大三,临近毕业季,日后希望从事物联网和嵌入式相关工作,所以自己构想了一个项目来练手,之前做大创的时候学了一点微信小程序 ...

  6. 新手如何用微信小程序和云数据库做一个论坛?【帖子页】

    新手小白用微信小程序和云数据库做一个论坛[帖子页] 先放个效果图 由于后面换了头像,所以评论的头像和发帖的头像不一样. 要做个同款论坛,首先需要用到云数据库.在微信开发者工具的左上角开通云开发就可以了 ...

  7. 最详细的【微信小程序+阿里云Web服务】开发部署指引(八):开发小程序卡片类型呈现功能

    文章目录 前言 一.功能说明 二.代码实现 1.创建主界面Page 2.WXML 2.JS 3.WXSS 4.合法域名校验 5.图片缓存刷新问题的解决 小结 专题文章链接 前言 本篇文章,将对照专题案 ...

  8. 记录一次微信小程序+阿里云oss的配置步骤和方法

    网上的文档搜索了无数,结果还是得靠自己摸索,都讲不到重点,折腾了两天,现在公布出来. 网站防盗链,如果使用了微信小程序的话记得加入防盗链白名单servicewechat.com,宝塔面板直接防盗链设置 ...

  9. 微信小程序-基于云开发实现社区项目(Demo版本的升级)

    针对上一版 [微信小程序~云开发的实现的一个社区 Demo(完结~)] 项目的问题,做了问题修复和功能优化以及UI美化,起码整体界面效果看起来不那么"程序员"了.同时还新增了很多小 ...

最新文章

  1. substrate 区块链框架 (1)概述
  2. 单例模式懒汉、饿汉和登记
  3. ECMAScript 6 里面的私有变量
  4. iis configuration error
  5. Web服务软件工厂(WSSF)演练之三:创建服务契约和实现方法
  6. alidata 手动挂载数据盘
  7. numpy中array的维度之-------一维向量和一维数组的区别。
  8. ARKit 和 ARCore概念介绍
  9. i9 9900es版,QQC0满载功耗测试
  10. Share Your Music - HTML5 Music Web App
  11. 说说远程团队协作的故事
  12. 论坛mysql cpu100_解决 MYSQL CPU 占用 100% 的经验总结
  13. Java类和对象的特征
  14. python内容推荐理由_好书推荐~第5期 | Python 数据可视化
  15. 一文深入浅出读懂NoSQL
  16. dedecms(织梦cms)安装99bill(快钱)支付方式接口
  17. 控制结构(强化):18.今夕何夕
  18. 如何稍后在YouTube上使用观看
  19. Nwafu-OJ-1411 Problem J C语言实习题二——5.按从大到小排序三个数
  20. 22-0001 淘宝店铺搜索界面

热门文章

  1. 流媒体服务新手入门教程01--什么是流媒体服务及m7s介绍
  2. astrolog php,Astrolog星象学软件使用指南(2)
  3. 风格对照表的制作与使用
  4. java中map嵌套map_java中遍历MAP,嵌套map的几种方法
  5. Linux---线程互斥和同步
  6. 微信JavaEye老炮群的入群标准-2009年之前注册JavaEye的技术人员
  7. fire温度压力测试软件,3Dmark
  8. react项目中在线预览附件
  9. 移动WEB - 自我总结
  10. shell脚本中export命令未生效,原因详解