c_cpp 谷歌事件,track.ino
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了c_cpp 谷歌事件,track.ino相关的知识,希望对你有一定的参考价值。
// Copyright Nat Weerawan 2015-2016
// MIT License
#include <ESP8266WiFi.h>
#include <WiFiConnector.h>
#include <ESPert.h>
WiFiConnector *wifi;
ESPert espert;
#define WIFI_SSID "Nat"
#define WIFI_PASSPHARSE "devicenetwork"
uint8_t SMARTCONFIG_BUTTON_PIN = 2;
const char *host = "www.google-analytics.com";
const int httpPort = 80;
String path = "/collect?v=1&t=event&tid=UA-53466330-1&cid=hello&dh=www.cmmakerclub.com&ec=ESPresso%20Lite&ea=Motion%20Sensor&cm5=1&el=Move!";
espert.println( ">>" + espert.wifi.getHTTP( host, path.c_str() ) + "<<" );
#include "init_wifi.h"
void init_hardware()
{
Serial.begin(115200);
delay(1000);
Serial.println();
Serial.println();
Serial.println();
Serial.println();
Serial.println("will be started in 500ms..");
espert.init();
delay(500);
}
void setup()
{
init_hardware();
wifi = init_wifi(WIFI_SSID, WIFI_PASSPHARSE, SMARTCONFIG_BUTTON_PIN);
Serial.println("BEING CONNECTED TO: ");
Serial.println(String(wifi->SSID() + ", " + wifi->psk()));
Serial.print("SMARTCONFIG PIN: ");
Serial.println(SMARTCONFIG_BUTTON_PIN);
Serial.print("CORE FN()");
Serial.println(String(WiFi.SSID() + ", " + WiFi.psk()));
Serial.print("OK ?");
wifi->on_connecting([&](const void* message)
{
Serial.print("STATE: CONNECTING -> ");
Serial.println(wifi->counter);
delay(500);
});
wifi->on_connected([&](const void* message)
{
// Print the IP address
Serial.print("WIFI CONNECTED WITH IP: ");
Serial.println(WiFi.localIP());
espert.println("Button: On");
espert.led.on();
espert.println( "Connecting..." );
String path = "/collect?v=1&t=event&tid=UA-????????-1&cid=hello&dh=www.cmmakerclub.com&ec=ESPresso%20Lite&ea=Motion%20Sensor&cm5=1&el=Move!";
espert.println( ">>" + espert.wifi.getHTTP( host, path.c_str() ) + "<<" );
// espert.led.on();
ESP.deepSleep(999999 * 1000000);
});
wifi->connect();
}
void loop()
{
espert.loop();
wifi->loop();
}
以上是关于c_cpp 谷歌事件,track.ino的主要内容,如果未能解决你的问题,请参考以下文章