Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bd26045
commit 002949d
Showing
22 changed files
with
1,820 additions
and
128 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
target remote :3333 | ||
mon reset halt | ||
thb app_main | ||
x $a1=0 | ||
c |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* Hello World Example | ||
This example code is in the Public Domain (or CC0 licensed, at your option.) | ||
Unless required by applicable law or agreed to in writing, this | ||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
CONDITIONS OF ANY KIND, either express or implied. | ||
*/ | ||
#include <stdio.h> | ||
|
||
#include "freertos/FreeRTOS.h" | ||
#include "freertos/task.h" | ||
|
||
#include "ble.h" | ||
#include "kv.h" | ||
#include "wifi.h" | ||
#include "time.h" | ||
#include "led.h" | ||
|
||
#define VERSION "v0.1" | ||
|
||
void app_main() { | ||
printf("Welcome to chronic-o-matic firmware %s\n", VERSION); | ||
|
||
init_kv(); | ||
init_ble(); | ||
init_wifi(); | ||
init_time(); | ||
init_led(); | ||
|
||
fflush(stdout); | ||
while(1) vTaskDelay(10); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
This example code is in the Public Domain (or CC0 licensed, at your option.) | ||
Unless required by applicable law or agreed to in writing, this | ||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
CONDITIONS OF ANY KIND, either express or implied. | ||
*/ | ||
|
||
#ifndef BLE_H_ | ||
#define BLE_H_ | ||
|
||
#include "ble_db.h" | ||
|
||
void init_ble(); | ||
void notify_handle(enum idx i, const uint8_t *notify_data, uint16_t notify_data_length); | ||
void notify_attr(enum idx i); | ||
|
||
void set_attr_value(enum idx i, const uint8_t *value, uint16_t value_length); | ||
|
||
#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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* ===================================================================================== | ||
* | ||
* Filename: ble_api.c | ||
* | ||
* Description: | ||
* | ||
* Version: 1.0 | ||
* Created: 05/9/2018 15:47:31 | ||
* Revision: none | ||
* Compiler: gcc | ||
* | ||
* Author: YOUR NAME (), | ||
* Organization: | ||
* | ||
* ===================================================================================== | ||
*/ | ||
|
||
#include "ble.h" | ||
#include "ble_utils.h" | ||
|
||
void notify_handle(enum idx i, const uint8_t *notify_data, uint16_t notify_data_length) { | ||
if (profile_tab[PROFILE_APP_IDX].gatts_if == ESP_GATT_IF_NONE || profile_tab[PROFILE_APP_IDX].conn_id == UINT16_MAX) return; | ||
|
||
ESP_ERROR_CHECK(esp_ble_gatts_send_indicate(profile_tab[PROFILE_APP_IDX].gatts_if, profile_tab[PROFILE_APP_IDX].conn_id, handle_table[i], notify_data_length, (uint8_t *)notify_data, false)); | ||
} | ||
|
||
void set_attr_value(enum idx i, const uint8_t *value, uint16_t value_length) { | ||
ESP_ERROR_CHECK(esp_ble_gatts_set_attr_value(handle_table[i], value_length, value)); | ||
} | ||
|
||
void notify_attr(enum idx i) { | ||
if (profile_tab[PROFILE_APP_IDX].gatts_if == ESP_GATT_IF_NONE || profile_tab[PROFILE_APP_IDX].conn_id == UINT16_MAX) return; | ||
|
||
const uint8_t *value; | ||
uint16_t value_length; | ||
|
||
ESP_ERROR_CHECK(esp_ble_gatts_get_attr_value(handle_table[i], &value_length, &value)); | ||
notify_handle(i, value, value_length); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* ===================================================================================== | ||
* | ||
* Filename: ble_db.c | ||
* | ||
* Description: | ||
* | ||
* Version: 1.0 | ||
* Created: 05/09/2018 11:58:37 | ||
* Revision: none | ||
* Compiler: gcc | ||
* | ||
* Author: YOUR NAME (), | ||
* Organization: | ||
* | ||
* ===================================================================================== | ||
*/ | ||
|
||
#include "ble_db.h" | ||
|
||
#include "ble_utils.h" | ||
#include "time.h" | ||
|
||
const esp_gatts_attr_db_t gatt_db[HRS_IDX_NB] = | ||
{ | ||
// Time Service Declaration | ||
[IDX_TIME_SVC] = | ||
{{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_16, (uint8_t *)&primary_service_uuid, ESP_GATT_PERM_READ, | ||
ESP_UUID_LEN_16, sizeof(TIME_SERVICE), (uint8_t *)TIME_SERVICE}}, | ||
|
||
R_I_NOTIFIABLE_CHAR(IDX_CHAR_TIME, IDX_CHAR_VAL_TIME, IDX_CHAR_CFG_TIME, TIME_UUID), | ||
R_I_NOTIFIABLE_CHAR(IDX_CHAR_SIMULATED_TIME, IDX_CHAR_VAL_SIMULATED_TIME, IDX_CHAR_CFG_SIMULATED_TIME, SIMULATED_TIME_UUID), | ||
RW_I_CHAR(IDX_CHAR_START_DATE_MONTH, IDX_CHAR_VAL_START_DATE_MONTH, START_DATE_MONTH_UUID), | ||
RW_I_CHAR(IDX_CHAR_START_DATE_DAY, IDX_CHAR_VAL_START_DATE_DAY, START_DATE_DAY_UUID), | ||
RW_I_CHAR(IDX_CHAR_DURATION_DAYS, IDX_CHAR_VAL_DURATION_DAYS, DURATION_DAYS_UUID), | ||
RW_I_CHAR(IDX_CHAR_SIMULATION_DURATION_DAYS, IDX_CHAR_VAL_SIMULATION_DURATION_DAYS, SIMULATION_DURATION_DAYS_UUID), | ||
RW_I_CHAR(IDX_CHAR_STARTED_AT, IDX_CHAR_VAL_STARTED_AT, STARTED_AT_UUID) | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* ===================================================================================== | ||
* | ||
* Filename: ble_db.h | ||
* | ||
* Description: | ||
* | ||
* Version: 1.0 | ||
* Created: 05/09/2018 11:57:38 | ||
* Revision: none | ||
* Compiler: gcc | ||
* | ||
* Author: YOUR NAME (), | ||
* Organization: | ||
* | ||
* ===================================================================================== | ||
*/ | ||
|
||
#ifndef BLE_DB_H_ | ||
#define BLE_DB_H_ | ||
|
||
#include "esp_gatts_api.h" | ||
|
||
enum idx | ||
{ | ||
IDX_TIME_SVC, | ||
|
||
IDX_CHAR_TIME, | ||
IDX_CHAR_VAL_TIME, | ||
IDX_CHAR_CFG_TIME, | ||
|
||
IDX_CHAR_SIMULATED_TIME, | ||
IDX_CHAR_VAL_SIMULATED_TIME, | ||
IDX_CHAR_CFG_SIMULATED_TIME, | ||
|
||
IDX_CHAR_START_DATE_MONTH, | ||
IDX_CHAR_VAL_START_DATE_MONTH, | ||
|
||
IDX_CHAR_START_DATE_DAY, | ||
IDX_CHAR_VAL_START_DATE_DAY, | ||
|
||
IDX_CHAR_DURATION_DAYS, | ||
IDX_CHAR_VAL_DURATION_DAYS, | ||
|
||
IDX_CHAR_SIMULATION_DURATION_DAYS, | ||
IDX_CHAR_VAL_SIMULATION_DURATION_DAYS, | ||
|
||
IDX_CHAR_STARTED_AT, | ||
IDX_CHAR_VAL_STARTED_AT, | ||
|
||
HRS_IDX_NB, | ||
}; | ||
|
||
extern const esp_gatts_attr_db_t gatt_db[HRS_IDX_NB]; | ||
|
||
#endif |
Oops, something went wrong.