Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiple sensors #256

Open
wants to merge 47 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
6082ecd
Create motion_sensor.c
sakisdog Jan 22, 2019
21da2f0
Create Makefile
sakisdog Jan 22, 2019
f3262a0
Added wifi_config
sakisdog Jan 22, 2019
5b76eb1
Added wifi_ncif
sakisdog Jan 22, 2019
f0804ca
Create multiple_sensors.c
sakisdog Jan 22, 2019
87e3df0
Create Makefile
sakisdog Jan 22, 2019
e85792c
Update multiple_sensors.c
sakisdog Jan 22, 2019
9471a7d
Update multiple_sensors.c
sakisdog Jan 22, 2019
77e066b
Update motion_sensor.c
sakisdog Jan 22, 2019
fe9d7c1
Update motion_sensor.c
sakisdog Jan 22, 2019
3214b3a
Update multiple_sensors.c
sakisdog Jan 22, 2019
e124891
Create contact_sensor.c
sakisdog Jan 23, 2019
14f1d1b
Create Makefile
sakisdog Jan 23, 2019
7b08990
Update Makefile
sakisdog Jan 23, 2019
43e8305
Update contact_sensor.c
sakisdog Jan 23, 2019
6a9a9e2
Update multiple_sensors.c
sakisdog Jan 26, 2019
41e2c82
Update multiple_sensors.c
sakisdog Jan 26, 2019
a52947b
Update contact_sensor.c
sakisdog Jan 26, 2019
4c11218
Update motion_sensor.c
sakisdog Jan 26, 2019
9185601
Update multiple_sensors.c
sakisdog Jan 26, 2019
bb77f10
Update multiple_sensors.c
sakisdog Jan 26, 2019
e07352e
Update multiple_sensors.c
sakisdog Jan 26, 2019
097a282
Update contact_sensor.c
sakisdog Jan 28, 2019
a5670e4
Update multiple_sensors.c
sakisdog Jan 28, 2019
2c4356c
Merge pull request #1 from maximkulkin/master
sakisdog Feb 21, 2019
4cd0e20
Merge pull request #2 from maximkulkin/master
sakisdog Mar 11, 2019
834a53b
Merge pull request #3 from maximkulkin/master
sakisdog Mar 17, 2019
ca1e38a
Experimental edit to resolve no response problem
sakisdog Mar 18, 2019
3fcd2b3
update test
sakisdog Mar 19, 2019
220e706
Merge pull request #4 from maximkulkin/master
sakisdog Mar 23, 2019
68ee8f3
update makefile
sakisdog Mar 23, 2019
c922597
Update Makefile
sakisdog Mar 23, 2019
3fa61b7
Update Makefile
sakisdog Mar 23, 2019
00ebb91
updated stack size
sakisdog Apr 13, 2019
deb82c1
minor changes
sakisdog Apr 20, 2019
f188f9a
Minor fixes
sakisdog Apr 25, 2019
47ba06f
Update components
Nov 6, 2019
b0d747d
Merge remote-tracking branch 'maximkulkik/master'
Nov 10, 2019
3b7f0fb
Update homeki component
Dec 19, 2019
1e969a2
Added temperature sensor oled
Jan 25, 2020
2ddac84
Merge remote-tracking branch 'maximkulkin/master'
Jan 25, 2020
b9c6623
Delete old files
Jan 25, 2020
d7ad8e4
Thermostat oled with buttons ESP-WROOM-02
Jan 25, 2020
ded9c04
Minor fixes for Thermostat oled with buttons ESP-WROOM-02
Jan 25, 2020
bfbc357
Minor changes
Feb 15, 2020
443b883
Minor changes
Feb 22, 2020
c0417bf
Added led strip animation with wifi config
Feb 22, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/common/homekit
Submodule homekit updated 1 files
+1 −1 component.mk
2 changes: 1 addition & 1 deletion components/esp8266-open-rtos/cJSON
Submodule cJSON updated 1 files
+9 −0 CMakeLists.txt
2 changes: 1 addition & 1 deletion components/esp8266-open-rtos/led-status
19 changes: 19 additions & 0 deletions examples/contact_sensor/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
PROGRAM = contact_sensor

EXTRA_COMPONENTS = \
extras/http-parser \
extras/dhcpserver \
$(abspath ../../components/esp-8266/wifi_config) \
$(abspath ../../components/common/wolfssl) \
$(abspath ../../components/common/cJSON) \
$(abspath ../../components/common/homekit)

FLASH_SIZE ?= 32
FLASH_MODE ?= dout

EXTRA_CFLAGS += -I../.. -DHOMEKIT_SHORT_APPLE_UUIDS

include $(SDK_PATH)/common.mk

monitor:
$(FILTEROUTPUT) --port $(ESPPORT) --baud 115200 --elf $(PROGRAM_OUT)
108 changes: 108 additions & 0 deletions examples/contact_sensor/contact_sensor.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
#define DEVICE_MANUFACTURER "Unknown"
#define DEVICE_NAME "Contact-Sensor"
#define DEVICE_MODEL "esp8266"
#define DEVICE_SERIAL "12345678"
#define FW_VERSION "1.0"
#define CONTACT_SENSOR_GPIO 4
#define LED_GPIO 2

#include <stdio.h>
#include <espressif/esp_wifi.h>
#include <espressif/esp_sta.h>
#include <espressif/esp_common.h>
#include <esp/uart.h>
#include <esp8266.h>
#include <FreeRTOS.h>
#include <task.h>
#include <queue.h>
#include <string.h>

#include <homekit/homekit.h>
#include <homekit/characteristics.h>
#include <wifi_config.h>

homekit_characteristic_t name = HOMEKIT_CHARACTERISTIC_(NAME, DEVICE_NAME);
homekit_characteristic_t manufacturer = HOMEKIT_CHARACTERISTIC_(MANUFACTURER, DEVICE_MANUFACTURER);
homekit_characteristic_t serial = HOMEKIT_CHARACTERISTIC_(SERIAL_NUMBER, DEVICE_SERIAL);
homekit_characteristic_t model = HOMEKIT_CHARACTERISTIC_(MODEL, DEVICE_MODEL);
homekit_characteristic_t revision = HOMEKIT_CHARACTERISTIC_(FIRMWARE_REVISION, FW_VERSION);
homekit_characteristic_t sensor_state = HOMEKIT_CHARACTERISTIC_(CONTACT_SENSOR_STATE, 0);

void led_write(bool on) {
gpio_write(LED_GPIO, on ? 0 : 1);
}

void identify_task(void *_args) {
// We identify the board by Flashing it's LED.
for (int i=0; i<1; i++) {
for (int j=0; j<2; j++) {
led_write(true);
vTaskDelay(100 / portTICK_PERIOD_MS);
led_write(false);
vTaskDelay(100 / portTICK_PERIOD_MS);
}

vTaskDelay(250 / portTICK_PERIOD_MS);
}
led_write(false);
vTaskDelete(NULL);
}

void identify() {
printf("identify\n\n");
xTaskCreate(identify_task, "identify", 128, NULL, 2, NULL);
}

homekit_accessory_t *accessories[] = {
HOMEKIT_ACCESSORY(.id=1, .category=homekit_accessory_category_sensor, .services=(homekit_service_t*[]){
HOMEKIT_SERVICE(ACCESSORY_INFORMATION, .characteristics=(homekit_characteristic_t*[]){
&name,
&manufacturer,
&serial,
&model,
&revision,
HOMEKIT_CHARACTERISTIC(IDENTIFY, identify),
NULL
}),
HOMEKIT_SERVICE(CONTACT_SENSOR, .primary=true, .characteristics=(homekit_characteristic_t*[]){
HOMEKIT_CHARACTERISTIC(NAME, "Contact Sensor"),
&sensor_state,
NULL
}),
NULL
}),
NULL
};

void contact_sensor_callback(uint8_t gpio) {
if (gpio == CONTACT_SENSOR_GPIO){
int new = 0;
new = gpio_read(CONTACT_SENSOR_GPIO);
identify();
sensor_state.value = HOMEKIT_UINT8(new);
homekit_characteristic_notify(&sensor_state, HOMEKIT_UINT8(new));
}
else {
printf("Interrupt on %d", gpio);
}
}

void gpio_init() {
gpio_enable(LED_GPIO, GPIO_OUTPUT);
gpio_enable(CONTACT_SENSOR_GPIO, GPIO_INPUT);
gpio_set_pullup(CONTACT_SENSOR_GPIO, true, true);
gpio_set_interrupt(CONTACT_SENSOR_GPIO, GPIO_INTTYPE_EDGE_ANY, contact_sensor_callback);
}
homekit_server_config_t config = {
.accessories = accessories,
.password = "111-11-111"
};

void on_wifi_ready() {
homekit_server_init(&config);
}
void user_init(void) {
uart_set_baud(0, 115200);
wifi_config_init("contact-sensor", NULL, on_wifi_ready);
gpio_init();
}
29 changes: 29 additions & 0 deletions examples/led_strip_animation_wifi/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
PROGRAM = led_strip_animation

EXTRA_COMPONENTS = \
extras/http-parser \
extras/i2s_dma \
extras/ws2812_i2s \
extras/dhcpserver \
$(abspath ../../components/esp8266-open-rtos/cJSON) \
$(abspath ../../components/common/wolfssl) \
$(abspath ../../components/common/homekit) \
$(abspath ../../components/common/button) \
$(abspath ../../components/esp8266-open-rtos/wifi_config) \
$(abspath ../../components/esp8266-open-rtos/WS2812FX)

FLASH_SIZE ?= 32
# FLASH_SIZE ?= 8
# HOMEKIT_SPI_FLASH_BASE_ADDR ?= 0x7A000
HOMEKIT_SPI_FLASH_BASE_ADDR=0x7A000

EXTRA_CFLAGS += -I../.. -DHOMEKIT_SHORT_APPLE_UUIDS

include $(SDK_PATH)/common.mk
include $(abspath ../../wifi.h)

LIBS += m

monitor:
$(FILTEROUTPUT) --port $(ESPPORT) --baud 115200 --elf $(PROGRAM_OUT)

Loading