Basic app running now
This commit is contained in:
parent
e03ea33bcd
commit
0c0413cb2c
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"files.associations": {
|
||||
"buttonhandler.h": "c"
|
||||
}
|
||||
}
|
|
@ -26,4 +26,8 @@
|
|||
|
||||
<p align="center">
|
||||
<img src="https://mongoose-os.com/images/app1.gif" width="75%">
|
||||
</p>
|
||||
</p>
|
||||
|
||||
## Functionality
|
||||
|
||||
- Button on device: Push toggles the relay. LED is on for about 2 seconds to signal, push button has been recognized.
|
||||
|
|
8
mos.yml
8
mos.yml
|
@ -45,9 +45,9 @@ config_schema:
|
|||
# - ["http.document_root", "/"]
|
||||
# - ["http.hidden_files", "s_*"]
|
||||
# - ["http.auth_file", "s_pass"]
|
||||
# - ["wifi.ap.enable", true]
|
||||
# - ["wifi.ap.ssid", "SONOFF_??????"]
|
||||
# - ["wifi.ap.pass", "MySonoff"]
|
||||
- ["wifi.ap.enable", true]
|
||||
- ["wifi.ap.ssid", "SONOFF_??????"]
|
||||
- ["wifi.ap.pass", "MySonoff"]
|
||||
- ["wifi.sta.enable", true]
|
||||
- ["wifi.sta.ssid", "Pinguin"]
|
||||
- ["wifi.sta.pass", "PaulchenAufmKlo34"]
|
||||
|
@ -60,7 +60,7 @@ config_schema:
|
|||
|
||||
build_vars:
|
||||
# sonoff basic has 1MBytes flash only
|
||||
# FLASH_SIZE: 1048576
|
||||
FLASH_SIZE: 1048576
|
||||
|
||||
tags:
|
||||
- c
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
static void buttonPressOne(int pressCount) {
|
||||
LOG(LL_DEBUG, ("buttonPressOne called with pressCount=%d", pressCount));
|
||||
set_relay(RELAY_TOGGLE);
|
||||
set_led_status(LED_ONCE);
|
||||
}
|
||||
|
||||
static void buttonPressTwo(int pressCount) {
|
||||
|
@ -21,6 +22,10 @@ static void buttonPressThree(int pressCount) {
|
|||
LOG(LL_DEBUG, ("buttonPressThree called with pressCount=%d", pressCount));
|
||||
}
|
||||
|
||||
static void on_board_led_off_cb(void *arg) {
|
||||
(void) arg;
|
||||
set_led_status(LED_OFF);
|
||||
}
|
||||
enum mgos_app_init_result mgos_app_init(void) {
|
||||
init_led_handler();
|
||||
set_led_status(LED_BLINK_FAST);
|
||||
|
@ -30,5 +35,6 @@ enum mgos_app_init_result mgos_app_init(void) {
|
|||
add_button_press_callback(3, buttonPressThree);
|
||||
init_mqtt_handler();
|
||||
LOG(LL_INFO, ("SONOFF app initialized"));
|
||||
mgos_set_timer(5000, 0, on_board_led_off_cb, NULL);
|
||||
return MGOS_APP_INIT_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ static void pubMqttStatus(char *event) {
|
|||
event,
|
||||
mgos_get_free_heap_size(),
|
||||
relay_is_on() ? "true" : "false");
|
||||
mgos_mqtt_pub(pubTopic, msg, strlen(msg), MG_MQTT_QOS(0));
|
||||
mgos_mqtt_pub(pubTopic, msg, strlen(msg), MG_MQTT_QOS(0), true);
|
||||
//mg_mqtt_publish(c, get_cfg()->mqtt.pub, 0, MG_MQTT_QOS(0), msg, n);
|
||||
LOG(LL_DEBUG, ("MQTT pub topic=%s -> %s", pubTopic, msg));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue