首页 \ 问答 \ 通过软件重置ESP8266(Resetting ESP8266 by software)

通过软件重置ESP8266(Resetting ESP8266 by software)

我希望ESP8266 WiFi模块在通过UART接收命令后自行复位。 可以用哪个代码来做到这一点? 是否有像reduce()这样的SDK函数?

我正在使用SMING框架


I would like the ESP8266 WiFi module to reset itself after receiving a command via UART. Which code can one use to do that? Are there SDK functions like reset()?

I am using the SMING framework


原文:https://stackoverflow.com/questions/35079101
更新时间:2023-09-17 14:09

最满意答案

变化:

collection.fetch({ data: { page: 1} });

至:

collection.fetch({ data: $.param({ page: 1}) });

所以,除了这样做,这是以你的{data: {page:1}}对象作为options调用的

Backbone.sync = function(method, model, options) {
    var type = methodMap[method];

    // Default JSON-request options.
    var params = _.extend({
      type:         type,
      dataType:     'json',
      processData:  false
    }, options);

    // Ensure that we have a URL.
    if (!params.url) {
      params.url = getUrl(model) || urlError();
    }

    // Ensure that we have the appropriate request data.
    if (!params.data && model && (method == 'create' || method == 'update')) {
      params.contentType = 'application/json';
      params.data = JSON.stringify(model.toJSON());
    }

    // For older servers, emulate JSON by encoding the request into an HTML-form.
    if (Backbone.emulateJSON) {
      params.contentType = 'application/x-www-form-urlencoded';
      params.processData = true;
      params.data        = params.data ? {model : params.data} : {};
    }

    // For older servers, emulate HTTP by mimicking the HTTP method with `_method`
    // And an `X-HTTP-Method-Override` header.
    if (Backbone.emulateHTTP) {
      if (type === 'PUT' || type === 'DELETE') {
        if (Backbone.emulateJSON) params.data._method = type;
        params.type = 'POST';
        params.beforeSend = function(xhr) {
          xhr.setRequestHeader('X-HTTP-Method-Override', type);
        };
      }
    }

    // Make the request.
    return $.ajax(params);
};

所以它将'data'发送给jQuery.ajax ,它将尽可能地将任何params.data附加到URL。


changing:

collection.fetch({ data: { page: 1} });

to:

collection.fetch({ data: $.param({ page: 1}) });

So with out over doing it, this is called with your {data: {page:1}} object as options

Backbone.sync = function(method, model, options) {
    var type = methodMap[method];

    // Default JSON-request options.
    var params = _.extend({
      type:         type,
      dataType:     'json',
      processData:  false
    }, options);

    // Ensure that we have a URL.
    if (!params.url) {
      params.url = getUrl(model) || urlError();
    }

    // Ensure that we have the appropriate request data.
    if (!params.data && model && (method == 'create' || method == 'update')) {
      params.contentType = 'application/json';
      params.data = JSON.stringify(model.toJSON());
    }

    // For older servers, emulate JSON by encoding the request into an HTML-form.
    if (Backbone.emulateJSON) {
      params.contentType = 'application/x-www-form-urlencoded';
      params.processData = true;
      params.data        = params.data ? {model : params.data} : {};
    }

    // For older servers, emulate HTTP by mimicking the HTTP method with `_method`
    // And an `X-HTTP-Method-Override` header.
    if (Backbone.emulateHTTP) {
      if (type === 'PUT' || type === 'DELETE') {
        if (Backbone.emulateJSON) params.data._method = type;
        params.type = 'POST';
        params.beforeSend = function(xhr) {
          xhr.setRequestHeader('X-HTTP-Method-Override', type);
        };
      }
    }

    // Make the request.
    return $.ajax(params);
};

So it sends the 'data' to jQuery.ajax which will do its best to append whatever params.data is to the URL.

相关问答

更多
  • 实现此目的的最简单方法是在Coupon模型上覆盖Backbone的url方法,并使用您定义的方法。 例如,你可以这样做: Affiliates.Coupon = Backbone.Model.extend({ urlRoot : "server/somecontroller/", url : function(){ var url = this.urlRoot + this.id; if(this.get("type")){ url = url + "/?type=" + ...
  • 这通常是IE上的问题,骨干与它无关。 你必须去查看jQuery ajax调用并查看文档。 Backbone使用jquery ajax作为其sync方法。 您可以这样做,以强制所有浏览器上的ajax调用: $.ajaxSetup({ cache: false }); http://api.jquery.com/jQuery.ajaxSetup/ This is a problem on IE usually and backbone has nothing to do with it. You have t ...
  • @ Paul的答案是好的,但也值得注意的是, url属性可以是一个函数。 在我看来(这只是意见,因为最终的结果是一样的),代码更清晰,如果更详细,如果你设置id在initialize和引用它在一个函数: var Messages = Backbone.Collection.extend({ initialize: function(models, options) { this.id = options.id; }, url: function() { return '/mess ...
  • TLDR / CLIFFS: 下面奇怪的小行用于确定天气,错误回调是由模型级别的验证失败,或者来自fetch,save或destroy方法(全部调用Backbone.sync)的失败的AJAX调用触发的。 如果失败来自验证,则它不会更改resp变量,因为resp应该已经包含validate返回的有用信息(例如错误数组或有关错误的字符串)。 如果失败来自错误的AJAX请求,则XHR对象将存储到resp中,因为XHR是可用信息量最大的项目。 不幸的是,XHR作为模型传递给了这个函数,Backbone文档没有指出 ...
  • 变化: collection.fetch({ data: { page: 1} }); 至: collection.fetch({ data: $.param({ page: 1}) }); 所以,除了这样做,这是以你的{data: {page:1}}对象作为options调用的 Backbone.sync = function(method, model, options) { var type = methodMap[method]; // Default JSON-request ...
  • Controller从您的浏览器接收请求并将数据放入ActiveRecord: def create document = Trainer.create! params[:trainer] ... end 但是你在日志中看到请求, params[:trainer]等于空哈希{} 您可以使用类似哈希的方式更改它创建json的javascript { 'trainer': {'name' : 'Lori stevens', ... }} 我不知道这对骨干有多么容易。 或者,您可以更改控制器,使其从哈 ...
  • 如果你想在成功时执行一些回调函数,你可以在你的View中订阅'sync'事件(如果你在那里调用fetch): var view = new Backbone.View.extend({ initialize: function() { this.listenTo(this.collection, 'sync', this.yourFirstCallback); }, yourFirstCallback: function() { //code of yourFirstCalbac ...
  • 如果您的模型不是集合的一部分,请指定Model.urlRoot而不是url 。 Backbone将自动生成格式为[urlRoot]/id的URL。 class Raffler.Models.Entry extends Backbone.Model urlRoot: '/api/entries' 如果您的模型是集合的一部分,则无需设置url或urlRoot 。 请改为指定collection.url ,Backbone将自动推断该集合中所有模型的URL。 If your model is not p ...
  • 好的 我得到了什么问题.....正在发生的事情是,我正在调用JSON对象的Java_Servlet以文本格式而不是JSON返回数据...(但它是一个有效的JSON字符串)...并且在调用ajax方法时我将类型设置为'json',因此它失败了。 感谢所有阅读我的问题并想出解决方案的人。 但我观察到一个奇怪的事情,相同的代码是在生产而不是在我的本地机器上工作??? 有没有人知道为什么它会表现得那样...... ??? 谢谢:)现在我可以睡得好!! Okay I got what was the issue... ...
  • Backbone有自己的api用于与服务器通信,例如fetch,save,destory。事实上,这些方法与jQuery的$ .ajax做同样的事情。 例如,您以这种方式使用backbone的fetch: var UserModel = Backbone.Model.extend({ url : "rootURL/user", }); var user = new UserModel; user.fetch( data:{ userId : 1, ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)