This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "mgos.h" | |
#include "mgos_rpc.h" | |
struct rpc_ipinfo_ctx { | |
struct mg_rpc_request_info *ri; | |
struct mbuf response; | |
}; | |
static void ev_handler(struct mg_connection *nc, int ev, void *ev_data, | |
void *cb_arg) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "mgos.h" | |
#if CS_PLATFORM == CS_P_ESP8266 | |
int8_t wifi_station_get_rssi(void); | |
uint8_t wifi_get_channel(void); | |
#elif CS_PLATFORM == CS_P_ESP32 | |
#include <esp_wifi.h> | |
#endif | |
/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <mgos.h> | |
#include "wifi_common.h" | |
#if CS_PLATFORM == CS_P_ESP8266 | |
int8_t wifi_station_get_rssi(void); | |
uint8_t wifi_get_channel(void); | |
#elif CS_PLATFORM == CS_P_ESP32 | |
#include <esp_wifi.h> | |
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#ifdef __cplusplus | |
extern "C" { | |
#endif | |
struct wifi_info { | |
int8_t rssi; | |
uint8_t channel; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
volatile uint64_t i = 0; | |
struct pin_state { | |
int64_t uptime; | |
bool state; | |
}; | |
static void cb2(void *arg) { | |
const struct pin_state *state = (const struct pin_state *) (arg); | |
LOG(LL_INFO, ("uptime: %lld, state: %d", state->uptime, state->state)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* mos.yml: | |
config_schema: | |
- ["mdash.device", "s", "", {}] | |
- ["mdash.api_key", "s", "", {}] | |
*/ | |
static void mdash_api_handler(struct mg_connection *nc, int ev, void *evd, | |
void *cb_arg) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void print_mgos_ro_vars(struct json_out *out, va_list *ap) { | |
struct mgos_ro_vars *p = va_arg(*ap, struct mgos_ro_vars *); | |
json_printf(out, | |
"{mac_address: %Q, arch: %Q, fw_version: %Q, fw_timestamp: %Q, " | |
"fw_id: %Q}", | |
p->mac_address, p->arch, p->fw_version, p->fw_timestamp, | |
p->fw_id); | |
} | |
static void main_timer_cb(void *arg) { |