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 "bt_prf_sys.h"
#include "fixed_queue.h"

View File

@ -1,16 +1,16 @@
/**
****************************************************************************************
*
* @file bt_prf_task.c
*
* @brief Application entry point
*
* Copyright (C) Espressif 2016
* Created by Yulong at 2016/10/11
*
*
****************************************************************************************
*/
// 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_prf_task.h"
#include "bt_prf_sys.h"

View File

@ -1,16 +1,16 @@
/**
****************************************************************************************
*
* @file bt_profile_act.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.

View File

@ -1,16 +1,16 @@
/**
****************************************************************************************
*
* @file bt_prf_task.h
*
* @brief Application entry point
*
* Copyright (C) Espressif 2016
* Created by Yulong at 2016/10/12
*
*
****************************************************************************************
*/
// 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>

View File

@ -1,16 +1,16 @@
/**
****************************************************************************************
*
* @file bt_prf_sys.h
*
* @brief Application entry point
*
* Copyright (C) Espressif 2016
* Created by Yulong at 2016/10/12
*
*
****************************************************************************************
*/
// 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.
#ifndef _PROFILE_SYS_H__
#define _PROFILE_SYS_H__

View File

@ -1,24 +1,24 @@
/**
****************************************************************************************
*
* @file bt_prf_task.h
*
* @brief Application entry point
*
* Copyright (C) Espressif 2016
* Created by Yulong at 2016/10/11
*
*
****************************************************************************************
*/
#include <stddef.h>
#include "bt_defs.h"
#include "fixed_queue.h"
#ifndef BT_PRF_TASK_H__
#define BT_PRF_TASK_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 <stddef.h>
#include "bt_defs.h"
#include "fixed_queue.h"
#ifndef BT_PRF_TASK_H__
#define BT_PRF_TASK_H__
/* Functions provided by bt_prf_task.c
************************************
*/

View File

@ -1,16 +1,16 @@
/**
****************************************************************************************
*
* @file button_pro.c
*
* @brief Application entry point
*
* Copyright (C) Espressif 2016
* Created by Yulong at 2016/8/18
*
*
****************************************************************************************
*/
// 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>

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"
// 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)
#include "bt_target.h"

View File

@ -1,16 +1,16 @@
/**
****************************************************************************************
*
* @file wx_airsync_prf.h
*
* @brief Application entry point
*
* Copyright (C) Espressif 2016
* Created by Yulong at 2016/9/29
*
*
****************************************************************************************
*/
// 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 "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"
// 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)

View File

@ -1,9 +1,18 @@
/***************************************************************
* *
* * This file is for battery service based on bta layer
* *
***************************************************************/
#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 <stdbool.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>
// 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 "prf_defs.h"

View File

@ -1,16 +1,16 @@
/**
****************************************************************************************
*
* @file button_pro.c
*
* @brief Application entry point
*
* Copyright (C) Espressif 2016
* Created by Yulong at 2016/9/7
*
*
****************************************************************************************
*/
// 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 "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_
// 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_
#include "bta_api.h"

File diff suppressed because it is too large Load Diff

View File

@ -1,108 +1,108 @@
/**
****************************************************************************************
*
* @file bt_app_sec.c
*
* @brief Application entry point
*
* Copyright (C) Espressif 2016
* Created by Yulong at 2016/10/13
*
*
****************************************************************************************
*/
#include "bt_app_sec.h"
#include <stdlib.h> // standard library
#include <string.h>
extern void srand (unsigned int seed);
extern int random (void);
/// Application Security Environment Structure
tAPP_SEC_ENV app_sec_env;
/*******************************************************************************
**
** Function app_ble_sec_gen_tk
**
** Description This function is called to generate the ble tk
**
** Returns the generate tk value
**
*******************************************************************************/
UINT32 app_ble_sec_gen_tk(void)
{
// Generate a PIN Code (Between 100000 and 999999)
return (100000 + (random()%900000));
}
/*******************************************************************************
**
** Function app_ble_sec_gen_ltk
**
** Description This function is called to generate the ble ltk
**
** Returns NULL
**
*******************************************************************************/
void app_ble_sec_gen_ltk(UINT8 key_size)
{
// Counter
UINT8 i;
app_sec_env.key_size = key_size;
// Randomly generate the LTK and the Random Number
for (i = 0; i < RAND_NB_LEN; i++)
{
app_sec_env.rand_nb.nb[i] = random()%256;
}
// Randomly generate the end of the LTK
for (i = 0; i < SEC_KEY_LEN; i++)
{
app_sec_env.ltk.key[i] = (((key_size) < (16 - i)) ? 0 : random()%256);
}
// Randomly generate the EDIV
app_sec_env.ediv = random()%65536;
}
/*******************************************************************************
**
** Function app_ble_sec_init
**
** Description This function is init the security env and function
**
** Returns NULL
**
*******************************************************************************/
void app_ble_sec_init()
{
// Reset Security Environment
memset(&app_sec_env, 0, sizeof(app_sec_env));
}
/*******************************************************************************
**
** Function app_ble_security_start
**
** Description This function is called by the slave when the seurity start
**
** Returns NULL
**
*******************************************************************************/
void app_ble_security_start(void)
{
}
// 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_app_sec.h"
#include <stdlib.h> // standard library
#include <string.h>
extern void srand (unsigned int seed);
extern int random (void);
/// Application Security Environment Structure
tAPP_SEC_ENV app_sec_env;
/*******************************************************************************
**
** Function app_ble_sec_gen_tk
**
** Description This function is called to generate the ble tk
**
** Returns the generate tk value
**
*******************************************************************************/
UINT32 app_ble_sec_gen_tk(void)
{
// Generate a PIN Code (Between 100000 and 999999)
return (100000 + (random()%900000));
}
/*******************************************************************************
**
** Function app_ble_sec_gen_ltk
**
** Description This function is called to generate the ble ltk
**
** Returns NULL
**
*******************************************************************************/
void app_ble_sec_gen_ltk(UINT8 key_size)
{
// Counter
UINT8 i;
app_sec_env.key_size = key_size;
// Randomly generate the LTK and the Random Number
for (i = 0; i < RAND_NB_LEN; i++)
{
app_sec_env.rand_nb.nb[i] = random()%256;
}
// Randomly generate the end of the LTK
for (i = 0; i < SEC_KEY_LEN; i++)
{
app_sec_env.ltk.key[i] = (((key_size) < (16 - i)) ? 0 : random()%256);
}
// Randomly generate the EDIV
app_sec_env.ediv = random()%65536;
}
/*******************************************************************************
**
** Function app_ble_sec_init
**
** Description This function is init the security env and function
**
** Returns NULL
**
*******************************************************************************/
void app_ble_sec_init()
{
// Reset Security Environment
memset(&app_sec_env, 0, sizeof(app_sec_env));
}
/*******************************************************************************
**
** Function app_ble_security_start
**
** Description This function is called by the slave when the seurity start
**
** Returns NULL
**
*******************************************************************************/
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 "bta_api.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"

File diff suppressed because it is too large Load Diff

View File

@ -1,78 +1,78 @@
/**
****************************************************************************************
*
* @file bt_app_sec.h
*
* @brief Application entry point
*
* Copyright (C) Espressif 2016
* Created by Yulong at 2016/10/13
*
*
****************************************************************************************
*/
#include "bt_types.h"
#define APP_SEC_IRK_FLAG (0)
#define RAND_NB_LEN 0x08
#define SEC_KEY_LEN 0x10
/*
* STRUCTURES DEFINITIONS
****************************************************************************************
*/
/// Generic Security key structure
typedef struct
{
/// Key value MSB -> LSB
UINT8 key[SEC_KEY_LEN];
}smp_sec_key;
///Random number structure
typedef struct
{
///8-byte array for random number
UINT8 nb[RAND_NB_LEN];
}rand_nb;
typedef struct
{
// LTK
smp_sec_key ltk;
// Random Number
rand_nb rand_nb;
// EDIV
UINT16 ediv;
// LTK key size
UINT8 key_size;
// Last paired peer address type
UINT8 peer_addr_type;
// Last paired peer address
BD_ADDR peer_addr;
// authentication level
UINT8 auth;
}tAPP_SEC_ENV;
extern tAPP_SEC_ENV app_sec_env;
/*
* GLOBAL FUNCTIONS DECLARATIONS
****************************************************************************************
*/
void app_ble_sec_init(void);
void app_ble_sec_pairing_cmp_evt_send(UINT8);
UINT32 app_ble_sec_gen_tk(void);
void app_ble_sec_gen_ltk(UINT8 key_size);
void app_ble_security_start(void);
// 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_types.h"
#define APP_SEC_IRK_FLAG (0)
#define RAND_NB_LEN 0x08
#define SEC_KEY_LEN 0x10
/*
* STRUCTURES DEFINITIONS
****************************************************************************************
*/
/// Generic Security key structure
typedef struct
{
/// Key value MSB -> LSB
UINT8 key[SEC_KEY_LEN];
}smp_sec_key;
///Random number structure
typedef struct
{
///8-byte array for random number
UINT8 nb[RAND_NB_LEN];
}rand_nb;
typedef struct
{
// LTK
smp_sec_key ltk;
// Random Number
rand_nb rand_nb;
// EDIV
UINT16 ediv;
// LTK key size
UINT8 key_size;
// Last paired peer address type
UINT8 peer_addr_type;
// Last paired peer address
BD_ADDR peer_addr;
// authentication level
UINT8 auth;
}tAPP_SEC_ENV;
extern tAPP_SEC_ENV app_sec_env;
/*
* GLOBAL FUNCTIONS DECLARATIONS
****************************************************************************************
*/
void app_ble_sec_init(void);
void app_ble_sec_pairing_cmp_evt_send(UINT8);
UINT32 app_ble_sec_gen_tk(void);
void app_ble_sec_gen_ltk(UINT8 key_size);
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 "freertos/FreeRTOS.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

View File

@ -1,16 +1,16 @@
/**
****************************************************************************************
*
* @file bt_app.c
*
* @brief Application entry point
*
* Copyright (C) Espressif 2016
* Created by Yulong at 2016/9/9
*
*
****************************************************************************************
*/
// 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_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 <string.h>
#include <stdbool.h>

View File

@ -1,130 +1,131 @@
/**
****************************************************************************************
*
* @file app_airsync_md5.h
*
* @brief Application airsync md5 generation Entry Point
*
* Copyright (C) ESPRESSIF 2016
* Created by Yulong at 2016/10/9
*
****************************************************************************************
*/
#include "prf_defs.h"
#if (WX_AIRSYNC_CFG)
#include <stdlib.h>
#include <stdio.h>
#include <math.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 }};
uint32_t F( uint32_t X, uint32_t Y, uint32_t Z )
{
return ( X & Y ) | ( ~X & Z );
}
uint32_t G( uint32_t X, uint32_t Y, uint32_t Z )
{
return ( X & Z ) | ( Y & ~Z );
}
uint32_t H( uint32_t X, uint32_t Y, uint32_t Z )
{
return X ^ Y ^ Z;
}
uint32_t I( uint32_t X, uint32_t Y, uint32_t Z )
{
return Y ^ ( X | ~Z );
}
// rotates x left s bits.
uint32_t rotate_left( uint32_t x, uint32_t s )
{
return ( x << s ) | ( x >> ( 32 - s ) );
}
// 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 c_bits;
if ( mod == 0 )
{
c_bits = MOD_SIZE;
}
else
{
c_bits = ( MOD_SIZE + BLOCK_SIZE - mod ) % BLOCK_SIZE;
}
return c_bits / BITS;
}
MD5String append_padding_bits ( char * argv )
{
uint32_t msg_length = strlen ( argv );
uint32_t bit_length = count_padding_bits ( msg_length );
uint64_t app_length = msg_length * BITS;
MD5String string;
string.str = (char *)GKI_getbuf(msg_length + bit_length + APP_SIZE / BITS);
strncpy ( string.str, argv, msg_length );
memset ( string.str + msg_length, 0, bit_length );
string.str [ msg_length ] = SINGLE_ONE_BIT;
memmove ( string.str + msg_length + bit_length, (char *)&app_length, sizeof( uint64_t ) );
string.len = msg_length + bit_length + sizeof( uint64_t );
return string;
}
int32_t wechat_md5 (char *argv, uint8_t *md5_32)
{
MD5String string;
uint32_t w[16];
uint32_t chain[4];
uint32_t state[4];
uint32_t ( *auxi[ 4 ])( uint32_t, uint32_t, uint32_t ) = { F, G, H, I };
int sIdx;
int wIdx;
string = append_padding_bits ( argv );
chain[0] = A;
chain[1] = B;
chain[2] = C;
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) );
for ( uint8_t roundIdx = 0; roundIdx < 4; roundIdx++ )
{
wIdx = X[ roundIdx ][ 0 ];
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+3) % 4]) + w[ wIdx ] + (uint32_t)floor((1ULL << 32) * fabs(sin( roundIdx * 16 + i + 1 )) ),
S[ roundIdx ][ i % 4 ]);
sIdx = ( sIdx + 3 ) % 4;
wIdx = ( wIdx + X[ roundIdx ][ 1 ] ) & 0xF;
}
}
chain[ 0 ] += state[ 0 ];
chain[ 1 ] += state[ 1 ];
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 + 8, (char *)&chain[2], sizeof(uint32_t) );
memmove ( md5_32 + 12, (char *)&chain[3], sizeof(uint32_t) );
free(string.str);
string.str = NULL;
return EXIT_SUCCESS;
}
#endif ///WX_AIRSYNC_CFG
// 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 "prf_defs.h"
#if (WX_AIRSYNC_CFG)
#include <stdlib.h>
#include <stdio.h>
#include <math.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 }};
uint32_t F( uint32_t X, uint32_t Y, uint32_t Z )
{
return ( X & Y ) | ( ~X & Z );
}
uint32_t G( uint32_t X, uint32_t Y, uint32_t Z )
{
return ( X & Z ) | ( Y & ~Z );
}
uint32_t H( uint32_t X, uint32_t Y, uint32_t Z )
{
return X ^ Y ^ Z;
}
uint32_t I( uint32_t X, uint32_t Y, uint32_t Z )
{
return Y ^ ( X | ~Z );
}
// rotates x left s bits.
uint32_t rotate_left( uint32_t x, uint32_t s )
{
return ( x << s ) | ( x >> ( 32 - s ) );
}
// 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 c_bits;
if ( mod == 0 )
{
c_bits = MOD_SIZE;
}
else
{
c_bits = ( MOD_SIZE + BLOCK_SIZE - mod ) % BLOCK_SIZE;
}
return c_bits / BITS;
}
MD5String append_padding_bits ( char * argv )
{
uint32_t msg_length = strlen ( argv );
uint32_t bit_length = count_padding_bits ( msg_length );
uint64_t app_length = msg_length * BITS;
MD5String string;
string.str = (char *)GKI_getbuf(msg_length + bit_length + APP_SIZE / BITS);
strncpy ( string.str, argv, msg_length );
memset ( string.str + msg_length, 0, bit_length );
string.str [ msg_length ] = SINGLE_ONE_BIT;
memmove ( string.str + msg_length + bit_length, (char *)&app_length, sizeof( uint64_t ) );
string.len = msg_length + bit_length + sizeof( uint64_t );
return string;
}
int32_t wechat_md5 (char *argv, uint8_t *md5_32)
{
MD5String string;
uint32_t w[16];
uint32_t chain[4];
uint32_t state[4];
uint32_t ( *auxi[ 4 ])( uint32_t, uint32_t, uint32_t ) = { F, G, H, I };
int sIdx;
int wIdx;
string = append_padding_bits ( argv );
chain[0] = A;
chain[1] = B;
chain[2] = C;
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) );
for ( uint8_t roundIdx = 0; roundIdx < 4; roundIdx++ )
{
wIdx = X[ roundIdx ][ 0 ];
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+3) % 4]) + w[ wIdx ] + (uint32_t)floor((1ULL << 32) * fabs(sin( roundIdx * 16 + i + 1 )) ),
S[ roundIdx ][ i % 4 ]);
sIdx = ( sIdx + 3 ) % 4;
wIdx = ( wIdx + X[ roundIdx ][ 1 ] ) & 0xF;
}
}
chain[ 0 ] += state[ 0 ];
chain[ 1 ] += state[ 1 ];
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 + 8, (char *)&chain[2], sizeof(uint32_t) );
memmove ( md5_32 + 12, (char *)&chain[3], sizeof(uint32_t) );
free(string.str);
string.str = NULL;
return EXIT_SUCCESS;
}
#endif ///WX_AIRSYNC_CFG

View File

@ -1,160 +1,161 @@
/**
****************************************************************************************
*
* @file app_airsync_prf.c
*
* @brief Application Security Entry Point
*
* Copyright (C) ESPRESSIF 2016
* Created by Yulong at 2016/9/30
*
****************************************************************************************
*/
#include "prf_defs.h"
#if (WX_AIRSYNC_CFG)
#include "app_airsync_prf.h"
#include "wx_airsync_prf.h"
#include "app_wechat_util.h"
#include "gki.h"
#include "mpbledemo2.h"
/*****************************************************************************
* data handle
*****************************************************************************/
data_info g_send_data;
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);
///function for register all products
static void register_all_products(void)
{
REGISTER(mpbledemo2);
// could register more products if defined
}
void app_wechat_init(void)
{
register_all_products();
data_handler_init(&m_mpbledemo2_handler,PRODUCT_TYPE_MPBLEDEMO2);
m_mpbledemo2_handler->m_data_init_func();
m_mpbledemo2_handler->m_data_init_peripheral_func();
app_wechat_SetDatahandler(m_mpbledemo2_handler);
}
int ble_wechat_indicate_data_chunk(void)
{
uint16_t chunk_len = 0;
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)
{
app_wechat_datahandler()->m_data_free_func(g_send_data.data,g_send_data.len);
g_send_data.data = NULL;
g_send_data.len = 0;
g_send_data.offset = 0;
return 0;
}
g_send_data.offset += chunk_len;
return 1;
}
/*******************************************************************************
// 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 "prf_defs.h"
#if (WX_AIRSYNC_CFG)
#include "app_airsync_prf.h"
#include "wx_airsync_prf.h"
#include "app_wechat_util.h"
#include "gki.h"
#include "mpbledemo2.h"
/*****************************************************************************
* data handle
*****************************************************************************/
data_info g_send_data;
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);
///function for register all products
static void register_all_products(void)
{
REGISTER(mpbledemo2);
// could register more products if defined
}
void app_wechat_init(void)
{
register_all_products();
data_handler_init(&m_mpbledemo2_handler,PRODUCT_TYPE_MPBLEDEMO2);
m_mpbledemo2_handler->m_data_init_func();
m_mpbledemo2_handler->m_data_init_peripheral_func();
app_wechat_SetDatahandler(m_mpbledemo2_handler);
}
int ble_wechat_indicate_data_chunk(void)
{
uint16_t chunk_len = 0;
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)
{
app_wechat_datahandler()->m_data_free_func(g_send_data.data,g_send_data.len);
g_send_data.data = NULL;
g_send_data.len = 0;
g_send_data.offset = 0;
return 0;
}
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
** receive the data from the peer device
** parms appid:the appid have been register to the gatt database
** conn_id:the current connection index
** msg_val:the airsync value receive from peer device
** Description the callback function after the airsync profile have been
** receive the data from the peer device
** parms appid:the appid have been register to the gatt database
** conn_id:the current connection index
** msg_val:the airsync value receive from peer device
** Returns NULL
**
*******************************************************************************/
static void airsync_process_msgreceive_cb(UINT8 app_id,
UINT8 conn_id,uint8_t *pData, uint16_t length)
{
int error_code;
int chunk_size = 0;
if(length <= BLE_WECHAT_MAX_DATA_LEN)
{
if(g_rcv_data.len == 0)
{
BpFixHead *fix_head = (BpFixHead *)pData;
g_rcv_data.len = ntohs(fix_head->nLength);
g_rcv_data.offset = 0;
g_rcv_data.data = (uint8_t *)GKI_getbuf(g_rcv_data.len);
}
chunk_size = g_rcv_data.len - g_rcv_data.offset;
chunk_size = chunk_size < length ? chunk_size : length;
memcpy(g_rcv_data.data + g_rcv_data.offset, pData, chunk_size);
g_rcv_data.offset += chunk_size;
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);
app_wechat_datahandler()->m_data_free_func(g_rcv_data.data,g_rcv_data.len);
wechat_error_chack(app_wechat_datahandler(), error_code);
g_rcv_data.len = 0;
g_rcv_data.offset = 0;
app_wechat_datahandler()->m_data_main_process_func();
}
}
}
void app_wechat_SetDatahandler(data_handler* pHandler)
{
pDataHandler = pHandler;
}
bool ble_wechat_is_last_data_sent_out(void)
{
return (g_send_data.len == 0 && g_send_data.offset == 0 ) || \
(g_send_data.len != 0 && g_send_data.len == g_send_data.offset);
}
//device sent data on the indicate characteristic
int ble_wechat_indicate_data(uint8_t *data, int len)
{
if(data == NULL || len == 0)
{
return 0;
}
if(!ble_wechat_is_last_data_sent_out())
{
return 0;
}
g_send_data.data = data;
g_send_data.len = len;
g_send_data.offset = 0;
return (ble_wechat_indicate_data_chunk());
}
data_handler *app_wechat_datahandler(void)
{
return pDataHandler;
}
#endif ///WX_AIRSYNC_CFG
*******************************************************************************/
static void airsync_process_msgreceive_cb(UINT8 app_id,
UINT8 conn_id,uint8_t *pData, uint16_t length)
{
int error_code;
int chunk_size = 0;
if(length <= BLE_WECHAT_MAX_DATA_LEN)
{
if(g_rcv_data.len == 0)
{
BpFixHead *fix_head = (BpFixHead *)pData;
g_rcv_data.len = ntohs(fix_head->nLength);
g_rcv_data.offset = 0;
g_rcv_data.data = (uint8_t *)GKI_getbuf(g_rcv_data.len);
}
chunk_size = g_rcv_data.len - g_rcv_data.offset;
chunk_size = chunk_size < length ? chunk_size : length;
memcpy(g_rcv_data.data + g_rcv_data.offset, pData, chunk_size);
g_rcv_data.offset += chunk_size;
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);
app_wechat_datahandler()->m_data_free_func(g_rcv_data.data,g_rcv_data.len);
wechat_error_chack(app_wechat_datahandler(), error_code);
g_rcv_data.len = 0;
g_rcv_data.offset = 0;
app_wechat_datahandler()->m_data_main_process_func();
}
}
}
void app_wechat_SetDatahandler(data_handler* pHandler)
{
pDataHandler = pHandler;
}
bool ble_wechat_is_last_data_sent_out(void)
{
return (g_send_data.len == 0 && g_send_data.offset == 0 ) || \
(g_send_data.len != 0 && g_send_data.len == g_send_data.offset);
}
//device sent data on the indicate characteristic
int ble_wechat_indicate_data(uint8_t *data, int len)
{
if(data == NULL || len == 0)
{
return 0;
}
if(!ble_wechat_is_last_data_sent_out())
{
return 0;
}
g_send_data.data = data;
g_send_data.len = len;
g_send_data.offset = 0;
return (ble_wechat_indicate_data_chunk());
}
data_handler *app_wechat_datahandler(void)
{
return pDataHandler;
}
#endif ///WX_AIRSYNC_CFG

View File

@ -1,20 +1,16 @@
/**
*******************************************************************************
*********
*
* @file app_button.c
*
* @brief button Service Application entry point
*
* Copyright (C) ESPRESSSIF 2016
* Created by Yulong at 2016/08/24
*
*
*******************************************************************************
*********
*/
// 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 "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,

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

View File

@ -1,52 +1,39 @@
/**
****************************************************************************************
*
* @file app_airsync_md5.h
*
* @brief Application airsync md5 generation head Entry Point
*
* Copyright (C) ESPRESSIF 2016
* Created by Yulong at 2016/10/9
*
****************************************************************************************
*/
#ifndef __APP_AIRSYNC_MD5__
#define __APP_AIRSYNC_MD5__
#include "prf_defs.h"
#if (WX_AIRSYNC_CFG)
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <math.h>
#define SINGLE_ONE_BIT 0x80
#define BLOCK_SIZE 512
#define MOD_SIZE 448
#define APP_SIZE 64
#define BITS 8
// MD5 Chaining Variable
#define A 0x67452301UL
#define B 0xEFCDAB89UL
#define C 0x98BADCFEUL
#define D 0x10325476UL
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__
#ifndef __APP_AIRSYNC_MD5__
#define __APP_AIRSYNC_MD5__
#include "prf_defs.h"
#if (WX_AIRSYNC_CFG)
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <math.h>
#define SINGLE_ONE_BIT 0x80
#define BLOCK_SIZE 512
#define MOD_SIZE 448
#define APP_SIZE 64
#define BITS 8
// MD5 Chaining Variable
#define A 0x67452301UL
#define B 0xEFCDAB89UL
#define C 0x98BADCFEUL
#define D 0x10325476UL
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 @@
/**
****************************************************************************************
*
* @file app_airsync_prf.h
*
* @brief Application Security Entry Point
*
* Copyright (C) ESPRESSIF 2016
* Created by Yulong at 2016/9/30
*
****************************************************************************************
*/
#ifndef _APP_AIRSYNC_PRF_H__
#define _APP_AIRSYNC_PRF_H__
#include "prf_defs.h"
#if (WX_AIRSYNC_CFG)
#include "app_wechat_util.h"
#include <stdint.h>
#include <stdbool.h>
#define MAGIC_NUMBER 0xFE
/**
****************************************************************************************
* @brief Create Wechat Database
*
****************************************************************************************
*/
void app_wechat_create_db(void);
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__
#ifndef _APP_AIRSYNC_PRF_H__
#define _APP_AIRSYNC_PRF_H__
#include "prf_defs.h"
#if (WX_AIRSYNC_CFG)
#include "app_wechat_util.h"
#include <stdint.h>
#include <stdbool.h>
#define MAGIC_NUMBER 0xFE
/**
****************************************************************************************
* @brief Create Wechat Database
*
****************************************************************************************
*/
void app_wechat_create_db(void);
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
****************************************************************************************

View File

@ -1,131 +1,116 @@
/**
*******************************************************************************
*********
*
* @file app_button_int.h
*
* @brief button Service Application entry point
*
* Copyright (C) ESPRESSSIF 2016
* Created by Yulong at 2016/10/17
*
*******************************************************************************
**********/
#include "prf_defs.h"
#include "bt_prf_sys.h"
#include "bt_types.h"
#if (BUT_PROFILE_CFG)
/// Messages for Device Information Service Server
enum
{
///Add a BUTTON instance into the database
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
BLE_BUT_SET_CHAR_VAL_REQ_EVT,
///Start the button notify Service Task - at connection
BLE_BUT_ENABLE_REQ_EVT,
/// Inform the application that the profile service role task has been disabled after a disconnection
BLE_BUT_DISABLE_IND_EVT,
/// Inform the application that the profile service has been reiceivd the charateristic write commamd from Client
BLE_BUT_CHAR_WRITE_IND_EVT,
///Error indication to Host
BLE_BUT_ERROR_IND_EVT,
};
/// Parameters of the @ref KEY_CREATE_DB_REQ message
typedef struct
{
///Database configuration
uint16_t features;
}tBUT_CRT_DB_REQ;
/// Parameters of the @ref KEY_CREATE_DB_CFM message
typedef struct
{
///Status
uint8_t status;
}tBUT_CRT_DB_CFM;
///Parameters of the @ref key_CFG_INDNTF_IND message
typedef struct
{
///Connection handle
uint16_t conhdl;
///Stop/notify/indicate value to configure into the peer characteristic
uint16_t cfg_val;
/// characteristics
uint8_t char_code;
}tBUT_CFG_NTF_IND;
/// Parameters of the @ref KEY_SET_CHAR_VAL_REQ message - shall be dynamically allocated
typedef struct
{
/// Characteristic Code
//uint8_t char_code;
uint8_t conhdl;
uint8_t key_val_len;
uint8_t key_val[2];
}tBUT_SND_CHAR_VAL_REQ;
/// Parameters of the @ref KEY_ENABLE_REQ message
typedef struct
{
///Connection handle
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;
///Type of connection
uint8_t con_type;
}tBUT_ENABLE_REQ;
///Parameters of the @ref KEY_VAL_SEND_CFM message
typedef struct
{
///Connection handle
uint16_t conhdl;
///Status
uint8_t status;
}tBUT_VAL_SND_CFM;
/// Parameters of the @ref KEY_DISABLE_IND message
typedef struct
{
///Connection handle
uint16_t conhdl;
}tBUT_DISABLE_IND;
typedef union
{
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;
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
#include "prf_defs.h"
#include "bt_prf_sys.h"
#include "bt_types.h"
#if (BUT_PROFILE_CFG)
/// Messages for Device Information Service Server
enum
{
///Add a BUTTON instance into the database
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
BLE_BUT_SET_CHAR_VAL_REQ_EVT,
///Start the button notify Service Task - at connection
BLE_BUT_ENABLE_REQ_EVT,
/// Inform the application that the profile service role task has been disabled after a disconnection
BLE_BUT_DISABLE_IND_EVT,
/// Inform the application that the profile service has been reiceivd the charateristic write commamd from Client
BLE_BUT_CHAR_WRITE_IND_EVT,
///Error indication to Host
BLE_BUT_ERROR_IND_EVT,
};
/// Parameters of the @ref KEY_CREATE_DB_REQ message
typedef struct
{
///Database configuration
uint16_t features;
}tBUT_CRT_DB_REQ;
/// Parameters of the @ref KEY_CREATE_DB_CFM message
typedef struct
{
///Status
uint8_t status;
}tBUT_CRT_DB_CFM;
///Parameters of the @ref key_CFG_INDNTF_IND message
typedef struct
{
///Connection handle
uint16_t conhdl;
///Stop/notify/indicate value to configure into the peer characteristic
uint16_t cfg_val;
/// characteristics
uint8_t char_code;
}tBUT_CFG_NTF_IND;
/// Parameters of the @ref KEY_SET_CHAR_VAL_REQ message - shall be dynamically allocated
typedef struct
{
/// Characteristic Code
//uint8_t char_code;
uint8_t conhdl;
uint8_t key_val_len;
uint8_t key_val[2];
}tBUT_SND_CHAR_VAL_REQ;
/// Parameters of the @ref KEY_ENABLE_REQ message
typedef struct
{
///Connection handle
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;
///Type of connection
uint8_t con_type;
}tBUT_ENABLE_REQ;
///Parameters of the @ref KEY_VAL_SEND_CFM message
typedef struct
{
///Connection handle
uint16_t conhdl;
///Status
uint8_t status;
}tBUT_VAL_SND_CFM;
/// Parameters of the @ref KEY_DISABLE_IND message
typedef struct
{
///Connection handle
uint16_t conhdl;
}tBUT_DISABLE_IND;
typedef union
{
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;
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 <stdlib.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

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 <stdint.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 <stdlib.h>
#include <string.h>