mirror of
https://github.com/RoCry/blozi-etag.git
synced 2026-05-08 13:34:05 +08:00
Compiling warning fixes and Humidity removing
This commit is contained in:
Binary file not shown.
@@ -205,16 +205,17 @@ static int print(char **out, const char *format, va_list args) {
|
||||
return pc;
|
||||
}
|
||||
|
||||
//extern void puts(const char* str);
|
||||
int u_printf(const char *format, ...) {
|
||||
static char my_printf_buff[1024] = { 0 };
|
||||
char *out = &my_printf_buff[0];
|
||||
|
||||
extern void puts(char* s);
|
||||
|
||||
va_list args;
|
||||
va_start(args, format );
|
||||
print(&out, format, args);
|
||||
puts(my_printf_buff);
|
||||
//puts(my_printf_buff);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int u_sprintf(char *out, const char *format, ...) {
|
||||
|
||||
@@ -162,6 +162,7 @@ void gpio_init(int anaRes_init_en);
|
||||
* @return none.
|
||||
*/
|
||||
void gpio_set_func(GPIO_PinTypeDef pin, GPIO_FuncTypeDef func);
|
||||
void gpio_set_func2(GPIO_PinTypeDef pin, GPIO_FuncTypeDef func);
|
||||
|
||||
/**
|
||||
* @brief This function set the output function of a pin.
|
||||
|
||||
@@ -179,10 +179,10 @@ typedef void (*blt_event_callback_t)(u8 e, u8 *p, int n);
|
||||
|
||||
|
||||
my_fifo_t blt_rxfifo;
|
||||
u8 blt_rxfifo_b[];
|
||||
//u8 blt_rxfifo_b[];
|
||||
|
||||
my_fifo_t blt_txfifo;
|
||||
u8 blt_txfifo_b[];
|
||||
//u8 blt_txfifo_b[];
|
||||
//////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
//user define
|
||||
#ifndef BLT_SOFTWARE_TIMER_ENABLE
|
||||
#define BLT_SOFTWARE_TIMER_ENABLE 0 //enable or disable
|
||||
#define BLT_SOFTWARE_TIMER_ENABLE 1 //enable or disable
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -48,7 +48,8 @@ GCC_FLAGS := \
|
||||
-std=gnu99 \
|
||||
-funsigned-char \
|
||||
-fshort-wchar \
|
||||
-fms-extensions
|
||||
-fms-extensions \
|
||||
-Wno-unused
|
||||
|
||||
INCLUDE_PATHS := -I$(TEL_PATH)/components -I$(PROJECT_PATH)
|
||||
|
||||
|
||||
@@ -66,11 +66,8 @@ RAM u8 my_batVal[1] = {100};
|
||||
//////////////////////// Temp /////////////////////////////////////////////////
|
||||
static const u16 my_tempServiceUUID = 0x181A;
|
||||
static const u16 my_tempCharUUID = 0x2A1F;
|
||||
static const u16 my_humiCharUUID = 0x2A6F;
|
||||
static u8 tempValueInCCC[2];
|
||||
RAM u8 my_tempVal[2] = {0};
|
||||
static u8 humiValueInCCC[2];
|
||||
RAM u8 my_humiVal[2] = {0};
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
static const u8 my_OtaUUID[16] = TELINK_SPP_DATA_OTA;
|
||||
@@ -84,10 +81,6 @@ static const u16 my_RxTx_ServiceUUID = 0x1f10;
|
||||
static u8 my_RxTx_Data = 0x00;
|
||||
static u8 RxTxValueInCCC[2];
|
||||
|
||||
//0x95FE
|
||||
static const u16 my_FE95_ServiceUUID = 0xFE95;
|
||||
static const u8 my_MiName[] = {'M', 'i'};
|
||||
|
||||
// Include attribute (Battery service)
|
||||
static const u16 include[3] = {BATT_PS_H, BATT_LEVEL_INPUT_CCB_H, SERVICE_UUID_BATTERY};
|
||||
|
||||
@@ -130,13 +123,6 @@ static const u8 my_tempCharVal[5] = {
|
||||
U16_LO(0x2A1F), U16_HI(0x2A1F)
|
||||
};
|
||||
|
||||
//// Humi attribute values
|
||||
static const u8 my_humiCharVal[5] = {
|
||||
CHAR_PROP_READ | CHAR_PROP_NOTIFY,
|
||||
U16_LO(HUMI_LEVEL_INPUT_DP_H), U16_HI(HUMI_LEVEL_INPUT_DP_H),
|
||||
U16_LO(0x2A6F), U16_HI(0x2A6F)
|
||||
};
|
||||
|
||||
//// OTA attribute values
|
||||
#define TELINK_SPP_DATA_OTA1 0x12,0x2B,0x0d,0x0c,0x0b,0x0a,0x09,0x08,0x07,0x06,0x05,0x04,0x03,0x02,0x01,0x00
|
||||
static const u8 my_OtaCharVal[19] = {
|
||||
@@ -182,10 +168,6 @@ static const attribute_t my_Attributes[] = {
|
||||
{0,ATT_PERMISSIONS_READ,2,sizeof(my_tempCharVal),(u8*)(&my_characterUUID), (u8*)(my_tempCharVal), 0}, //prop
|
||||
{0,ATT_PERMISSIONS_READ,2,sizeof(my_tempVal),(u8*)(&my_tempCharUUID), (u8*)(my_tempVal), 0}, //value
|
||||
{0,ATT_PERMISSIONS_RDWR,2,sizeof(tempValueInCCC),(u8*)(&clientCharacterCfgUUID), (u8*)(tempValueInCCC), 0}, //value
|
||||
|
||||
{0,ATT_PERMISSIONS_READ,2,sizeof(my_humiCharVal),(u8*)(&my_characterUUID), (u8*)(my_humiCharVal), 0}, //prop
|
||||
{0,ATT_PERMISSIONS_READ,2,sizeof(my_humiVal),(u8*)(&my_humiCharUUID), (u8*)(my_humiVal), 0}, //value
|
||||
{0,ATT_PERMISSIONS_RDWR,2,sizeof(humiValueInCCC),(u8*)(&clientCharacterCfgUUID), (u8*)(humiValueInCCC), 0}, //value
|
||||
////////////////////////////////////// OTA /////////////////////////////////////////////////////
|
||||
// 002e - 0031
|
||||
{4,ATT_PERMISSIONS_READ, 2,16,(u8*)(&my_primaryServiceUUID), (u8*)(&my_OtaServiceUUID), 0},
|
||||
|
||||
@@ -6,7 +6,7 @@ extern "C" {
|
||||
|
||||
#define CLOCK_SYS_CLOCK_HZ 24000000
|
||||
|
||||
#define ADVERTISING_INTERVAL 3000
|
||||
#define ADVERTISING_INTERVAL 300
|
||||
|
||||
#define RAM _attribute_data_retention_ // short version, this is needed to keep the values in ram after sleep
|
||||
|
||||
@@ -52,10 +52,6 @@ typedef enum
|
||||
TEMP_LEVEL_INPUT_CD_H, //UUID: 2803, VALUE: Prop: Read | Notify
|
||||
TEMP_LEVEL_INPUT_DP_H, //UUID: 2A19 VALUE: tempVal
|
||||
TEMP_LEVEL_INPUT_CCB_H, //UUID: 2902, VALUE: tempValCCC
|
||||
|
||||
HUMI_LEVEL_INPUT_CD_H, //UUID: 2803, VALUE: Prop: Read | Notify
|
||||
HUMI_LEVEL_INPUT_DP_H, //UUID: 2A19 VALUE: humiVal
|
||||
HUMI_LEVEL_INPUT_CCB_H, //UUID: 2902, VALUE: humiValCCC
|
||||
|
||||
//// Ota ////
|
||||
/**********************************************************************************************/
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
RAM uint8_t ble_connected = 0;
|
||||
|
||||
extern uint8_t my_tempVal[2];
|
||||
extern uint8_t my_humiVal[2];
|
||||
extern uint8_t my_batVal[1];
|
||||
|
||||
RAM uint8_t blt_rxfifo_b[64 * 8] = {0};
|
||||
@@ -27,17 +26,6 @@ RAM my_fifo_t blt_txfifo = { 40, 16, 0, 0, blt_txfifo_b,};
|
||||
|
||||
RAM uint8_t ble_name[] = {11, 0x09, 'E', 'S', 'L', '_', '0', '0', '0', '0', '0', '0'};
|
||||
|
||||
RAM bool show_temp_humi_Mi = true;
|
||||
|
||||
RAM uint8_t advertising_data_Mi[] = {
|
||||
/*Description*/21, 0x16, 0x95, 0xfe,
|
||||
/*Start*/0x50, 0x30,
|
||||
/*Device id*/0x5B, 0x05,
|
||||
/*counter*/0x00,
|
||||
/*MAC*/0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
/*Temp+Humi*//*BatL alternating*/0x0D, 0x10, 0x04, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
RAM uint8_t advertising_data[] = {
|
||||
/*Description*/16, 0x16, 0x1a, 0x18,
|
||||
/*MAC*/0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
@@ -130,13 +118,6 @@ void init_ble(){
|
||||
advertising_data[8] = mac_public[1];
|
||||
advertising_data[9] = mac_public[0];
|
||||
|
||||
advertising_data_Mi[9] = mac_public[0];
|
||||
advertising_data_Mi[10] = mac_public[1];
|
||||
advertising_data_Mi[11] = mac_public[2];
|
||||
advertising_data_Mi[12] = mac_public[3];
|
||||
advertising_data_Mi[13] = mac_public[4];
|
||||
advertising_data_Mi[14] = mac_public[5];
|
||||
|
||||
////// Controller Initialization //////////
|
||||
blc_ll_initBasicMCU(); //must
|
||||
blc_ll_initStandby_module(mac_public); //must
|
||||
@@ -175,34 +156,7 @@ bool ble_get_connected(){
|
||||
return ble_connected;
|
||||
}
|
||||
|
||||
extern settings_struct settings;//Custom or Mi Advertising
|
||||
void set_adv_data(int16_t temp, uint16_t humi, uint8_t battery_level, uint16_t battery_mv){
|
||||
if(settings.advertising_type){//Mi Like Advertising
|
||||
humi = humi * 10;
|
||||
|
||||
advertising_data_Mi[8]++;
|
||||
|
||||
if(show_temp_humi_Mi){//Alternate between Sensor and Battery level
|
||||
advertising_data_Mi[15] = 0x0d;
|
||||
advertising_data_Mi[17] = 0x04;
|
||||
|
||||
advertising_data_Mi[18] = temp&0xff;
|
||||
advertising_data_Mi[19] = temp>>8;
|
||||
advertising_data_Mi[20] = humi&0xff;
|
||||
advertising_data_Mi[21] = humi>>8;
|
||||
}else{
|
||||
advertising_data_Mi[15] = 0x0a;
|
||||
advertising_data_Mi[17] = 0x01;
|
||||
|
||||
advertising_data_Mi[18] = battery_level;
|
||||
advertising_data_Mi[19] = 0x00;
|
||||
advertising_data_Mi[20] = 0x00;
|
||||
advertising_data_Mi[21] = 0x00;
|
||||
}
|
||||
show_temp_humi_Mi = !show_temp_humi_Mi;
|
||||
|
||||
bls_ll_setAdvData( (uint8_t *)advertising_data_Mi, sizeof(advertising_data_Mi));
|
||||
}else{//Custom advertising type
|
||||
advertising_data[10] = temp>>8;
|
||||
advertising_data[11] = temp&0xff;
|
||||
|
||||
@@ -216,7 +170,6 @@ void set_adv_data(int16_t temp, uint16_t humi, uint8_t battery_level, uint16_t b
|
||||
advertising_data[16]++;
|
||||
|
||||
bls_ll_setAdvData( (uint8_t *)advertising_data, sizeof(advertising_data));
|
||||
}
|
||||
}
|
||||
|
||||
void ble_send_temp(uint16_t temp){
|
||||
@@ -225,13 +178,6 @@ void ble_send_temp(uint16_t temp){
|
||||
bls_att_pushNotifyData(TEMP_LEVEL_INPUT_DP_H, my_tempVal, 2);
|
||||
}
|
||||
|
||||
void ble_send_humi(uint16_t humi){
|
||||
humi*=100;
|
||||
my_humiVal[0] = humi & 0xFF;
|
||||
my_humiVal[1] = humi >> 8;
|
||||
bls_att_pushNotifyData(HUMI_LEVEL_INPUT_DP_H, (uint8_t *)my_humiVal, 2);
|
||||
}
|
||||
|
||||
void ble_send_battery(uint8_t value){
|
||||
my_batVal[0] = value;
|
||||
bls_att_pushNotifyData(BATT_LEVEL_INPUT_DP_H, (uint8_t *)my_batVal, 1);
|
||||
|
||||
@@ -7,6 +7,5 @@ void init_ble();
|
||||
void set_adv_data(int16_t temp, uint16_t humi, uint8_t battery_level, uint16_t battery_mv);
|
||||
bool ble_get_connected();
|
||||
void ble_send_temp(uint16_t temp);
|
||||
void ble_send_humi(uint16_t humi);
|
||||
void ble_send_battery(uint8_t value);
|
||||
void blt_pm_proc(void);
|
||||
|
||||
@@ -45,25 +45,13 @@ void cmd_parser(void * p){
|
||||
settings.comfort_smiley = true; // Comfort Indicator
|
||||
}else if(inData == 0xAB){
|
||||
settings.blinking_smiley = true;//Smiley blinking
|
||||
}else if(inData == 0xAE){
|
||||
settings.advertising_type = false;//Advertising type Custom
|
||||
}else if(inData == 0xAF){
|
||||
settings.advertising_type = true;//Advertising type Mi Like
|
||||
}else if(inData == 0xFE){
|
||||
settings.advertising_interval = req->dat[1];//Set advertising interval with second byte, value*10second / 0=main_delay
|
||||
}else if(inData == 0xFA){
|
||||
settings.temp_offset = req->dat[1];//Set temp offset, -12,5 - +12,5 °C
|
||||
}else if(inData == 0xFB){
|
||||
settings.humi_offset = req->dat[1];//Set humi offset, -50 - +50 %
|
||||
if(settings.humi_offset<-50)settings.humi_offset=-50;
|
||||
if(settings.humi_offset>50)settings.humi_offset=50;
|
||||
}else if(inData == 0xFC){
|
||||
settings.temp_alarm_point = req->dat[1];//Set temp alarm point value divided by 10 for temp in °C
|
||||
if(settings.temp_alarm_point==0)settings.temp_alarm_point = 1;
|
||||
}else if(inData == 0xFD){
|
||||
settings.humi_alarm_point = req->dat[1];//Set humi alarm point
|
||||
if(settings.humi_alarm_point==0)settings.humi_alarm_point = 1;
|
||||
if(settings.humi_alarm_point>50)settings.humi_alarm_point = 50;
|
||||
}else if(inData == 0xDD){// Set display segments directly
|
||||
|
||||
}else if(inData == 0xDE){// Save settings in flash to default
|
||||
|
||||
@@ -33,13 +33,10 @@ void reset_settings_to_default()
|
||||
settings.blinking_smiley = false;
|
||||
settings.comfort_smiley = true;
|
||||
settings.show_batt_enabled = true;
|
||||
settings.advertising_type = false;
|
||||
settings.advertising_interval = 6;
|
||||
settings.measure_interval = 10;
|
||||
settings.temp_offset = 0;
|
||||
settings.humi_offset = 0;
|
||||
settings.temp_alarm_point = 5;
|
||||
settings.humi_alarm_point = 5;
|
||||
}
|
||||
|
||||
void save_settings_to_flash()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
struct Settings_struct
|
||||
typedef struct Settings_struct
|
||||
{
|
||||
uint32_t magic;
|
||||
uint32_t len;
|
||||
@@ -9,17 +9,13 @@ struct Settings_struct
|
||||
uint8_t blinking_smiley;
|
||||
uint8_t comfort_smiley;
|
||||
uint8_t show_batt_enabled;
|
||||
uint8_t advertising_type;//Custom or Mi Advertising (true)
|
||||
uint8_t advertising_interval;//advise new values - multiply by 10 for value
|
||||
uint8_t measure_interval;//time = loop interval * factor (def: about 7 * X)
|
||||
int8_t temp_offset;
|
||||
int8_t humi_offset;
|
||||
uint8_t temp_alarm_point;//divide by ten for value
|
||||
uint8_t humi_alarm_point;
|
||||
uint8_t crc;// Needs to be at the last position otherwise the settings can not be validated on next boot!!!!
|
||||
};
|
||||
} settings_struct;
|
||||
|
||||
typedef struct Settings_struct settings_struct;
|
||||
|
||||
void init_flash();
|
||||
void reset_settings_to_default();
|
||||
|
||||
@@ -837,7 +837,6 @@ int iPitch = pOBD->width;
|
||||
//
|
||||
void obdWriteDataBlock(OBDISP *pOBD, unsigned char *ucBuf, int iLen, int bRender)
|
||||
{
|
||||
unsigned char ucTemp[196];
|
||||
int iPitch, iBufferSize;
|
||||
|
||||
iPitch = pOBD->width;
|
||||
@@ -1210,7 +1209,7 @@ int obdLoadBMP(OBDISP *pOBD, uint8_t *pBMP, int dx, int dy, int bInvert)
|
||||
int16_t i16, cx, cy;
|
||||
int iOffBits; // offset to bitmap data
|
||||
int iPitch, iDestPitch;
|
||||
uint8_t x, y, b, *s, *d;
|
||||
uint8_t x, y, b = 0, *s, *d;
|
||||
uint8_t dst_mask, src_mask;
|
||||
uint8_t bFlipped = false;
|
||||
|
||||
|
||||
@@ -8,31 +8,31 @@
|
||||
|
||||
void init_uart()
|
||||
{
|
||||
gpio_set_func(TXD, AS_GPIO);
|
||||
gpio_set_output_en(TXD, 1);
|
||||
gpio_write(TXD, 0);
|
||||
gpio_set_func(RXD, AS_GPIO);
|
||||
gpio_set_input_en(RXD, 1);
|
||||
gpio_set_output_en(RXD, 0);
|
||||
|
||||
gpio_set_func(TXD, AS_GPIO);
|
||||
gpio_set_output_en(TXD, 1);
|
||||
gpio_write(TXD, 0);
|
||||
gpio_set_func(RXD, AS_GPIO);
|
||||
gpio_set_input_en(RXD, 1);
|
||||
gpio_set_output_en(RXD, 0);
|
||||
|
||||
uart_gpio_set(UART_TX_PB1, UART_RX_PA0);
|
||||
uart_reset();
|
||||
uart_init(12,15,PARITY_NONE, STOP_BIT_ONE); //baud rate: 115200
|
||||
uart_init(12, 15, PARITY_NONE, STOP_BIT_ONE); // baud rate: 115200
|
||||
uart_dma_enable(0, 0);
|
||||
dma_chn_irq_enable(0, 0);
|
||||
uart_irq_enable(0,0);
|
||||
uart_ndma_irq_triglevel(0,0);
|
||||
uart_irq_enable(0, 0);
|
||||
uart_ndma_irq_triglevel(0, 0);
|
||||
}
|
||||
|
||||
_attribute_ram_code_ void puts(char* s){
|
||||
|
||||
while(*s!='\0')
|
||||
{
|
||||
uart_ndma_send_byte(*s);
|
||||
while(uart_tx_is_busy())
|
||||
_attribute_ram_code_ void puts(const char* str)
|
||||
{
|
||||
while (*str != '\0')
|
||||
{
|
||||
uart_ndma_send_byte(*str);
|
||||
while (uart_tx_is_busy())
|
||||
{
|
||||
sleep_us(10);
|
||||
};
|
||||
s++;
|
||||
}
|
||||
str++;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user