Skip to content

Instantly share code, notes, and snippets.

#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) {
#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
/*
#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
@nliviu
nliviu / wifi_common.h
Created February 16, 2020 16:40
wifi_common.h
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
struct wifi_info {
int8_t rssi;
uint8_t channel;
};
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));
@nliviu
nliviu / mdash_api.c
Created August 2, 2019 11:13
Create mdash labels
/*
* 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) {
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) {