Skip to content

Instantly share code, notes, and snippets.

@sankarcheppali
sankarcheppali / main.c
Created November 28, 2020 08:18
esp-idf clear bluetooth devices
void remove_all_bonded_devices(void)
{
int dev_num = esp_ble_get_bond_device_num();
esp_ble_bond_dev_t *dev_list = (esp_ble_bond_dev_t *)malloc(sizeof(esp_ble_bond_dev_t) * dev_num);
esp_ble_get_bond_device_list(&dev_num, dev_list);
for (int i = 0; i < dev_num; i++) {
esp_ble_remove_bond_device(dev_list[i].bd_addr);
}
free(dev_list);
@sankarcheppali
sankarcheppali / serial-api-blink.ino
Last active August 23, 2020 11:45
control arduino on board led using serial api
@sankarcheppali
sankarcheppali / blue_pill_dino_player.ino
Created June 14, 2020 12:35
blue pill based dino player
#define KEYBOARD_ENABLE_CONTROL PB2
#define LDR_PIN PA4
#define LDR_OBSTACLE_THRESHOLD 980
#include "Keyboard.h"
void setup() {
Serial.begin(115200);
pinMode(LDR_PIN,INPUT);
pinMode(KEYBOARD_ENABLE_CONTROL,INPUT);
import 'package:flutter/material.dart';
import 'package:path/path.dart';
import 'package:image_picker/image_picker.dart';
import 'dart:io';
import 'dart:async';
import 'package:dio/dio.dart';
/**
* accepts two parameters,the endpoint and the file
@sankarcheppali
sankarcheppali / MainActivity.kt
Created July 1, 2017 10:26
Connecting WiFi programmatically
package example.siva.com.hellokotlin
import android.content.BroadcastReceiver
import android.content.Context
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import kotlinx.android.synthetic.main.activity_main.*
import org.jetbrains.anko.toast
import android.net.wifi.WifiConfiguration
@sankarcheppali
sankarcheppali / Pair.java
Created December 28, 2019 06:41
Generic pair class
public class Pair<T,R> {
private T key;
private R value;
public Pair(T key, R value) {
this.key = key;
this.value = value;
}
public T getKey() {
@sankarcheppali
sankarcheppali / esp32_serial_mqtt_pub_sub.ino
Last active September 22, 2018 14:15
esp32 will publish message received from serial line to mqtt broker, writes messages received from mqtt broker to serial line
#include <WiFi.h>
#include <PubSubClient.h>
// Update these with values suitable for your network.
const char* ssid = "SSID";
const char* password = "pwd";
const char* mqtt_server = "iot.eclipse.org";
#define mqtt_port 1883
#define MQTT_USER "username"
@sankarcheppali
sankarcheppali / nodemcu_serial_mqtt_publish.ino
Created April 13, 2018 16:12
read UART data and send messages to MQTT broker
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
// Update these with values suitable for your network.
const char* ssid = "SSID";
const char* password = "password";
const char* mqtt_server = "iot.eclipse.org";
#define mqtt_port 1883
#define MQTT_USER "mqtt username"
@sankarcheppali
sankarcheppali / esp32_mqtt_led_on_off.ino
Last active March 1, 2018 09:44
control leds using ESP32 and MQTT
#include <WiFi.h>
#include <PubSubClient.h>
#include <ArduinoJson.h>
// Update these with values suitable for your network.
const char* ssid = "SSID";
const char* password = "PASSWORD";
const char* mqtt_server = "iot.eclipse.org";
#define mqtt_port 1883
#define MQTT_USER "username"
@sankarcheppali
sankarcheppali / arduino_nodemcu_mqtt_serial_bridge.ino
Last active January 28, 2018 16:38
arduino code for nodemcu/esp8266 for connecting to mqtt broker. It can receive and send messages to MQTT broker
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
// Update these with values suitable for your network.
const char* ssid = "SSID";
const char* password = "passowrd";
const char* mqtt_server = "iot.eclipse.org";
#define mqtt_port 1883
#define MQTT_USER "username"