component/bt : cleanup the liscence header

This commit is contained in:
Tian Hao
2016-11-05 02:48:16 +08:00
parent acda125e8b
commit aa6fe04148
37 changed files with 3200 additions and 3088 deletions

View File

@@ -1,17 +1,18 @@
/**
****************************************************************************************
*
* @file bt_prf_sys_main.c
*
* @brief Application entry point
*
* Copyright (C) Espressif 2016
* Created by Yulong at 2016/10/13
*
*
****************************************************************************************
*/
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "thread.h" #include "thread.h"
#include "bt_prf_sys.h" #include "bt_prf_sys.h"
#include "fixed_queue.h" #include "fixed_queue.h"

View File

@@ -1,16 +1,16 @@
/** // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
**************************************************************************************** //
* // Licensed under the Apache License, Version 2.0 (the "License");
* @file bt_prf_task.c // you may not use this file except in compliance with the License.
* // You may obtain a copy of the License at
* @brief Application entry point
* // http://www.apache.org/licenses/LICENSE-2.0
* Copyright (C) Espressif 2016 //
* Created by Yulong at 2016/10/11 // Unless required by applicable law or agreed to in writing, software
* // distributed under the License is distributed on an "AS IS" BASIS,
* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
**************************************************************************************** // See the License for the specific language governing permissions and
*/ // limitations under the License.
#include "bt_prf_task.h" #include "bt_prf_task.h"
#include "bt_prf_sys.h" #include "bt_prf_sys.h"

View File

@@ -1,16 +1,16 @@
/** // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
**************************************************************************************** //
* // Licensed under the Apache License, Version 2.0 (the "License");
* @file bt_profile_act.c // you may not use this file except in compliance with the License.
* // You may obtain a copy of the License at
* @brief Application entry point
* // http://www.apache.org/licenses/LICENSE-2.0
* Copyright (C) Espressif 2016 //
* Created by Yulong at 2016/10/13 // Unless required by applicable law or agreed to in writing, software
* // distributed under the License is distributed on an "AS IS" BASIS,
* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
**************************************************************************************** // See the License for the specific language governing permissions and
*/ // limitations under the License.

View File

@@ -1,16 +1,16 @@
/** // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
**************************************************************************************** //
* // Licensed under the Apache License, Version 2.0 (the "License");
* @file bt_prf_task.h // you may not use this file except in compliance with the License.
* // You may obtain a copy of the License at
* @brief Application entry point
* // http://www.apache.org/licenses/LICENSE-2.0
* Copyright (C) Espressif 2016 //
* Created by Yulong at 2016/10/12 // Unless required by applicable law or agreed to in writing, software
* // distributed under the License is distributed on an "AS IS" BASIS,
* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
**************************************************************************************** // See the License for the specific language governing permissions and
*/ // limitations under the License.
#include <string.h> #include <string.h>

View File

@@ -1,16 +1,16 @@
/** // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
**************************************************************************************** //
* // Licensed under the Apache License, Version 2.0 (the "License");
* @file bt_prf_sys.h // you may not use this file except in compliance with the License.
* // You may obtain a copy of the License at
* @brief Application entry point
* // http://www.apache.org/licenses/LICENSE-2.0
* Copyright (C) Espressif 2016 //
* Created by Yulong at 2016/10/12 // Unless required by applicable law or agreed to in writing, software
* // distributed under the License is distributed on an "AS IS" BASIS,
* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
**************************************************************************************** // See the License for the specific language governing permissions and
*/ // limitations under the License.
#ifndef _PROFILE_SYS_H__ #ifndef _PROFILE_SYS_H__
#define _PROFILE_SYS_H__ #define _PROFILE_SYS_H__

View File

@@ -1,24 +1,24 @@
/** // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
**************************************************************************************** //
* // Licensed under the Apache License, Version 2.0 (the "License");
* @file bt_prf_task.h // you may not use this file except in compliance with the License.
* // You may obtain a copy of the License at
* @brief Application entry point
* // http://www.apache.org/licenses/LICENSE-2.0
* Copyright (C) Espressif 2016 //
* Created by Yulong at 2016/10/11 // Unless required by applicable law or agreed to in writing, software
* // distributed under the License is distributed on an "AS IS" BASIS,
* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
**************************************************************************************** // See the License for the specific language governing permissions and
*/ // limitations under the License.
#include <stddef.h> #include <stddef.h>
#include "bt_defs.h" #include "bt_defs.h"
#include "fixed_queue.h" #include "fixed_queue.h"
#ifndef BT_PRF_TASK_H__ #ifndef BT_PRF_TASK_H__
#define BT_PRF_TASK_H__ #define BT_PRF_TASK_H__
/* Functions provided by bt_prf_task.c /* Functions provided by bt_prf_task.c
************************************ ************************************
*/ */

View File

@@ -1,16 +1,16 @@
/** // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
**************************************************************************************** //
* // Licensed under the Apache License, Version 2.0 (the "License");
* @file button_pro.c // you may not use this file except in compliance with the License.
* // You may obtain a copy of the License at
* @brief Application entry point
* // http://www.apache.org/licenses/LICENSE-2.0
* Copyright (C) Espressif 2016 //
* Created by Yulong at 2016/8/18 // Unless required by applicable law or agreed to in writing, software
* // distributed under the License is distributed on an "AS IS" BASIS,
* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
**************************************************************************************** // See the License for the specific language governing permissions and
*/ // limitations under the License.
#include <stdint.h> #include <stdint.h>

View File

@@ -1,17 +1,18 @@
/**
****************************************************************************************
*
* @file button_pro.h
*
* @brief Application entry point
*
* Copyright (C) Espressif 2016
* Created by Yulong at 2016/8/18
*
*
****************************************************************************************
*/
#include "prf_defs.h" #include "prf_defs.h"
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#if (BUT_PROFILE_CFG) #if (BUT_PROFILE_CFG)
#include "bt_target.h" #include "bt_target.h"

View File

@@ -1,16 +1,16 @@
/** // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
**************************************************************************************** //
* // Licensed under the Apache License, Version 2.0 (the "License");
* @file wx_airsync_prf.h // you may not use this file except in compliance with the License.
* // You may obtain a copy of the License at
* @brief Application entry point
* // http://www.apache.org/licenses/LICENSE-2.0
* Copyright (C) Espressif 2016 //
* Created by Yulong at 2016/9/29 // Unless required by applicable law or agreed to in writing, software
* // distributed under the License is distributed on an "AS IS" BASIS,
* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
**************************************************************************************** // See the License for the specific language governing permissions and
*/ // limitations under the License.
#include "prf_defs.h" #include "prf_defs.h"

View File

@@ -1,17 +1,18 @@
/**
****************************************************************************************
*
* @file wx_airsync_prf.c
*
* @brief Application entry point
*
* Copyright (C) Espressif 2016
* Created by Yulong at 2016/9/29
*
*
****************************************************************************************
*/
#include "wx_airsync_prf.h" #include "wx_airsync_prf.h"
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#if (WX_AIRSYNC_CFG) #if (WX_AIRSYNC_CFG)

View File

@@ -1,9 +1,18 @@
/***************************************************************
* *
* * This file is for battery service based on bta layer
* *
***************************************************************/
#include <stdint.h> #include <stdint.h>
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <string.h> #include <string.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdio.h> #include <stdio.h>

View File

@@ -1,17 +1,18 @@
/**
****************************************************************************************
*
* @file hid_le_prf.c
*
* @brief Application entry point
*
* Copyright (C) Espressif 2016
* Created by Yulong at 2016/9/7
*
*
****************************************************************************************
*/
#include <string.h> #include <string.h>
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "hid_le_prf.h" #include "hid_le_prf.h"
#include "prf_defs.h" #include "prf_defs.h"

View File

@@ -1,16 +1,16 @@
/** // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
**************************************************************************************** //
* // Licensed under the Apache License, Version 2.0 (the "License");
* @file button_pro.c // you may not use this file except in compliance with the License.
* // You may obtain a copy of the License at
* @brief Application entry point
* // http://www.apache.org/licenses/LICENSE-2.0
* Copyright (C) Espressif 2016 //
* Created by Yulong at 2016/9/7 // Unless required by applicable law or agreed to in writing, software
* // distributed under the License is distributed on an "AS IS" BASIS,
* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
**************************************************************************************** // See the License for the specific language governing permissions and
*/ // limitations under the License.
#include "prf_defs.h" #include "prf_defs.h"

View File

@@ -1,17 +1,18 @@
/**
****************************************************************************************
*
* @file prf_defs.h
*
* @brief Application entry point
*
* Copyright (C) Espressif 2016
* Created by Yulong at 2016/9/8
*
*
****************************************************************************************
*/
#ifndef PRF_DEFS_H_ #ifndef PRF_DEFS_H_
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#define PRF_DEFS_H_ #define PRF_DEFS_H_
#include "bta_api.h" #include "bta_api.h"

File diff suppressed because it is too large Load Diff

View File

@@ -1,108 +1,108 @@
/** // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
**************************************************************************************** //
* // Licensed under the Apache License, Version 2.0 (the "License");
* @file bt_app_sec.c // you may not use this file except in compliance with the License.
* // You may obtain a copy of the License at
* @brief Application entry point
* // http://www.apache.org/licenses/LICENSE-2.0
* Copyright (C) Espressif 2016 //
* Created by Yulong at 2016/10/13 // Unless required by applicable law or agreed to in writing, software
* // distributed under the License is distributed on an "AS IS" BASIS,
* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
**************************************************************************************** // See the License for the specific language governing permissions and
*/ // limitations under the License.
#include "bt_app_sec.h" #include "bt_app_sec.h"
#include <stdlib.h> // standard library #include <stdlib.h> // standard library
#include <string.h> #include <string.h>
extern void srand (unsigned int seed); extern void srand (unsigned int seed);
extern int random (void); extern int random (void);
/// Application Security Environment Structure /// Application Security Environment Structure
tAPP_SEC_ENV app_sec_env; tAPP_SEC_ENV app_sec_env;
/******************************************************************************* /*******************************************************************************
** **
** Function app_ble_sec_gen_tk ** Function app_ble_sec_gen_tk
** **
** Description This function is called to generate the ble tk ** Description This function is called to generate the ble tk
** **
** Returns the generate tk value ** Returns the generate tk value
** **
*******************************************************************************/ *******************************************************************************/
UINT32 app_ble_sec_gen_tk(void) UINT32 app_ble_sec_gen_tk(void)
{ {
// Generate a PIN Code (Between 100000 and 999999) // Generate a PIN Code (Between 100000 and 999999)
return (100000 + (random()%900000)); return (100000 + (random()%900000));
} }
/******************************************************************************* /*******************************************************************************
** **
** Function app_ble_sec_gen_ltk ** Function app_ble_sec_gen_ltk
** **
** Description This function is called to generate the ble ltk ** Description This function is called to generate the ble ltk
** **
** Returns NULL ** Returns NULL
** **
*******************************************************************************/ *******************************************************************************/
void app_ble_sec_gen_ltk(UINT8 key_size) void app_ble_sec_gen_ltk(UINT8 key_size)
{ {
// Counter // Counter
UINT8 i; UINT8 i;
app_sec_env.key_size = key_size; app_sec_env.key_size = key_size;
// Randomly generate the LTK and the Random Number // Randomly generate the LTK and the Random Number
for (i = 0; i < RAND_NB_LEN; i++) for (i = 0; i < RAND_NB_LEN; i++)
{ {
app_sec_env.rand_nb.nb[i] = random()%256; app_sec_env.rand_nb.nb[i] = random()%256;
} }
// Randomly generate the end of the LTK // Randomly generate the end of the LTK
for (i = 0; i < SEC_KEY_LEN; i++) for (i = 0; i < SEC_KEY_LEN; i++)
{ {
app_sec_env.ltk.key[i] = (((key_size) < (16 - i)) ? 0 : random()%256); app_sec_env.ltk.key[i] = (((key_size) < (16 - i)) ? 0 : random()%256);
} }
// Randomly generate the EDIV // Randomly generate the EDIV
app_sec_env.ediv = random()%65536; app_sec_env.ediv = random()%65536;
} }
/******************************************************************************* /*******************************************************************************
** **
** Function app_ble_sec_init ** Function app_ble_sec_init
** **
** Description This function is init the security env and function ** Description This function is init the security env and function
** **
** Returns NULL ** Returns NULL
** **
*******************************************************************************/ *******************************************************************************/
void app_ble_sec_init() void app_ble_sec_init()
{ {
// Reset Security Environment // Reset Security Environment
memset(&app_sec_env, 0, sizeof(app_sec_env)); memset(&app_sec_env, 0, sizeof(app_sec_env));
} }
/******************************************************************************* /*******************************************************************************
** **
** Function app_ble_security_start ** Function app_ble_security_start
** **
** Description This function is called by the slave when the seurity start ** Description This function is called by the slave when the seurity start
** **
** Returns NULL ** Returns NULL
** **
*******************************************************************************/ *******************************************************************************/
void app_ble_security_start(void) void app_ble_security_start(void)
{ {
} }

View File

@@ -1,3 +1,17 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "bt_gap_api.h" #include "bt_gap_api.h"
#include "bta_api.h" #include "bta_api.h"
#include "bt_trace.h" #include "bt_trace.h"

View File

@@ -1,3 +1,17 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "bt_sdp_api.h" #include "bt_sdp_api.h"

File diff suppressed because it is too large Load Diff

View File

@@ -1,78 +1,78 @@
/** // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
**************************************************************************************** //
* // Licensed under the Apache License, Version 2.0 (the "License");
* @file bt_app_sec.h // you may not use this file except in compliance with the License.
* // You may obtain a copy of the License at
* @brief Application entry point
* // http://www.apache.org/licenses/LICENSE-2.0
* Copyright (C) Espressif 2016 //
* Created by Yulong at 2016/10/13 // Unless required by applicable law or agreed to in writing, software
* // distributed under the License is distributed on an "AS IS" BASIS,
* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
**************************************************************************************** // See the License for the specific language governing permissions and
*/ // limitations under the License.
#include "bt_types.h" #include "bt_types.h"
#define APP_SEC_IRK_FLAG (0) #define APP_SEC_IRK_FLAG (0)
#define RAND_NB_LEN 0x08 #define RAND_NB_LEN 0x08
#define SEC_KEY_LEN 0x10 #define SEC_KEY_LEN 0x10
/* /*
* STRUCTURES DEFINITIONS * STRUCTURES DEFINITIONS
**************************************************************************************** ****************************************************************************************
*/ */
/// Generic Security key structure /// Generic Security key structure
typedef struct typedef struct
{ {
/// Key value MSB -> LSB /// Key value MSB -> LSB
UINT8 key[SEC_KEY_LEN]; UINT8 key[SEC_KEY_LEN];
}smp_sec_key; }smp_sec_key;
///Random number structure ///Random number structure
typedef struct typedef struct
{ {
///8-byte array for random number ///8-byte array for random number
UINT8 nb[RAND_NB_LEN]; UINT8 nb[RAND_NB_LEN];
}rand_nb; }rand_nb;
typedef struct typedef struct
{ {
// LTK // LTK
smp_sec_key ltk; smp_sec_key ltk;
// Random Number // Random Number
rand_nb rand_nb; rand_nb rand_nb;
// EDIV // EDIV
UINT16 ediv; UINT16 ediv;
// LTK key size // LTK key size
UINT8 key_size; UINT8 key_size;
// Last paired peer address type // Last paired peer address type
UINT8 peer_addr_type; UINT8 peer_addr_type;
// Last paired peer address // Last paired peer address
BD_ADDR peer_addr; BD_ADDR peer_addr;
// authentication level // authentication level
UINT8 auth; UINT8 auth;
}tAPP_SEC_ENV; }tAPP_SEC_ENV;
extern tAPP_SEC_ENV app_sec_env; extern tAPP_SEC_ENV app_sec_env;
/* /*
* GLOBAL FUNCTIONS DECLARATIONS * GLOBAL FUNCTIONS DECLARATIONS
**************************************************************************************** ****************************************************************************************
*/ */
void app_ble_sec_init(void); void app_ble_sec_init(void);
void app_ble_sec_pairing_cmp_evt_send(UINT8); void app_ble_sec_pairing_cmp_evt_send(UINT8);
UINT32 app_ble_sec_gen_tk(void); UINT32 app_ble_sec_gen_tk(void);
void app_ble_sec_gen_ltk(UINT8 key_size); void app_ble_sec_gen_ltk(UINT8 key_size);
void app_ble_security_start(void); void app_ble_security_start(void);

View File

@@ -1,3 +1,17 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <stdio.h> #include <stdio.h>
#include "freertos/FreeRTOS.h" #include "freertos/FreeRTOS.h"
#include "freertos/task.h" #include "freertos/task.h"

View File

@@ -1,3 +1,17 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*************************************************************** /***************************************************************
* * * *
* * This file is for client to execute battery-related operation * * This file is for client to execute battery-related operation

View File

@@ -1,16 +1,16 @@
/** // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
**************************************************************************************** //
* // Licensed under the Apache License, Version 2.0 (the "License");
* @file bt_app.c // you may not use this file except in compliance with the License.
* // You may obtain a copy of the License at
* @brief Application entry point
* // http://www.apache.org/licenses/LICENSE-2.0
* Copyright (C) Espressif 2016 //
* Created by Yulong at 2016/9/9 // Unless required by applicable law or agreed to in writing, software
* // distributed under the License is distributed on an "AS IS" BASIS,
* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
**************************************************************************************** // See the License for the specific language governing permissions and
*/ // limitations under the License.
#include "bt_app_defs.h" #include "bt_app_defs.h"

View File

@@ -1,3 +1,17 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
#include <stdbool.h> #include <stdbool.h>

View File

@@ -1,130 +1,131 @@
/** // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
**************************************************************************************** //
* // Licensed under the Apache License, Version 2.0 (the "License");
* @file app_airsync_md5.h // you may not use this file except in compliance with the License.
* // You may obtain a copy of the License at
* @brief Application airsync md5 generation Entry Point
* // http://www.apache.org/licenses/LICENSE-2.0
* Copyright (C) ESPRESSIF 2016 //
* Created by Yulong at 2016/10/9 // Unless required by applicable law or agreed to in writing, software
* // distributed under the License is distributed on an "AS IS" BASIS,
**************************************************************************************** // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/ // See the License for the specific language governing permissions and
// limitations under the License.
#include "prf_defs.h"
#if (WX_AIRSYNC_CFG) #include "prf_defs.h"
#if (WX_AIRSYNC_CFG)
#include <stdlib.h>
#include <stdio.h> #include <stdlib.h>
#include <math.h> #include <stdio.h>
#include "gki.h" #include <math.h>
#include "app_airsync_md5.h" #include "gki.h"
#include "app_airsync_md5.h"
const uint32_t X[4][2] = {{0, 1}, {1, 5}, {5, 3}, {0, 7}};
const uint32_t S[4][4] = {{ 7, 12, 17, 22 },{ 5, 9 , 14, 20 },{ 4, 11, 16, 23 },{ 6, 10, 15, 21 }}; const uint32_t X[4][2] = {{0, 1}, {1, 5}, {5, 3}, {0, 7}};
uint32_t F( uint32_t X, uint32_t Y, uint32_t Z ) const uint32_t S[4][4] = {{ 7, 12, 17, 22 },{ 5, 9 , 14, 20 },{ 4, 11, 16, 23 },{ 6, 10, 15, 21 }};
{ uint32_t F( uint32_t X, uint32_t Y, uint32_t Z )
return ( X & Y ) | ( ~X & Z ); {
} return ( X & Y ) | ( ~X & Z );
uint32_t G( uint32_t X, uint32_t Y, uint32_t Z ) }
{ uint32_t G( uint32_t X, uint32_t Y, uint32_t Z )
return ( X & Z ) | ( Y & ~Z ); {
} return ( X & Z ) | ( Y & ~Z );
uint32_t H( uint32_t X, uint32_t Y, uint32_t Z ) }
{ uint32_t H( uint32_t X, uint32_t Y, uint32_t Z )
return X ^ Y ^ Z; {
} return X ^ Y ^ Z;
uint32_t I( uint32_t X, uint32_t Y, uint32_t Z ) }
{ uint32_t I( uint32_t X, uint32_t Y, uint32_t Z )
return Y ^ ( X | ~Z ); {
} return Y ^ ( X | ~Z );
// rotates x left s bits. }
uint32_t rotate_left( uint32_t x, uint32_t s ) // rotates x left s bits.
{ uint32_t rotate_left( uint32_t x, uint32_t s )
return ( x << s ) | ( x >> ( 32 - s ) ); {
} return ( x << s ) | ( x >> ( 32 - s ) );
}
// Pre-processin
uint32_t count_padding_bits ( uint32_t length ) // Pre-processin
{ uint32_t count_padding_bits ( uint32_t length )
// uint32_t div = length * BITS / BLOCK_SIZE; {
uint32_t mod = length * BITS % BLOCK_SIZE; // uint32_t div = length * BITS / BLOCK_SIZE;
uint32_t c_bits; uint32_t mod = length * BITS % BLOCK_SIZE;
if ( mod == 0 ) uint32_t c_bits;
{ if ( mod == 0 )
c_bits = MOD_SIZE; {
} c_bits = MOD_SIZE;
else }
{ else
c_bits = ( MOD_SIZE + BLOCK_SIZE - mod ) % BLOCK_SIZE; {
} c_bits = ( MOD_SIZE + BLOCK_SIZE - mod ) % BLOCK_SIZE;
return c_bits / BITS; }
} return c_bits / BITS;
}
MD5String append_padding_bits ( char * argv )
{ MD5String append_padding_bits ( char * argv )
uint32_t msg_length = strlen ( argv ); {
uint32_t bit_length = count_padding_bits ( msg_length ); uint32_t msg_length = strlen ( argv );
uint64_t app_length = msg_length * BITS; uint32_t bit_length = count_padding_bits ( msg_length );
MD5String string; uint64_t app_length = msg_length * BITS;
string.str = (char *)GKI_getbuf(msg_length + bit_length + APP_SIZE / BITS); MD5String string;
strncpy ( string.str, argv, msg_length ); string.str = (char *)GKI_getbuf(msg_length + bit_length + APP_SIZE / BITS);
memset ( string.str + msg_length, 0, bit_length ); strncpy ( string.str, argv, msg_length );
string.str [ msg_length ] = SINGLE_ONE_BIT; memset ( string.str + msg_length, 0, bit_length );
memmove ( string.str + msg_length + bit_length, (char *)&app_length, sizeof( uint64_t ) ); string.str [ msg_length ] = SINGLE_ONE_BIT;
string.len = msg_length + bit_length + sizeof( uint64_t ); memmove ( string.str + msg_length + bit_length, (char *)&app_length, sizeof( uint64_t ) );
return string; string.len = msg_length + bit_length + sizeof( uint64_t );
} return string;
}
int32_t wechat_md5 (char *argv, uint8_t *md5_32)
{ int32_t wechat_md5 (char *argv, uint8_t *md5_32)
MD5String string; {
uint32_t w[16]; MD5String string;
uint32_t chain[4]; uint32_t w[16];
uint32_t state[4]; uint32_t chain[4];
uint32_t state[4];
uint32_t ( *auxi[ 4 ])( uint32_t, uint32_t, uint32_t ) = { F, G, H, I };
int sIdx; uint32_t ( *auxi[ 4 ])( uint32_t, uint32_t, uint32_t ) = { F, G, H, I };
int wIdx; int sIdx;
string = append_padding_bits ( argv ); int wIdx;
chain[0] = A; string = append_padding_bits ( argv );
chain[1] = B; chain[0] = A;
chain[2] = C; chain[1] = B;
chain[3] = D; chain[2] = C;
for (uint32_t j = 0; j < string.len; j += BLOCK_SIZE / BITS) chain[3] = D;
{ for (uint32_t j = 0; j < string.len; j += BLOCK_SIZE / BITS)
memmove ( (char *)w, string.str + j, BLOCK_SIZE / BITS ); {
memmove ( state, chain, sizeof(chain) ); memmove ( (char *)w, string.str + j, BLOCK_SIZE / BITS );
for ( uint8_t roundIdx = 0; roundIdx < 4; roundIdx++ ) memmove ( state, chain, sizeof(chain) );
{ for ( uint8_t roundIdx = 0; roundIdx < 4; roundIdx++ )
wIdx = X[ roundIdx ][ 0 ]; {
sIdx = 0; wIdx = X[ roundIdx ][ 0 ];
for (uint8_t i = 0; i < 16; i++ ) sIdx = 0;
{ for (uint8_t i = 0; i < 16; i++ )
state[sIdx] = state [(sIdx + 1)%4] + rotate_left( state[sIdx] +(*auxi[ roundIdx])( state[(sIdx+1) % 4], {
state[(sIdx+2) % 4], state[sIdx] = state [(sIdx + 1)%4] + rotate_left( state[sIdx] +(*auxi[ roundIdx])( state[(sIdx+1) % 4],
state[(sIdx+3) % 4]) + w[ wIdx ] + (uint32_t)floor((1ULL << 32) * fabs(sin( roundIdx * 16 + i + 1 )) ), state[(sIdx+2) % 4],
S[ roundIdx ][ i % 4 ]); state[(sIdx+3) % 4]) + w[ wIdx ] + (uint32_t)floor((1ULL << 32) * fabs(sin( roundIdx * 16 + i + 1 )) ),
sIdx = ( sIdx + 3 ) % 4; S[ roundIdx ][ i % 4 ]);
wIdx = ( wIdx + X[ roundIdx ][ 1 ] ) & 0xF; sIdx = ( sIdx + 3 ) % 4;
} wIdx = ( wIdx + X[ roundIdx ][ 1 ] ) & 0xF;
} }
chain[ 0 ] += state[ 0 ]; }
chain[ 1 ] += state[ 1 ]; chain[ 0 ] += state[ 0 ];
chain[ 2 ] += state[ 2 ]; chain[ 1 ] += state[ 1 ];
chain[ 3 ] += state[ 3 ]; chain[ 2 ] += state[ 2 ];
} chain[ 3 ] += state[ 3 ];
memmove ( md5_32 + 0, (char *)&chain[0], sizeof(uint32_t) ); }
memmove ( md5_32 + 4, (char *)&chain[1], sizeof(uint32_t) ); memmove ( md5_32 + 0, (char *)&chain[0], sizeof(uint32_t) );
memmove ( md5_32 + 8, (char *)&chain[2], sizeof(uint32_t) ); memmove ( md5_32 + 4, (char *)&chain[1], sizeof(uint32_t) );
memmove ( md5_32 + 12, (char *)&chain[3], sizeof(uint32_t) ); memmove ( md5_32 + 8, (char *)&chain[2], sizeof(uint32_t) );
free(string.str); memmove ( md5_32 + 12, (char *)&chain[3], sizeof(uint32_t) );
string.str = NULL; free(string.str);
return EXIT_SUCCESS; string.str = NULL;
return EXIT_SUCCESS;
}
}
#endif ///WX_AIRSYNC_CFG
#endif ///WX_AIRSYNC_CFG

View File

@@ -1,160 +1,161 @@
/** // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
**************************************************************************************** //
* // Licensed under the Apache License, Version 2.0 (the "License");
* @file app_airsync_prf.c // you may not use this file except in compliance with the License.
* // You may obtain a copy of the License at
* @brief Application Security Entry Point
* // http://www.apache.org/licenses/LICENSE-2.0
* Copyright (C) ESPRESSIF 2016 //
* Created by Yulong at 2016/9/30 // Unless required by applicable law or agreed to in writing, software
* // distributed under the License is distributed on an "AS IS" BASIS,
**************************************************************************************** // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/ // See the License for the specific language governing permissions and
// limitations under the License.
#include "prf_defs.h"
#if (WX_AIRSYNC_CFG) #include "prf_defs.h"
#if (WX_AIRSYNC_CFG)
#include "app_airsync_prf.h"
#include "wx_airsync_prf.h" #include "app_airsync_prf.h"
#include "app_wechat_util.h" #include "wx_airsync_prf.h"
#include "gki.h" #include "app_wechat_util.h"
#include "mpbledemo2.h" #include "gki.h"
#include "mpbledemo2.h"
/*****************************************************************************
* data handle /*****************************************************************************
*****************************************************************************/ * data handle
data_info g_send_data; *****************************************************************************/
data_info g_send_data;
static data_info g_rcv_data;
data_handler *pDataHandler; static data_info g_rcv_data;
data_handler *pDataHandler;
static void airsync_process_msgreceive_cb(UINT8 app_id,
UINT8 conn_id,uint8_t *pData, uint16_t length); static void airsync_process_msgreceive_cb(UINT8 app_id,
UINT8 conn_id,uint8_t *pData, uint16_t length);
///function for register all products
static void register_all_products(void) ///function for register all products
{ static void register_all_products(void)
REGISTER(mpbledemo2); {
// could register more products if defined REGISTER(mpbledemo2);
} // could register more products if defined
}
void app_wechat_init(void)
{ void app_wechat_init(void)
register_all_products(); {
register_all_products();
data_handler_init(&m_mpbledemo2_handler,PRODUCT_TYPE_MPBLEDEMO2);
m_mpbledemo2_handler->m_data_init_func(); data_handler_init(&m_mpbledemo2_handler,PRODUCT_TYPE_MPBLEDEMO2);
m_mpbledemo2_handler->m_data_init_peripheral_func(); m_mpbledemo2_handler->m_data_init_func();
m_mpbledemo2_handler->m_data_init_peripheral_func();
app_wechat_SetDatahandler(m_mpbledemo2_handler);
} app_wechat_SetDatahandler(m_mpbledemo2_handler);
}
int ble_wechat_indicate_data_chunk(void)
{ int ble_wechat_indicate_data_chunk(void)
uint16_t chunk_len = 0; {
chunk_len = g_send_data.len - g_send_data.offset; uint16_t chunk_len = 0;
chunk_len = chunk_len > BLE_WECHAT_MAX_DATA_LEN?BLE_WECHAT_MAX_DATA_LEN:chunk_len; chunk_len = g_send_data.len - g_send_data.offset;
chunk_len = chunk_len > BLE_WECHAT_MAX_DATA_LEN?BLE_WECHAT_MAX_DATA_LEN:chunk_len;
if(chunk_len == 0)
{ if(chunk_len == 0)
app_wechat_datahandler()->m_data_free_func(g_send_data.data,g_send_data.len); {
g_send_data.data = NULL; app_wechat_datahandler()->m_data_free_func(g_send_data.data,g_send_data.len);
g_send_data.len = 0; g_send_data.data = NULL;
g_send_data.offset = 0; g_send_data.len = 0;
return 0; g_send_data.offset = 0;
} return 0;
}
g_send_data.offset += chunk_len;
return 1; g_send_data.offset += chunk_len;
} return 1;
}
/*******************************************************************************
/*******************************************************************************
** **
** Function airsync_msgreceive_cb ** Function airsync_msgreceive_cb
** **
** Description the callback function after the airsync profile have been ** Description the callback function after the airsync profile have been
** receive the data from the peer device ** receive the data from the peer device
** parms appid:the appid have been register to the gatt database ** parms appid:the appid have been register to the gatt database
** conn_id:the current connection index ** conn_id:the current connection index
** msg_val:the airsync value receive from peer device ** msg_val:the airsync value receive from peer device
** Returns NULL ** Returns NULL
** **
*******************************************************************************/ *******************************************************************************/
static void airsync_process_msgreceive_cb(UINT8 app_id, static void airsync_process_msgreceive_cb(UINT8 app_id,
UINT8 conn_id,uint8_t *pData, uint16_t length) UINT8 conn_id,uint8_t *pData, uint16_t length)
{ {
int error_code; int error_code;
int chunk_size = 0; int chunk_size = 0;
if(length <= BLE_WECHAT_MAX_DATA_LEN) if(length <= BLE_WECHAT_MAX_DATA_LEN)
{ {
if(g_rcv_data.len == 0) if(g_rcv_data.len == 0)
{ {
BpFixHead *fix_head = (BpFixHead *)pData; BpFixHead *fix_head = (BpFixHead *)pData;
g_rcv_data.len = ntohs(fix_head->nLength); g_rcv_data.len = ntohs(fix_head->nLength);
g_rcv_data.offset = 0; g_rcv_data.offset = 0;
g_rcv_data.data = (uint8_t *)GKI_getbuf(g_rcv_data.len); g_rcv_data.data = (uint8_t *)GKI_getbuf(g_rcv_data.len);
} }
chunk_size = g_rcv_data.len - g_rcv_data.offset; chunk_size = g_rcv_data.len - g_rcv_data.offset;
chunk_size = chunk_size < length ? chunk_size : length; chunk_size = chunk_size < length ? chunk_size : length;
memcpy(g_rcv_data.data + g_rcv_data.offset, pData, chunk_size); memcpy(g_rcv_data.data + g_rcv_data.offset, pData, chunk_size);
g_rcv_data.offset += chunk_size; g_rcv_data.offset += chunk_size;
if (g_rcv_data.len <= g_rcv_data.offset) if (g_rcv_data.len <= g_rcv_data.offset)
{ {
error_code = app_wechat_datahandler()->m_data_consume_func(g_rcv_data.data, g_rcv_data.len); error_code = app_wechat_datahandler()->m_data_consume_func(g_rcv_data.data, g_rcv_data.len);
app_wechat_datahandler()->m_data_free_func(g_rcv_data.data,g_rcv_data.len); app_wechat_datahandler()->m_data_free_func(g_rcv_data.data,g_rcv_data.len);
wechat_error_chack(app_wechat_datahandler(), error_code); wechat_error_chack(app_wechat_datahandler(), error_code);
g_rcv_data.len = 0; g_rcv_data.len = 0;
g_rcv_data.offset = 0; g_rcv_data.offset = 0;
app_wechat_datahandler()->m_data_main_process_func(); app_wechat_datahandler()->m_data_main_process_func();
} }
} }
} }
void app_wechat_SetDatahandler(data_handler* pHandler) void app_wechat_SetDatahandler(data_handler* pHandler)
{ {
pDataHandler = pHandler; pDataHandler = pHandler;
} }
bool ble_wechat_is_last_data_sent_out(void) bool ble_wechat_is_last_data_sent_out(void)
{ {
return (g_send_data.len == 0 && g_send_data.offset == 0 ) || \ return (g_send_data.len == 0 && g_send_data.offset == 0 ) || \
(g_send_data.len != 0 && g_send_data.len == g_send_data.offset); (g_send_data.len != 0 && g_send_data.len == g_send_data.offset);
} }
//device sent data on the indicate characteristic //device sent data on the indicate characteristic
int ble_wechat_indicate_data(uint8_t *data, int len) int ble_wechat_indicate_data(uint8_t *data, int len)
{ {
if(data == NULL || len == 0) if(data == NULL || len == 0)
{ {
return 0; return 0;
} }
if(!ble_wechat_is_last_data_sent_out()) if(!ble_wechat_is_last_data_sent_out())
{ {
return 0; return 0;
} }
g_send_data.data = data; g_send_data.data = data;
g_send_data.len = len; g_send_data.len = len;
g_send_data.offset = 0; g_send_data.offset = 0;
return (ble_wechat_indicate_data_chunk()); return (ble_wechat_indicate_data_chunk());
} }
data_handler *app_wechat_datahandler(void) data_handler *app_wechat_datahandler(void)
{ {
return pDataHandler; return pDataHandler;
} }
#endif ///WX_AIRSYNC_CFG #endif ///WX_AIRSYNC_CFG

View File

@@ -1,20 +1,16 @@
/** // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
******************************************************************************* // Licensed under the Apache License, Version 2.0 (the "License");
********* // you may not use this file except in compliance with the License.
* // You may obtain a copy of the License at
* @file app_button.c
* // http://www.apache.org/licenses/LICENSE-2.0
* @brief button Service Application entry point //
* // Unless required by applicable law or agreed to in writing, software
* Copyright (C) ESPRESSSIF 2016 // distributed under the License is distributed on an "AS IS" BASIS,
* Created by Yulong at 2016/08/24 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* // See the License for the specific language governing permissions and
* // limitations under the License.
*******************************************************************************
*********
*/
#include "prf_defs.h" #include "prf_defs.h"

View File

@@ -1,3 +1,17 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**************************************************************************** /****************************************************************************
* *
* This file is for gatt client. It can scan ble device, connect one device, * This file is for gatt client. It can scan ble device, connect one device,

View File

@@ -1,3 +1,17 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*************************************************************** /***************************************************************
* *
* This file is for gatt server device. It instantiates BATTERY * This file is for gatt server device. It instantiates BATTERY

View File

@@ -1,52 +1,39 @@
/** #ifndef __APP_AIRSYNC_MD5__
**************************************************************************************** #define __APP_AIRSYNC_MD5__
*
* @file app_airsync_md5.h #include "prf_defs.h"
* #if (WX_AIRSYNC_CFG)
* @brief Application airsync md5 generation head Entry Point
*
* Copyright (C) ESPRESSIF 2016 #include <stdlib.h>
* Created by Yulong at 2016/10/9 #include <string.h>
* #include <stdio.h>
**************************************************************************************** #include <math.h>
*/
#define SINGLE_ONE_BIT 0x80
#ifndef __APP_AIRSYNC_MD5__ #define BLOCK_SIZE 512
#define __APP_AIRSYNC_MD5__ #define MOD_SIZE 448
#define APP_SIZE 64
#include "prf_defs.h" #define BITS 8
#if (WX_AIRSYNC_CFG)
// MD5 Chaining Variable
#define A 0x67452301UL
#include <stdlib.h> #define B 0xEFCDAB89UL
#include <string.h> #define C 0x98BADCFEUL
#include <stdio.h> #define D 0x10325476UL
#include <math.h>
typedef struct
#define SINGLE_ONE_BIT 0x80 {
#define BLOCK_SIZE 512 char *str;
#define MOD_SIZE 448 uint32_t len;
#define APP_SIZE 64 }MD5String;
#define BITS 8
// MD5 Chaining Variable int32_t wechat_md5 ( char *argv, uint8_t *md5_32);
#define A 0x67452301UL
#define B 0xEFCDAB89UL
#define C 0x98BADCFEUL #endif ///WX_AIRSYNC_CFG
#define D 0x10325476UL
#endif /// __APP_AIRSYNC_MD5__
typedef struct
{
char *str;
uint32_t len;
}MD5String;
int32_t wechat_md5 ( char *argv, uint8_t *md5_32);
#endif ///WX_AIRSYNC_CFG
#endif /// __APP_AIRSYNC_MD5__

View File

@@ -1,47 +1,35 @@
/** #ifndef _APP_AIRSYNC_PRF_H__
**************************************************************************************** #define _APP_AIRSYNC_PRF_H__
*
* @file app_airsync_prf.h #include "prf_defs.h"
* #if (WX_AIRSYNC_CFG)
* @brief Application Security Entry Point
*
* Copyright (C) ESPRESSIF 2016 #include "app_wechat_util.h"
* Created by Yulong at 2016/9/30 #include <stdint.h>
* #include <stdbool.h>
****************************************************************************************
*/ #define MAGIC_NUMBER 0xFE
#ifndef _APP_AIRSYNC_PRF_H__
#define _APP_AIRSYNC_PRF_H__ /**
****************************************************************************************
#include "prf_defs.h" * @brief Create Wechat Database
#if (WX_AIRSYNC_CFG) *
****************************************************************************************
*/
#include "app_wechat_util.h" void app_wechat_create_db(void);
#include <stdint.h>
#include <stdbool.h> void app_wechat_SetDatahandler(data_handler* pHandler);
int ble_wechat_indicate_data(uint8_t *data, int len);
#define MAGIC_NUMBER 0xFE int ble_wechat_indicate_data_chunk(void);
void ble_wechat_process_received_data(uint8_t* pData, uint32_t length);
/** data_handler* app_wechat_datahandler(void);
**************************************************************************************** bool ble_wechat_is_last_data_sent_out(void);
* @brief Create Wechat Database
*
**************************************************************************************** #endif ///WX_AIRSYNC_CFG
*/
void app_wechat_create_db(void); #endif ///_APP_AIRSYNC_PRF_H__
void app_wechat_SetDatahandler(data_handler* pHandler);
int ble_wechat_indicate_data(uint8_t *data, int len);
int ble_wechat_indicate_data_chunk(void);
void ble_wechat_process_received_data(uint8_t* pData, uint32_t length);
data_handler* app_wechat_datahandler(void);
bool ble_wechat_is_last_data_sent_out(void);
#endif ///WX_AIRSYNC_CFG
#endif ///_APP_AIRSYNC_PRF_H__

View File

@@ -1,17 +1,3 @@
/**
****************************************************************************************
*
* @file app_button.h
*
* @brief button Service Application entry point
*
* Copyright (C) ESPRESSIF 2016
* Created by Yulong at 2016/02/24
*
*
****************************************************************************************
*/
/* /*
* DEFINES * DEFINES
**************************************************************************************** ****************************************************************************************

View File

@@ -1,131 +1,116 @@
/** #include "prf_defs.h"
#include "bt_prf_sys.h"
******************************************************************************* #include "bt_types.h"
*********
* #if (BUT_PROFILE_CFG)
* @file app_button_int.h
* /// Messages for Device Information Service Server
* @brief button Service Application entry point enum
* {
* Copyright (C) ESPRESSSIF 2016 ///Add a BUTTON instance into the database
* Created by Yulong at 2016/10/17 BLE_BUT_CREATE_DB_REQ_EVT = BT_PRF_SYS_EVT_START(PRF_ID_BUT_LE),
* ///Send key value confirm to APP so stable values can be erased
******************************************************************************* ///if correctly sent.
**********/ BLE_BUT_VAL_SEND_CFM_EVT,
///Set the value of an attribute
#include "prf_defs.h" BLE_BUT_SET_CHAR_VAL_REQ_EVT,
#include "bt_prf_sys.h"
#include "bt_types.h" ///Start the button notify Service Task - at connection
BLE_BUT_ENABLE_REQ_EVT,
#if (BUT_PROFILE_CFG)
/// Inform the application that the profile service role task has been disabled after a disconnection
/// Messages for Device Information Service Server BLE_BUT_DISABLE_IND_EVT,
enum /// Inform the application that the profile service has been reiceivd the charateristic write commamd from Client
{ BLE_BUT_CHAR_WRITE_IND_EVT,
///Add a BUTTON instance into the database ///Error indication to Host
BLE_BUT_CREATE_DB_REQ_EVT = BT_PRF_SYS_EVT_START(PRF_ID_BUT_LE), BLE_BUT_ERROR_IND_EVT,
///Send key value confirm to APP so stable values can be erased };
///if correctly sent.
BLE_BUT_VAL_SEND_CFM_EVT, /// Parameters of the @ref KEY_CREATE_DB_REQ message
///Set the value of an attribute typedef struct
BLE_BUT_SET_CHAR_VAL_REQ_EVT, {
///Database configuration
///Start the button notify Service Task - at connection uint16_t features;
BLE_BUT_ENABLE_REQ_EVT, }tBUT_CRT_DB_REQ;
/// Inform the application that the profile service role task has been disabled after a disconnection /// Parameters of the @ref KEY_CREATE_DB_CFM message
BLE_BUT_DISABLE_IND_EVT, typedef struct
/// Inform the application that the profile service has been reiceivd the charateristic write commamd from Client {
BLE_BUT_CHAR_WRITE_IND_EVT, ///Status
///Error indication to Host uint8_t status;
BLE_BUT_ERROR_IND_EVT, }tBUT_CRT_DB_CFM;
};
///Parameters of the @ref key_CFG_INDNTF_IND message
/// Parameters of the @ref KEY_CREATE_DB_REQ message typedef struct
typedef struct {
{ ///Connection handle
///Database configuration uint16_t conhdl;
uint16_t features; ///Stop/notify/indicate value to configure into the peer characteristic
}tBUT_CRT_DB_REQ; uint16_t cfg_val;
/// characteristics
/// Parameters of the @ref KEY_CREATE_DB_CFM message uint8_t char_code;
typedef struct }tBUT_CFG_NTF_IND;
{
///Status
uint8_t status; /// Parameters of the @ref KEY_SET_CHAR_VAL_REQ message - shall be dynamically allocated
}tBUT_CRT_DB_CFM; typedef struct
{
///Parameters of the @ref key_CFG_INDNTF_IND message /// Characteristic Code
typedef struct //uint8_t char_code;
{ uint8_t conhdl;
///Connection handle uint8_t key_val_len;
uint16_t conhdl; uint8_t key_val[2];
///Stop/notify/indicate value to configure into the peer characteristic }tBUT_SND_CHAR_VAL_REQ;
uint16_t cfg_val;
/// characteristics /// Parameters of the @ref KEY_ENABLE_REQ message
uint8_t char_code; typedef struct
}tBUT_CFG_NTF_IND; {
///Connection handle
uint16_t conhdl;
/// Parameters of the @ref KEY_SET_CHAR_VAL_REQ message - shall be dynamically allocated /// security level: b0= nothing, b1=unauthenticated, b2=authenticated, b3=authorized; b1 or b2 and b3 can go together
typedef struct uint8_t sec_lvl;
{ ///Type of connection
/// Characteristic Code uint8_t con_type;
//uint8_t char_code; }tBUT_ENABLE_REQ;
uint8_t conhdl;
uint8_t key_val_len; ///Parameters of the @ref KEY_VAL_SEND_CFM message
uint8_t key_val[2]; typedef struct
}tBUT_SND_CHAR_VAL_REQ; {
///Connection handle
/// Parameters of the @ref KEY_ENABLE_REQ message uint16_t conhdl;
typedef struct ///Status
{ uint8_t status;
///Connection handle }tBUT_VAL_SND_CFM;
uint16_t conhdl;
/// security level: b0= nothing, b1=unauthenticated, b2=authenticated, b3=authorized; b1 or b2 and b3 can go together
uint8_t sec_lvl; /// Parameters of the @ref KEY_DISABLE_IND message
///Type of connection typedef struct
uint8_t con_type; {
}tBUT_ENABLE_REQ; ///Connection handle
uint16_t conhdl;
///Parameters of the @ref KEY_VAL_SEND_CFM message }tBUT_DISABLE_IND;
typedef struct
{ typedef union
///Connection handle {
uint16_t conhdl; uint16_t conhdl;
///Status tBUT_CRT_DB_REQ but_crt_db_req;
uint8_t status; tBUT_CRT_DB_CFM but_crt_db_cfm;
}tBUT_VAL_SND_CFM; tBUT_CFG_NTF_IND but_cfg_ntf_ind;
tBUT_SND_CHAR_VAL_REQ but_snd_char_val_req;
tBUT_ENABLE_REQ but_enable_req;
/// Parameters of the @ref KEY_DISABLE_IND message tBUT_VAL_SND_CFM but_val_snd_cfm;
typedef struct tBUT_DISABLE_IND but_disable_ind;
{ }tBUT_PRF_MSG;
///Connection handle
uint16_t conhdl;
}tBUT_DISABLE_IND;
BOOLEAN ble_but_prf_hdl_event(prf_hdr_evt_t *msg_data);
typedef union
{ void ble_but_prf_disable(void);
uint16_t conhdl;
tBUT_CRT_DB_REQ but_crt_db_req;
tBUT_CRT_DB_CFM but_crt_db_cfm;
tBUT_CFG_NTF_IND but_cfg_ntf_ind; #endif ///BUT_PROFILE_CFG
tBUT_SND_CHAR_VAL_REQ but_snd_char_val_req;
tBUT_ENABLE_REQ but_enable_req;
tBUT_VAL_SND_CFM but_val_snd_cfm;
tBUT_DISABLE_IND but_disable_ind;
}tBUT_PRF_MSG;
BOOLEAN ble_but_prf_hdl_event(prf_hdr_evt_t *msg_data);
void ble_but_prf_disable(void);
#endif ///BUT_PROFILE_CFG

View File

@@ -1,3 +1,17 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>

View File

@@ -1,3 +1,17 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*************************************************************** /***************************************************************
* *
* This file is for gatt server device. It instantiates BATTERY * This file is for gatt server device. It instantiates BATTERY

View File

@@ -1,3 +1,17 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <stdio.h> #include <stdio.h>
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>

View File

@@ -1,3 +1,17 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>