From ec6016a49498b682525fefa31a02fc232631a43b Mon Sep 17 00:00:00 2001 From: strawmanbobi Date: Mon, 13 Mar 2017 12:54:31 +0800 Subject: [PATCH] completed TV binary transfer and decode --- .../Source/Application/Board/Board_uart.h | 2 +- .../Source/Application/Board/board_uart.c | 6 +- .../Application/Profile/simpleGATTprofile.c | 1026 ++++++++--------- .../CC26xx/Source/Application/buffer.h | 2 +- .../Source/Application/simpleBLEPeripheral.c | 80 +- .../Source/Application/simpleBLEPeripheral.h | 6 +- 6 files changed, 573 insertions(+), 549 deletions(-) diff --git a/src/example/decode_example/CC26xx/Source/Application/Board/Board_uart.h b/src/example/decode_example/CC26xx/Source/Application/Board/Board_uart.h index 5753b6b..e0f5a87 100644 --- a/src/example/decode_example/CC26xx/Source/Application/Board/Board_uart.h +++ b/src/example/decode_example/CC26xx/Source/Application/Board/Board_uart.h @@ -62,7 +62,7 @@ extern void PrintString(uint8 *str); extern void PrintValue(char *title, uint32 value, uint8 format); -extern void WriteBytes(uint8 *str); +extern void WriteBytes(uint8 *data, uint16_t len); extern void WriteValue(char *title, uint32 value, uint8 format); diff --git a/src/example/decode_example/CC26xx/Source/Application/Board/board_uart.c b/src/example/decode_example/CC26xx/Source/Application/Board/board_uart.c index b732b33..3d992df 100644 --- a/src/example/decode_example/CC26xx/Source/Application/Board/board_uart.c +++ b/src/example/decode_example/CC26xx/Source/Application/Board/board_uart.c @@ -154,9 +154,9 @@ void PrintValue(char *content, uint32 value, uint8 format) } -void WriteBytes(uint8 *str) +void WriteBytes(uint8 *data, uint16_t len) { - UART_WriteTransport(str, (strlen((char*)str))); + UART_WriteTransport(data, len); } void WriteValue(char *content, uint32 value, uint8 format) @@ -169,7 +169,7 @@ void WriteValue(char *content, uint32 value, uint8 format) memcpy(buf, content, tmpLen); err = (uint32)(value); _ltoa(err, &buf[tmpLen], format); - WriteBytes(buf); + WriteBytes(buf, strlen(buf)); } #endif diff --git a/src/example/decode_example/CC26xx/Source/Application/Profile/simpleGATTprofile.c b/src/example/decode_example/CC26xx/Source/Application/Profile/simpleGATTprofile.c index 00b1bc9..2e1dc31 100644 --- a/src/example/decode_example/CC26xx/Source/Application/Profile/simpleGATTprofile.c +++ b/src/example/decode_example/CC26xx/Source/Application/Profile/simpleGATTprofile.c @@ -3,7 +3,7 @@ Revised: $Date: 2015-07-20 11:31:07 -0700 (Mon, 20 Jul 2015) $ Revision: $Revision: 44370 $ - Description: This file contains the Simple GATT profile sample GATT service + Description: This file contains the Simple GATT profile sample GATT service profile for use with the BLE sample application. Copyright 2010 - 2015 Texas Instruments Incorporated. All rights reserved. @@ -22,8 +22,8 @@ its documentation for any purpose. YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE - PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, - INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE, + PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, + INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER @@ -34,11 +34,9 @@ (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS. Should you have any questions regarding your right to use this Software, - contact Texas Instruments Incorporated at www.TI.com. + contact Texas Instruments Incorporated at www.TI.com. **************************************************************************************************/ -// ÐÞ¸Ä---amomcu---------2015.08.31---- -// °¢Äªµ¥Æ¬»úÌÔ±¦µê https://amomcu.taobao.com/ /********************************************************************* * INCLUDES @@ -55,11 +53,15 @@ #include "gapbondmgr.h" #include "simpleGATTprofile.h" +#include "simpleBlePeripheral.h" + /********************************************************************* * MACROS */ +#define USE_CUSTOM_CHARACTERISTIC + /********************************************************************* * CONSTANTS */ @@ -75,50 +77,50 @@ */ // Simple GATT Profile Service UUID: 0xFFF0 CONST uint8 simpleProfileServUUID[ATT_BT_UUID_SIZE] = -{ - LO_UINT16(SIMPLEPROFILE_SERV_UUID), HI_UINT16(SIMPLEPROFILE_SERV_UUID) +{ + LO_UINT16(SIMPLEPROFILE_SERV_UUID), HI_UINT16(SIMPLEPROFILE_SERV_UUID) }; // Characteristic 1 UUID: 0xFFF1 CONST uint8 simpleProfilechar1UUID[ATT_BT_UUID_SIZE] = -{ - LO_UINT16(SIMPLEPROFILE_CHAR1_UUID), HI_UINT16(SIMPLEPROFILE_CHAR1_UUID) +{ + LO_UINT16(SIMPLEPROFILE_CHAR1_UUID), HI_UINT16(SIMPLEPROFILE_CHAR1_UUID) }; // Characteristic 2 UUID: 0xFFF2 CONST uint8 simpleProfilechar2UUID[ATT_BT_UUID_SIZE] = -{ - LO_UINT16(SIMPLEPROFILE_CHAR2_UUID), HI_UINT16(SIMPLEPROFILE_CHAR2_UUID) +{ + LO_UINT16(SIMPLEPROFILE_CHAR2_UUID), HI_UINT16(SIMPLEPROFILE_CHAR2_UUID) }; // Characteristic 3 UUID: 0xFFF3 CONST uint8 simpleProfilechar3UUID[ATT_BT_UUID_SIZE] = -{ - LO_UINT16(SIMPLEPROFILE_CHAR3_UUID), HI_UINT16(SIMPLEPROFILE_CHAR3_UUID) +{ + LO_UINT16(SIMPLEPROFILE_CHAR3_UUID), HI_UINT16(SIMPLEPROFILE_CHAR3_UUID) }; // Characteristic 4 UUID: 0xFFF4 CONST uint8 simpleProfilechar4UUID[ATT_BT_UUID_SIZE] = -{ - LO_UINT16(SIMPLEPROFILE_CHAR4_UUID), HI_UINT16(SIMPLEPROFILE_CHAR4_UUID) +{ + LO_UINT16(SIMPLEPROFILE_CHAR4_UUID), HI_UINT16(SIMPLEPROFILE_CHAR4_UUID) }; // Characteristic 5 UUID: 0xFFF5 CONST uint8 simpleProfilechar5UUID[ATT_BT_UUID_SIZE] = -{ - LO_UINT16(SIMPLEPROFILE_CHAR5_UUID), HI_UINT16(SIMPLEPROFILE_CHAR5_UUID) +{ + LO_UINT16(SIMPLEPROFILE_CHAR5_UUID), HI_UINT16(SIMPLEPROFILE_CHAR5_UUID) }; // Characteristic 6 UUID: 0xFFF6 CONST uint8 simpleProfilechar6UUID[ATT_BT_UUID_SIZE] = -{ - LO_UINT16(SIMPLEPROFILE_CHAR6_UUID), HI_UINT16(SIMPLEPROFILE_CHAR6_UUID) +{ + LO_UINT16(SIMPLEPROFILE_CHAR6_UUID), HI_UINT16(SIMPLEPROFILE_CHAR6_UUID) }; // Characteristic 7 UUID: 0xFFF7 CONST uint8 simpleProfilechar7UUID[ATT_BT_UUID_SIZE] = -{ - LO_UINT16(SIMPLEPROFILE_CHAR7_UUID), HI_UINT16(SIMPLEPROFILE_CHAR7_UUID) +{ + LO_UINT16(SIMPLEPROFILE_CHAR7_UUID), HI_UINT16(SIMPLEPROFILE_CHAR7_UUID) }; /********************************************************************* @@ -184,7 +186,7 @@ static uint8 simpleProfileChar4 = 0; // Client Characteristic Configuration only shows the configuration for // that client and writes only affect the configuration of that client. static gattCharCfg_t *simpleProfileChar4Config; - + // Simple Profile Characteristic 4 User Description static uint8 simpleProfileChar4UserDesp[17] = "Characteristic 4"; @@ -199,11 +201,11 @@ static uint8 simpleProfileChar5[SIMPLEPROFILE_CHAR5_LEN] = { 0, 0, 0, 0, 0 }; static uint8 simpleProfileChar5UserDesp[17] = "Characteristic 5"; -// Simple Profile Characteristic 6 Properties ¿É¶Á£¬¿Éд£¬ ¿É֪ͨ +// Simple Profile Characteristic 6 Properties static uint8 simpleProfileChar6Props = GATT_PROP_READ | GATT_PROP_WRITE_NO_RSP | GATT_PROP_NOTIFY; // Characteristic 6 Value -static uint8 simpleProfileChar6[SIMPLEPROFILE_CHAR6_LEN] = {0};// ÌØÕ÷Öµ³õʼ»¯ +static uint8 simpleProfileChar6[SIMPLEPROFILE_CHAR6_LEN] = {0}; static uint8 simpleProfileChar6Len = 0; // Simple Profile Characteristic 6 Configuration Each client has its own @@ -213,195 +215,195 @@ static uint8 simpleProfileChar6Len = 0; static gattCharCfg_t *simpleProfileChar6Config; // Simple Profile Characteristic 6 User Description -static uint8 simpleProfileChar6UserDesp[17] = "Characteristic 6"; // ÌØÕ÷ÖµÃèÊö +static uint8 simpleProfileChar6UserDesp[17] = "Characteristic 6"; /********************************************************************* * Profile Attributes - Table */ -static gattAttribute_t simpleProfileAttrTbl[SERVAPP_NUM_ATTR_SUPPORTED] = +static gattAttribute_t simpleProfileAttrTbl[SERVAPP_NUM_ATTR_SUPPORTED] = { - // Simple Profile Service - { - { ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type */ - GATT_PERMIT_READ, /* permissions */ - 0, /* handle */ - (uint8 *)&simpleProfileService /* pValue */ - }, + // Simple Profile Service + { + { ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type */ + GATT_PERMIT_READ, /* permissions */ + 0, /* handle */ + (uint8 *)&simpleProfileService /* pValue */ + }, // Characteristic 1 Declaration - { - { ATT_BT_UUID_SIZE, characterUUID }, - GATT_PERMIT_READ, - 0, - &simpleProfileChar1Props + { + { ATT_BT_UUID_SIZE, characterUUID }, + GATT_PERMIT_READ, + 0, + &simpleProfileChar1Props }, - // Characteristic Value 1 - { + // Characteristic Value 1 + { { ATT_BT_UUID_SIZE, simpleProfilechar1UUID }, - GATT_PERMIT_READ | GATT_PERMIT_WRITE, - 0, - &simpleProfileChar1 - }, + GATT_PERMIT_READ | GATT_PERMIT_WRITE, + 0, + &simpleProfileChar1 + }, - // Characteristic 1 User Description - { + // Characteristic 1 User Description + { { ATT_BT_UUID_SIZE, charUserDescUUID }, - GATT_PERMIT_READ, - 0, - simpleProfileChar1UserDesp - }, + GATT_PERMIT_READ, + 0, + simpleProfileChar1UserDesp + }, // Characteristic 2 Declaration - { - { ATT_BT_UUID_SIZE, characterUUID }, - GATT_PERMIT_READ, - 0, - &simpleProfileChar2Props + { + { ATT_BT_UUID_SIZE, characterUUID }, + GATT_PERMIT_READ, + 0, + &simpleProfileChar2Props }, - // Characteristic Value 2 - { + // Characteristic Value 2 + { { ATT_BT_UUID_SIZE, simpleProfilechar2UUID }, - GATT_PERMIT_READ, - 0, - &simpleProfileChar2 - }, - - // Characteristic 2 User Description - { - { ATT_BT_UUID_SIZE, charUserDescUUID }, - GATT_PERMIT_READ, - 0, - simpleProfileChar2UserDesp - }, - - // Characteristic 3 Declaration - { - { ATT_BT_UUID_SIZE, characterUUID }, - GATT_PERMIT_READ, - 0, - &simpleProfileChar3Props + GATT_PERMIT_READ, + 0, + &simpleProfileChar2 }, - // Characteristic Value 3 - { - { ATT_BT_UUID_SIZE, simpleProfilechar3UUID }, - GATT_PERMIT_WRITE, - 0, - &simpleProfileChar3 - }, - - // Characteristic 3 User Description - { + // Characteristic 2 User Description + { { ATT_BT_UUID_SIZE, charUserDescUUID }, - GATT_PERMIT_READ, - 0, - simpleProfileChar3UserDesp - }, + GATT_PERMIT_READ, + 0, + simpleProfileChar2UserDesp + }, + + // Characteristic 3 Declaration + { + { ATT_BT_UUID_SIZE, characterUUID }, + GATT_PERMIT_READ, + 0, + &simpleProfileChar3Props + }, + + // Characteristic Value 3 + { + { ATT_BT_UUID_SIZE, simpleProfilechar3UUID }, + GATT_PERMIT_WRITE, + 0, + &simpleProfileChar3 + }, + + // Characteristic 3 User Description + { + { ATT_BT_UUID_SIZE, charUserDescUUID }, + GATT_PERMIT_READ, + 0, + simpleProfileChar3UserDesp + }, // Characteristic 4 Declaration - { - { ATT_BT_UUID_SIZE, characterUUID }, - GATT_PERMIT_READ, - 0, - &simpleProfileChar4Props + { + { ATT_BT_UUID_SIZE, characterUUID }, + GATT_PERMIT_READ, + 0, + &simpleProfileChar4Props }, - // Characteristic Value 4 - { + // Characteristic Value 4 + { { ATT_BT_UUID_SIZE, simpleProfilechar4UUID }, - 0, - 0, - &simpleProfileChar4 - }, + 0, + 0, + &simpleProfileChar4 + }, - // Characteristic 4 configuration - { + // Characteristic 4 configuration + { { ATT_BT_UUID_SIZE, clientCharCfgUUID }, - GATT_PERMIT_READ | GATT_PERMIT_WRITE, - 0, - (uint8 *)&simpleProfileChar4Config - }, - - // Characteristic 4 User Description - { + GATT_PERMIT_READ | GATT_PERMIT_WRITE, + 0, + (uint8 *)&simpleProfileChar4Config + }, + + // Characteristic 4 User Description + { { ATT_BT_UUID_SIZE, charUserDescUUID }, - GATT_PERMIT_READ, - 0, - simpleProfileChar4UserDesp - }, -#if 1 + GATT_PERMIT_READ, + 0, + simpleProfileChar4UserDesp + }, +#if defined USE_CUSTOM_CHARACTERISTIC // Characteristic 5 Declaration - { - { ATT_BT_UUID_SIZE, characterUUID }, - GATT_PERMIT_READ, - 0, - &simpleProfileChar5Props + { + { ATT_BT_UUID_SIZE, characterUUID }, + GATT_PERMIT_READ, + 0, + &simpleProfileChar5Props }, - // Characteristic Value 5 - { + // Characteristic Value 5 + { { ATT_BT_UUID_SIZE, simpleProfilechar5UUID }, - GATT_PERMIT_AUTHEN_READ, - 0, - simpleProfileChar5 - }, - - // Characteristic 5 User Description - { - { ATT_BT_UUID_SIZE, charUserDescUUID }, - GATT_PERMIT_READ, - 0, - simpleProfileChar5UserDesp - }, - - // Characteristic 6 Declaration - { - { ATT_BT_UUID_SIZE, characterUUID }, - GATT_PERMIT_READ, - 0, - &simpleProfileChar6Props + GATT_PERMIT_AUTHEN_READ, + 0, + simpleProfileChar5 }, - // Characteristic Value 6 - { + // Characteristic 5 User Description + { + { ATT_BT_UUID_SIZE, charUserDescUUID }, + GATT_PERMIT_READ, + 0, + simpleProfileChar5UserDesp + }, + + // Characteristic 6 Declaration + { + { ATT_BT_UUID_SIZE, characterUUID }, + GATT_PERMIT_READ, + 0, + &simpleProfileChar6Props + }, + + // Characteristic Value 6 + { { ATT_BT_UUID_SIZE, simpleProfilechar6UUID }, GATT_PERMIT_READ | GATT_PERMIT_WRITE, - 0, - simpleProfileChar6 - }, + 0, + simpleProfileChar6 + }, - // Characteristic 6 configuration - { + // Characteristic 6 configuration + { { ATT_BT_UUID_SIZE, clientCharCfgUUID }, - GATT_PERMIT_READ | GATT_PERMIT_WRITE, - 0, - (uint8 *)&simpleProfileChar6Config - }, - - // Characteristic 6 User Description - { + GATT_PERMIT_READ | GATT_PERMIT_WRITE, + 0, + (uint8 *)&simpleProfileChar6Config + }, + + // Characteristic 6 User Description + { { ATT_BT_UUID_SIZE, charUserDescUUID }, - GATT_PERMIT_READ, - 0, - simpleProfileChar6UserDesp - }, -#endif + GATT_PERMIT_READ, + 0, + simpleProfileChar6UserDesp + }, +#endif }; /********************************************************************* * LOCAL FUNCTIONS */ static bStatus_t simpleProfile_ReadAttrCB(uint16_t connHandle, - gattAttribute_t *pAttr, - uint8_t *pValue, uint16_t *pLen, - uint16_t offset, uint16_t maxLen, - uint8_t method); + gattAttribute_t *pAttr, + uint8_t *pValue, uint16_t *pLen, + uint16_t offset, uint16_t maxLen, + uint8_t method); static bStatus_t simpleProfile_WriteAttrCB(uint16_t connHandle, - gattAttribute_t *pAttr, - uint8_t *pValue, uint16_t len, - uint16_t offset, uint8_t method); + gattAttribute_t *pAttr, + uint8_t *pValue, uint16_t len, + uint16_t offset, uint8_t method); /********************************************************************* * PROFILE CALLBACKS @@ -409,9 +411,9 @@ static bStatus_t simpleProfile_WriteAttrCB(uint16_t connHandle, // Simple Profile Service Callbacks CONST gattServiceCBs_t simpleProfileCBs = { - simpleProfile_ReadAttrCB, // Read callback function pointer - simpleProfile_WriteAttrCB, // Write callback function pointer - NULL // Authorization callback function pointer + simpleProfile_ReadAttrCB, // Read callback function pointer + simpleProfile_WriteAttrCB, // Write callback function pointer + NULL // Authorization callback function pointer }; /********************************************************************* @@ -431,52 +433,52 @@ CONST gattServiceCBs_t simpleProfileCBs = */ bStatus_t SimpleProfile_AddService( uint32 services ) { - uint8 status; + uint8 status; + + // Allocate Client Characteristic Configuration table + simpleProfileChar4Config = (gattCharCfg_t *)ICall_malloc( sizeof(gattCharCfg_t) * + linkDBNumConns ); + if ( simpleProfileChar4Config == NULL ) + { + return ( bleMemAllocError ); + } + + // Initialize Client Characteristic Configuration attributes + GATTServApp_InitCharCfg( INVALID_CONNHANDLE, simpleProfileChar4Config ); - // Allocate Client Characteristic Configuration table - simpleProfileChar4Config = (gattCharCfg_t *)ICall_malloc( sizeof(gattCharCfg_t) * - linkDBNumConns ); - if ( simpleProfileChar4Config == NULL ) - { - return ( bleMemAllocError ); - } - - // Initialize Client Characteristic Configuration attributes - GATTServApp_InitCharCfg( INVALID_CONNHANDLE, simpleProfileChar4Config ); - #if 1 - // Allocate Client Characteristic Configuration table - simpleProfileChar6Config = (gattCharCfg_t *)ICall_malloc( sizeof(gattCharCfg_t) * - linkDBNumConns ); - if ( simpleProfileChar6Config == NULL ) - { - return ( bleMemAllocError ); - } - - // Initialize Client Characteristic Configuration attributes - GATTServApp_InitCharCfg( INVALID_CONNHANDLE, simpleProfileChar6Config ); + // Allocate Client Characteristic Configuration table + simpleProfileChar6Config = (gattCharCfg_t *)ICall_malloc( sizeof(gattCharCfg_t) * + linkDBNumConns ); + if ( simpleProfileChar6Config == NULL ) + { + return ( bleMemAllocError ); + } + + // Initialize Client Characteristic Configuration attributes + GATTServApp_InitCharCfg( INVALID_CONNHANDLE, simpleProfileChar6Config ); #endif - if ( services & SIMPLEPROFILE_SERVICE ) - { - // Register GATT attribute list and CBs with GATT Server App - status = GATTServApp_RegisterService( simpleProfileAttrTbl, - GATT_NUM_ATTRS( simpleProfileAttrTbl ), - GATT_MAX_ENCRYPT_KEY_SIZE, - &simpleProfileCBs ); - } - else - { - status = SUCCESS; - } + if ( services & SIMPLEPROFILE_SERVICE ) + { + // Register GATT attribute list and CBs with GATT Server App + status = GATTServApp_RegisterService( simpleProfileAttrTbl, + GATT_NUM_ATTRS( simpleProfileAttrTbl ), + GATT_MAX_ENCRYPT_KEY_SIZE, + &simpleProfileCBs ); + } + else + { + status = SUCCESS; + } - return ( status ); + return ( status ); } /********************************************************************* * @fn SimpleProfile_RegisterAppCBs * - * @brief Registers the application callback function. Only call + * @brief Registers the application callback function. Only call * this function once. * * @param callbacks - pointer to application callbacks. @@ -485,16 +487,16 @@ bStatus_t SimpleProfile_AddService( uint32 services ) */ bStatus_t SimpleProfile_RegisterAppCBs( simpleProfileCBs_t *appCallbacks ) { - if ( appCallbacks ) - { - simpleProfile_AppCBs = appCallbacks; - - return ( SUCCESS ); - } - else - { - return ( bleAlreadyInRequestedMode ); - } + if ( appCallbacks ) + { + simpleProfile_AppCBs = appCallbacks; + + return ( SUCCESS ); + } + else + { + return ( bleAlreadyInRequestedMode ); + } } /********************************************************************* @@ -505,103 +507,101 @@ bStatus_t SimpleProfile_RegisterAppCBs( simpleProfileCBs_t *appCallbacks ) * @param param - Profile parameter ID * @param len - length of data to write * @param value - pointer to data to write. This is dependent on - * the parameter ID and WILL be cast to the appropriate - * data type (example: data type of uint16 will be cast to + * the parameter ID and WILL be cast to the appropriate + * data type (example: data type of uint16 will be cast to * uint16 pointer). * * @return bStatus_t */ bStatus_t SimpleProfile_SetParameter( uint8 param, uint8 len, void *value ) { - bStatus_t ret = SUCCESS; - switch ( param ) - { - case SIMPLEPROFILE_CHAR1: - if ( len == sizeof ( uint8 ) ) - { - simpleProfileChar1 = *((uint8*)value); - } - else - { - ret = bleInvalidRange; - } - break; + bStatus_t ret = SUCCESS; + switch ( param ) + { + case SIMPLEPROFILE_CHAR1: + if ( len == sizeof ( uint8 ) ) + { + simpleProfileChar1 = *((uint8*)value); + } + else + { + ret = bleInvalidRange; + } + break; - case SIMPLEPROFILE_CHAR2: - if ( len == sizeof ( uint8 ) ) - { - simpleProfileChar2 = *((uint8*)value); - } - else - { - ret = bleInvalidRange; - } - break; + case SIMPLEPROFILE_CHAR2: + if ( len == sizeof ( uint8 ) ) + { + simpleProfileChar2 = *((uint8*)value); + } + else + { + ret = bleInvalidRange; + } + break; - case SIMPLEPROFILE_CHAR3: - if ( len == sizeof ( uint8 ) ) - { - simpleProfileChar3 = *((uint8*)value); - } - else - { - ret = bleInvalidRange; - } - break; + case SIMPLEPROFILE_CHAR3: + if ( len == sizeof ( uint8 ) ) + { + simpleProfileChar3 = *((uint8*)value); + } + else + { + ret = bleInvalidRange; + } + break; - case SIMPLEPROFILE_CHAR4: - if ( len == sizeof ( uint8 ) ) - { - simpleProfileChar4 = *((uint8*)value); - - // See if Notification has been enabled - GATTServApp_ProcessCharCfg( simpleProfileChar4Config, &simpleProfileChar4, FALSE, - simpleProfileAttrTbl, GATT_NUM_ATTRS( simpleProfileAttrTbl ), - INVALID_TASK_ID, simpleProfile_ReadAttrCB ); - } - else - { - ret = bleInvalidRange; - } - break; + case SIMPLEPROFILE_CHAR4: + if ( len == sizeof ( uint8 ) ) + { + simpleProfileChar4 = *((uint8*)value); - case SIMPLEPROFILE_CHAR5: - if ( len == SIMPLEPROFILE_CHAR5_LEN ) - { - memcpy( simpleProfileChar5, value, SIMPLEPROFILE_CHAR5_LEN ); - } - else - { - ret = bleInvalidRange; - } - break; - - case SIMPLEPROFILE_CHAR6: - //LCD_WRITE_STRING_VALUE( "SetParameter 6 len=", len, 10, HAL_LCD_LINE_1 ); - //if ( len == SIMPLEPROFILE_CHAR6_LEN ) - if ( len <= SIMPLEPROFILE_CHAR6_LEN ) - { - memcpy( simpleProfileChar6, value, len ); - simpleProfileChar6Len = len; - // See if Notification has been enabled + // See if Notification has been enabled + GATTServApp_ProcessCharCfg( simpleProfileChar4Config, &simpleProfileChar4, FALSE, + simpleProfileAttrTbl, GATT_NUM_ATTRS( simpleProfileAttrTbl ), + INVALID_TASK_ID, simpleProfile_ReadAttrCB ); + } + else + { + ret = bleInvalidRange; + } + break; - // See if Notification has been enabled - GATTServApp_ProcessCharCfg( simpleProfileChar6Config, simpleProfileChar6, FALSE, - simpleProfileAttrTbl, GATT_NUM_ATTRS( simpleProfileAttrTbl ), - INVALID_TASK_ID, simpleProfile_ReadAttrCB ); - } - else - { - ret = bleInvalidRange; - } - break; - - default: - ret = INVALIDPARAMETER; - break; - } - - return ( ret ); + case SIMPLEPROFILE_CHAR5: + if ( len == SIMPLEPROFILE_CHAR5_LEN ) + { + memcpy( simpleProfileChar5, value, SIMPLEPROFILE_CHAR5_LEN ); + } + else + { + ret = bleInvalidRange; + } + break; + + case SIMPLEPROFILE_CHAR6: + if ( len <= SIMPLEPROFILE_CHAR6_LEN ) + { + memcpy( simpleProfileChar6, value, len ); + simpleProfileChar6Len = len; + // See if Notification has been enabled + + // See if Notification has been enabled + GATTServApp_ProcessCharCfg( simpleProfileChar6Config, simpleProfileChar6, FALSE, + simpleProfileAttrTbl, GATT_NUM_ATTRS( simpleProfileAttrTbl ), + INVALID_TASK_ID, simpleProfile_ReadAttrCB ); + } + else + { + ret = bleInvalidRange; + } + break; + + default: + ret = INVALIDPARAMETER; + break; + } + + return ( ret ); } /********************************************************************* @@ -611,56 +611,56 @@ bStatus_t SimpleProfile_SetParameter( uint8 param, uint8 len, void *value ) * * @param param - Profile parameter ID * @param value - pointer to data to put. This is dependent on - * the parameter ID and WILL be cast to the appropriate - * data type (example: data type of uint16 will be cast to + * the parameter ID and WILL be cast to the appropriate + * data type (example: data type of uint16 will be cast to * uint16 pointer). * * @return bStatus_t */ bStatus_t SimpleProfile_GetParameter( uint8 param, void *value, uint8 *returnBytes) { - bStatus_t ret = SUCCESS; - switch ( param ) - { - case SIMPLEPROFILE_CHAR1: - *((uint8*)value) = simpleProfileChar1; - *returnBytes = 1; - break; + bStatus_t ret = SUCCESS; + switch ( param ) + { + case SIMPLEPROFILE_CHAR1: + *((uint8*)value) = simpleProfileChar1; + *returnBytes = 1; + break; - case SIMPLEPROFILE_CHAR2: - *((uint8*)value) = simpleProfileChar2; - *returnBytes = 1; - break; + case SIMPLEPROFILE_CHAR2: + *((uint8*)value) = simpleProfileChar2; + *returnBytes = 1; + break; - case SIMPLEPROFILE_CHAR3: - *((uint8*)value) = simpleProfileChar3; - *returnBytes = 1; - break; + case SIMPLEPROFILE_CHAR3: + *((uint8*)value) = simpleProfileChar3; + *returnBytes = 1; + break; - case SIMPLEPROFILE_CHAR4: - *((uint8*)value) = simpleProfileChar4; - *returnBytes = 1; - break; + case SIMPLEPROFILE_CHAR4: + *((uint8*)value) = simpleProfileChar4; + *returnBytes = 1; + break; - case SIMPLEPROFILE_CHAR5: - memcpy( value, simpleProfileChar5, SIMPLEPROFILE_CHAR5_LEN ); - *returnBytes = 1; - break; - - case SIMPLEPROFILE_CHAR6: - memcpy( value, simpleProfileChar6, simpleProfileChar6Len ); - *returnBytes = simpleProfileChar6Len; - //*returnBytes = 1; - break; - - - default: - ret = INVALIDPARAMETER; - *returnBytes = 0; - break; - } - - return ( ret ); + case SIMPLEPROFILE_CHAR5: + memcpy( value, simpleProfileChar5, SIMPLEPROFILE_CHAR5_LEN ); + *returnBytes = 1; + break; + + case SIMPLEPROFILE_CHAR6: + memcpy( value, simpleProfileChar6, simpleProfileChar6Len ); + *returnBytes = simpleProfileChar6Len; + //*returnBytes = 1; + break; + + + default: + ret = INVALIDPARAMETER; + *returnBytes = 0; + break; + } + + return ( ret ); } /********************************************************************* @@ -679,80 +679,75 @@ bStatus_t SimpleProfile_GetParameter( uint8 param, void *value, uint8 *returnByt * @return SUCCESS, blePending or Failure */ static bStatus_t simpleProfile_ReadAttrCB(uint16_t connHandle, - gattAttribute_t *pAttr, - uint8_t *pValue, uint16_t *pLen, - uint16_t offset, uint16_t maxLen, - uint8_t method) + gattAttribute_t *pAttr, + uint8_t *pValue, uint16_t *pLen, + uint16_t offset, uint16_t maxLen, + uint8_t method) { - bStatus_t status = SUCCESS; + bStatus_t status = SUCCESS; - // If attribute permissions require authorization to read, return error - if ( gattPermitAuthorRead( pAttr->permissions ) ) - { - // Insufficient authorization - return ( ATT_ERR_INSUFFICIENT_AUTHOR ); - } - - // Make sure it's not a blob operation (no attributes in the profile are long) - if ( offset > 0 ) - { - return ( ATT_ERR_ATTR_NOT_LONG ); - } - - if ( pAttr->type.len == ATT_BT_UUID_SIZE ) - { - // 16-bit UUID - uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]); - switch ( uuid ) + // If attribute permissions require authorization to read, return error + if ( gattPermitAuthorRead( pAttr->permissions ) ) { - // No need for "GATT_SERVICE_UUID" or "GATT_CLIENT_CHAR_CFG_UUID" cases; - // gattserverapp handles those reads - - // characteristics 1 and 2 have read permissions - // characteritisc 3 does not have read permissions; therefore it is not - // included here - // characteristic 4 does not have read permissions, but because it - // can be sent as a notification, it is included here - case SIMPLEPROFILE_CHAR1_UUID: - case SIMPLEPROFILE_CHAR2_UUID: - case SIMPLEPROFILE_CHAR4_UUID: - *pLen = 1; - pValue[0] = *pAttr->pValue; - break; - - case SIMPLEPROFILE_CHAR5_UUID: - *pLen = SIMPLEPROFILE_CHAR5_LEN; - memcpy( pValue, pAttr->pValue, SIMPLEPROFILE_CHAR5_LEN ); - break; - - case SIMPLEPROFILE_CHAR6_UUID: - //*Len = SIMPLEPROFILE_CHAR6_LEN; - //VOID osal_memcpy( pValue, pAttr->pValue, SIMPLEPROFILE_CHAR6_LEN ); - //LCD_WRITE_STRING_VALUE( "ReadAttrCB 6 len=", simpleProfileChar6Len, 10, HAL_LCD_LINE_1 ); - *pLen = simpleProfileChar6Len; - memcpy( pValue, pAttr->pValue, simpleProfileChar6Len ); - { - // Õâ¸ö±äÁ¿ÓÃÓÚ±íÃ÷ÉÏÒ»´ÎдÊý¾Ýµ½´Ó»úÒѾ­³É¹¦£¬ ¿ÉÓÃÓÚÅжÏдÊý¾ÝʱµÄÅжϣ¬ ÒÔÈ·±£Êý¾ÝµÄÍêÕûÐÔ -// extern bool simpleBLEChar6DoWrite2; -// simpleBLEChar6DoWrite2 = TRUE; - } - break; - - default: - // Should never get here! (characteristics 3 and 4 do not have read permissions) - *pLen = 0; - status = ATT_ERR_ATTR_NOT_FOUND; - break; + // Insufficient authorization + return ( ATT_ERR_INSUFFICIENT_AUTHOR ); } - } - else - { - // 128-bit UUID - *pLen = 0; - status = ATT_ERR_INVALID_HANDLE; - } - return ( status ); + // Make sure it's not a blob operation (no attributes in the profile are long) + if ( offset > 0 ) + { + return ( ATT_ERR_ATTR_NOT_LONG ); + } + + if ( pAttr->type.len == ATT_BT_UUID_SIZE ) + { + // 16-bit UUID + uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]); + switch ( uuid ) + { + // No need for "GATT_SERVICE_UUID" or "GATT_CLIENT_CHAR_CFG_UUID" cases; + // gattserverapp handles those reads + + // characteristics 1 and 2 have read permissions + // characteritisc 3 does not have read permissions; therefore it is not + // included here + // characteristic 4 does not have read permissions, but because it + // can be sent as a notification, it is included here + case SIMPLEPROFILE_CHAR1_UUID: + case SIMPLEPROFILE_CHAR2_UUID: + case SIMPLEPROFILE_CHAR4_UUID: + *pLen = 1; + pValue[0] = *pAttr->pValue; + break; + + case SIMPLEPROFILE_CHAR5_UUID: + *pLen = SIMPLEPROFILE_CHAR5_LEN; + memcpy( pValue, pAttr->pValue, SIMPLEPROFILE_CHAR5_LEN ); + break; + + case SIMPLEPROFILE_CHAR6_UUID: + *pLen = simpleProfileChar6Len; + memcpy( pValue, pAttr->pValue, simpleProfileChar6Len ); + { + // Characteristic 6 is likely a customized characteristic + } + break; + + default: + // Should never get here! (characteristics 3 and 4 do not have read permissions) + *pLen = 0; + status = ATT_ERR_ATTR_NOT_FOUND; + break; + } + } + else + { + // 128-bit UUID + *pLen = 0; + status = ATT_ERR_INVALID_HANDLE; + } + + return ( status ); } /********************************************************************* @@ -768,116 +763,113 @@ static bStatus_t simpleProfile_ReadAttrCB(uint16_t connHandle, * @param method - type of write message * * @return SUCCESS, blePending or Failure - */ // ÊÕµ½Ö÷»ú·¢Ë͹ýÀ´µÄÊý¾Ý + */ static bStatus_t simpleProfile_WriteAttrCB(uint16_t connHandle, - gattAttribute_t *pAttr, - uint8_t *pValue, uint16_t len, - uint16_t offset, uint8_t method) + gattAttribute_t *pAttr, + uint8_t *pValue, uint16_t len, + uint16_t offset, uint8_t method) { - bStatus_t status = SUCCESS; - uint8 notifyApp = 0xFF; - - // If attribute permissions require authorization to write, return error - if ( gattPermitAuthorWrite( pAttr->permissions ) ) - { - // Insufficient authorization - return ( ATT_ERR_INSUFFICIENT_AUTHOR ); - } - - if ( pAttr->type.len == ATT_BT_UUID_SIZE ) - { - // 16-bit UUID - uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]); - switch ( uuid ) + bStatus_t status = SUCCESS; + uint8 notifyApp = 0xFF; + + // If attribute permissions require authorization to write, return error + if ( gattPermitAuthorWrite( pAttr->permissions ) ) { - case SIMPLEPROFILE_CHAR1_UUID: - case SIMPLEPROFILE_CHAR3_UUID: - - //Validate the value - // Make sure it's not a blob oper - if ( offset == 0 ) - { - if ( len != 1 ) - { - status = ATT_ERR_INVALID_VALUE_SIZE; - } - } - else - { - status = ATT_ERR_ATTR_NOT_LONG; - } - - //Write the value - if ( status == SUCCESS ) - { - uint8 *pCurValue = (uint8 *)pAttr->pValue; - *pCurValue = pValue[0]; - - if( pAttr->pValue == &simpleProfileChar1 ) - { - notifyApp = SIMPLEPROFILE_CHAR1; - } - else - { - notifyApp = SIMPLEPROFILE_CHAR3; - } - } - - break; - - case SIMPLEPROFILE_CHAR6_UUID: - //Validate the value - // Make sure it's not a blob oper - //LCD_WRITE_STRING_VALUE( "WriteAttrCB 6 len=", len, 10, HAL_LCD_LINE_1 ); - //LCD_WRITE_STRING_VALUE( "WriteAttrCB 6 len2=", simpleProfileChar6Len, 10, HAL_LCD_LINE_1 ); - if ( offset == 0 ) - { - //if ( len != SIMPLEPROFILE_CHAR6_LEN ) - if ( len > SIMPLEPROFILE_CHAR6_LEN ) - { - status = ATT_ERR_INVALID_VALUE_SIZE; - } - } - else - { - status = ATT_ERR_ATTR_NOT_LONG; - } - - //Write the value - if ( status == SUCCESS ) - { - //VOID osal_memcpy( pAttr->pValue, pValue, SIMPLEPROFILE_CHAR6_LEN ); - memcpy( pAttr->pValue, pValue, len ); - simpleProfileChar6Len = len; - notifyApp = SIMPLEPROFILE_CHAR6; - } - - break; - - case GATT_CLIENT_CHAR_CFG_UUID: - status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len, - offset, GATT_CLIENT_CFG_NOTIFY ); - break; - - default: - // Should never get here! (characteristics 2 and 4 do not have write permissions) - status = ATT_ERR_ATTR_NOT_FOUND; - break; + // Insufficient authorization + return ( ATT_ERR_INSUFFICIENT_AUTHOR ); } - } - else - { - // 128-bit UUID - status = ATT_ERR_INVALID_HANDLE; - } - // If a characteristic value changed then callback function to notify application of change - if ( (notifyApp != 0xFF ) && simpleProfile_AppCBs && simpleProfile_AppCBs->pfnSimpleProfileChange ) - { - simpleProfile_AppCBs->pfnSimpleProfileChange( notifyApp ); - } - - return ( status ); + if ( pAttr->type.len == ATT_BT_UUID_SIZE ) + { + // 16-bit UUID + uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]); + switch ( uuid ) + { + case SIMPLEPROFILE_CHAR1_UUID: + case SIMPLEPROFILE_CHAR3_UUID: + + //Validate the value + // Make sure it's not a blob oper + if ( offset == 0 ) + { + if ( len != 1 ) + { + status = ATT_ERR_INVALID_VALUE_SIZE; + } + } + else + { + status = ATT_ERR_ATTR_NOT_LONG; + } + + //Write the value + if ( status == SUCCESS ) + { + uint8 *pCurValue = (uint8 *)pAttr->pValue; + *pCurValue = pValue[0]; + + if( pAttr->pValue == &simpleProfileChar1 ) + { + notifyApp = SIMPLEPROFILE_CHAR1; + } + else + { + notifyApp = SIMPLEPROFILE_CHAR3; + } + } + + break; + + case SIMPLEPROFILE_CHAR6_UUID: + // Validate the value + // Make sure it's not a blob oper + if ( offset == 0 ) + { + //if ( len != SIMPLEPROFILE_CHAR6_LEN ) + if ( len > SIMPLEPROFILE_CHAR6_LEN ) + { + status = ATT_ERR_INVALID_VALUE_SIZE; + } + } + else + { + status = ATT_ERR_ATTR_NOT_LONG; + } + + // Write the value + if ( status == SUCCESS ) + { + memcpy( pAttr->pValue, pValue, len ); + simpleProfileChar6Len = len; + notifyApp = SIMPLEPROFILE_CHAR6; + } + + break; + + case GATT_CLIENT_CHAR_CFG_UUID: + status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len, + offset, GATT_CLIENT_CFG_NOTIFY ); + break; + + default: + // Should never get here! (characteristics 2 and 4 do not have write permissions) + status = ATT_ERR_ATTR_NOT_FOUND; + break; + } + } + else + { + // 128-bit UUID + status = ATT_ERR_INVALID_HANDLE; + } + + // If a characteristic value changed then callback function to notify application of change + if ( (notifyApp != 0xFF ) && simpleProfile_AppCBs && simpleProfile_AppCBs->pfnSimpleProfileChange ) + { + simpleProfile_AppCBs->pfnSimpleProfileChange( notifyApp ); + } + + return ( status ); } /********************************************************************* diff --git a/src/example/decode_example/CC26xx/Source/Application/buffer.h b/src/example/decode_example/CC26xx/Source/Application/buffer.h index eaa763b..b2f9402 100644 --- a/src/example/decode_example/CC26xx/Source/Application/buffer.h +++ b/src/example/decode_example/CC26xx/Source/Application/buffer.h @@ -18,7 +18,7 @@ extern "C" { #endif -#define SEND_BUF_MAX_SIZE 320 +#define SEND_BUF_MAX_SIZE 256 extern bool queue_write(uint8 *WrBuf, unsigned short WrLen); diff --git a/src/example/decode_example/CC26xx/Source/Application/simpleBLEPeripheral.c b/src/example/decode_example/CC26xx/Source/Application/simpleBLEPeripheral.c index 17aaac8..71946fe 100644 --- a/src/example/decode_example/CC26xx/Source/Application/simpleBLEPeripheral.c +++ b/src/example/decode_example/CC26xx/Source/Application/simpleBLEPeripheral.c @@ -135,17 +135,11 @@ static transfer_control_block btcb = static decode_control_block dccb = { .ir_type = IR_TYPE_NONE, - .ir_state = IR_STATE_NONE, + .ir_state = IR_STATE_STANDBY, .source_code_length = 0, .decoded_length = 0, }; -/* source code holder */ -static uint8_t binary_source[BINARY_SOURCE_SIZE_MAX] = -{ - 0x00, -}; - // local function prototypes static void IRext_uartDebug(); @@ -160,31 +154,50 @@ static void ParseCommand(uint8_t* data, uint16_t len); // IR operation static void IRext_processState() { - if (IR_STATE_NONE == dccb.ir_state) + if (IR_STATE_STANDBY == dccb.ir_state) { - if (IR_DECODE_SUCCEEDED == ir_tv_lib_open(dccb.source_code, dccb.source_code_length)) + dccb.ir_state = IR_STATE_NONE; + LCD_WRITE_STRING("IR READY", LCD_PAGE7); + } + else if (IR_STATE_READY == dccb.ir_state) + { + if (dccb.ir_type == IR_TYPE_TV) { - LCD_WRITE_STRING("IR OPENED", LCD_PAGE7); - HalLedSet(HAL_LED_1, HAL_LED_MODE_ON); - dccb.ir_state = IR_STATE_OPENED; + if (IR_DECODE_SUCCEEDED == ir_tv_lib_open(dccb.source_code, dccb.source_code_length)) + { + LCD_WRITE_STRING("IR OPENED", LCD_PAGE7); + HalLedSet(HAL_LED_1, HAL_LED_MODE_ON); + dccb.ir_state = IR_STATE_OPENED; + } + else + { + LCD_WRITE_STRING("OPEN ERROR", LCD_PAGE7); + } } } else if (IR_STATE_OPENED == dccb.ir_state) { - if (IR_DECODE_SUCCEEDED == ir_tv_lib_parse(0)) + if (dccb.ir_type == IR_TYPE_TV) { - LCD_WRITE_STRING("IR PARSED", LCD_PAGE7); - HalLedSet(HAL_LED_2, HAL_LED_MODE_ON); - dccb.ir_state = IR_STATE_PARSED; + if (IR_DECODE_SUCCEEDED == ir_tv_lib_parse(0)) + { + LCD_WRITE_STRING("IR PARSED", LCD_PAGE7); + HalLedSet(HAL_LED_2, HAL_LED_MODE_ON); + dccb.ir_state = IR_STATE_PARSED; + } + else + { + LCD_WRITE_STRING("PARSE ERROR", LCD_PAGE7); + } } } else if (IR_STATE_PARSED == dccb.ir_state) { if (IR_DECODE_SUCCEEDED == ir_tv_lib_close()) { - LCD_WRITE_STRING("IR NONE", LCD_PAGE7); + LCD_WRITE_STRING("IR READY", LCD_PAGE7); HalLedSet(HAL_LED_1 | HAL_LED_2, HAL_LED_MODE_OFF); - dccb.ir_state = IR_STATE_NONE; + dccb.ir_state = IR_STATE_READY; } } } @@ -214,10 +227,9 @@ static void IRext_processKey(uint8_t ir_type, uint8_t ir_key, char* key_display) // UART operation static void IRext_uartDebug() { -#if defined UART_DEBUG uint16_t index = 0; - if (user_data_length > 0) + if (dccb.source_code_length > 0) { // output to UART char debug[16] = { 0 }; @@ -230,7 +242,6 @@ static void IRext_uartDebug() } UART_WriteTransport((uint8_t*)"\n", 1); } -#endif } static void IRext_processUartMsg(uint8_t* data, uint16_t len) @@ -256,15 +267,16 @@ static void IRext_processUartMsg(uint8_t* data, uint16_t len) if (HEADER_SR == header) { + // since there is 1 more byte for eos ParseSummary(&data[1], len - 2); } else if (HEADER_BT == header) { - ParseBinary(&data[1], len - 2); + ParseBinary(&data[1], len - 1); } else if (HEADER_CMD == header) { - ParseCommand(&data[1], len - 2); + ParseCommand(&data[1], len - 1); } else { @@ -286,6 +298,8 @@ static void ParseSummary(uint8_t* data, uint16_t len) // 4 bytes length in ASCII format value = n memcpy(cat_char, &data[0], CATEGORY_LENGTH_SIZE); dccb.ir_type = (ir_type_t)atoi(cat_char); + dccb.source_code_length = 0; + memset(dccb.source_code, 0x00, BINARY_SOURCE_SIZE_MAX); memcpy(len_char, &data[1], BINARY_LENGTH_SIZE); btcb.binary_recv_expected_length = atoi(len_char); @@ -304,7 +318,7 @@ static void ParseSummary(uint8_t* data, uint16_t len) static void ParseBinary(uint8_t* data, uint16_t len) { // n bytes payload fragment - memcpy(&binary_source[btcb.binary_recv_length], + memcpy(&dccb.source_code[btcb.binary_recv_length], data, len); btcb.binary_recv_length += len; @@ -312,6 +326,7 @@ static void ParseBinary(uint8_t* data, uint16_t len) { // finish binary transfer dccb.source_code_length = btcb.binary_recv_length; + dccb.ir_state = IR_STATE_READY; btcb.transfer_on_going = 0; } // feed back next expected offset in any cases @@ -323,6 +338,12 @@ static void ParseCommand(uint8_t* data, uint16_t len) // TODO: } +void TransportDataToUart(uint8_t* data, uint16_t len) +{ + UART_WriteTransport(data, len); +} + + /* IREXT - end */ @@ -736,7 +757,7 @@ static void SimpleBLEPeripheral_init(void) #endif // HAL_IMAGE_A #else LCD_WRITE_STRING("IRext sample", LCD_PAGE0); - LCD_WRITE_STRING("IR NONE", LCD_PAGE7); + LCD_WRITE_STRING("STANDBY", LCD_PAGE7); HalLedSet(HAL_LED_1, HAL_LED_MODE_OFF); #endif } @@ -1119,7 +1140,14 @@ static void SimpleBLEPeripheral_processAppMsg(sbpEvt_t *pMsg) uint8 len = queue_read(valueToCopy, UART_BUFFER_SIZE); if(len > 0) { - IRext_processUartMsg(valueToCopy, len); + if (IR_STATE_STANDBY == dccb.ir_state) + { + SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR6, len, valueToCopy); + } + else + { + IRext_processUartMsg(valueToCopy, len); + } } if(queue_total() > 0) { diff --git a/src/example/decode_example/CC26xx/Source/Application/simpleBLEPeripheral.h b/src/example/decode_example/CC26xx/Source/Application/simpleBLEPeripheral.h index b64e36d..7b8c097 100644 --- a/src/example/decode_example/CC26xx/Source/Application/simpleBLEPeripheral.h +++ b/src/example/decode_example/CC26xx/Source/Application/simpleBLEPeripheral.h @@ -64,7 +64,9 @@ typedef enum typedef enum { - IR_STATE_NONE = 0, + IR_STATE_STANDBY = 0, + IR_STATE_NONE, + IR_STATE_READY, IR_STATE_OPENED, IR_STATE_PARSED, IR_STATE_MAX @@ -94,6 +96,8 @@ typedef struct * FUNCTIONS */ +extern void TransportDataToUart(uint8_t* data, uint16_t len); + /* * Task creation function for the Simple BLE Peripheral. */