// 串口回调函数 static void simpleBLE_NpiSerialCallback( uint8 port, uint8 events ) { (void)port; if (events & (HAL_UART_RX_TIMEOUT | HAL_UART_RX_FULL)) //串口有数据 { uint8 numBytes = 0; numBytes = NPI_RxBufLen(); //读出串口缓冲区有多少字节 if(numBytes > 0) { uint8 *buffer = osal_mem_alloc(numBytes); if(buffer) { // 读出串口数据 NPI_ReadTransport(buffer,numBytes); #if 1 // 作为测试, 把读到的数据也通过串口返回, 这只是一个test功能, 你可以把去掉 NPI_WriteTransport(buffer,numBytes); #endif osal_mem_free(buffer); } } } }
/* 1, 思路: 当串口收到数据后,就会马上调用以下回调函数,在实际测试中发现,此回调 函数调用频繁, 如果你不执行NPI_ReadTransport函数进行读取, 那么这个回调函数就会 频繁地被执行,但是,你通过串口发送一段数据, 你本意是想处理这一完整一段的数据,所以, 我们在下面引入了时间的处理方法, 也即接收的数据够多或者超时,就读取一次数据, 然后根据当前的状态决定执行,如果没有连接上,就把所有数据当做AT命令处理, 如果连接 上了,就把数据送到对端。 ---------------amomcu 2014.08.17 */ void NpiSerialCallback( uint8 port, uint8 events ) { (void)port;//加个 (void),是未了避免编译告警,明确告诉缓冲区不用理会这个变量 if (events & (HAL_UART_RX_TIMEOUT | HAL_UART_RX_FULL)) //串口有数据 { uint8 numBytes = 0; numBytes = NPI_RxBufLen(); //读出串口缓冲区有多少字节 if(numBytes == 0) { return; } else { //申请缓冲区buffer uint8 *buffer = osal_mem_alloc(numBytes); if(buffer) { //读取读取串口缓冲区数据,释放串口数据 NPI_ReadTransport(buffer,numBytes); //把收到的数据发送到串口-实现回环 NPI_WriteTransport(buffer, numBytes); //释放申请的缓冲区 osal_mem_free(buffer); } } } }
void xbee_api_atcmd_set_led(uint8 led,uint8 state) { pst_api_frame_head head = (pst_api_frame_head)xbee_wbuf; pst_api_atCmd atCmd; head->start_delimiter = 0x7e; head->len_msb = 0x00; head->len_lsb = 0x05; atCmd = (pst_api_atCmd)&head->fram_data; atCmd->frame_type = 0x08; atCmd->frame_id = 0x52; switch(led) { case XBEE_LED1: atCmd->atCmd[0] = 'P'; atCmd->atCmd[1] = '1'; break; case XBEE_LED2: atCmd->atCmd[0] = 'D'; atCmd->atCmd[1] = '4'; break; case XBEE_LED3: atCmd->atCmd[0] = 'D'; atCmd->atCmd[1] = '5'; break; case XBEE_LED4: atCmd->atCmd[0] = 'D'; atCmd->atCmd[1] = '3'; break; } atCmd->atPara = (state == LED_ON)?4:5; xbee_api_checksum((uint8*)atCmd,5); NPI_WriteTransport(xbee_wbuf, 9); }
static void performPeriodicTask( void ) { //static bool a = true; //a = !a; //HalLedSet(HAL_LED_1,a); #if 0 char strTemp[35] = {0}; sprintf(strTemp, "led1 = %d\r\n",a); NPI_WriteTransport((uint8*)strTemp, osal_strlen(strTemp)); #endif if ( simpleBLEState == BLE_STATE_CONNECTED && simpleBLEProcedureInProgress == FALSE ) { uint8 status; attReadReq_t req; req.handle = simpleBLECharHdl; status = GATT_ReadCharValue( simpleBLEConnHandle, &req, simpleBLETaskId ); #if 0 sprintf(strTemp, "read status = %d\r\n",status); NPI_WriteTransport((uint8*)strTemp, osal_strlen(strTemp)); #endif } #if 0 uint8 valueToCopy; uint8 stat; // Call to retrieve the value of the third characteristic in the profile stat = SimpleProfile_GetParameter( SIMPLEPROFILE_CHAR3, &valueToCopy); if( stat == SUCCESS ) { /* * Call to set that value of the fourth characteristic in the profile. Note * that if notifications of the fourth characteristic have been enabled by * a GATT client device, then a notification will be sent every time this * function is called. */ SimpleProfile_SetParameter( SIMPLEPROFILE_CHAR4, sizeof(uint8), &valueToCopy); } #endif }
void xbee_api_transmit_data_request(uint8 *dest_addr,uint8 *data,uint16 len) { xbee_wbuf[0] = 0x7e; xbee_wbuf[1] = (uint8)((len + 1) >> 8); xbee_wbuf[2] = (uint8)(len + 1); xbee_wbuf[3] = 0x10; osal_memcpy(&xbee_wbuf[4],data,len); xbee_api_checksum(&xbee_wbuf[3],len + 1); NPI_WriteTransport(xbee_wbuf, len + 1 + 4); }
void xbee_api_atcmd_speaker_opt(uint8 state) { pst_api_frame_head head = (pst_api_frame_head)xbee_wbuf; pst_api_atCmd atCmd; head->start_delimiter = 0x7e; head->len_msb = 0x00; head->len_lsb = 0x05; atCmd = (pst_api_atCmd)&head->fram_data; atCmd->frame_type = 0x08; atCmd->frame_id = 0x52; atCmd->atCmd[0] = 'P'; atCmd->atCmd[1] = '2'; atCmd->atPara = (state == SPEAKER_ON)?5:4; xbee_api_checksum((uint8*)atCmd,5); NPI_WriteTransport(xbee_wbuf, 9); }
/*************************************************************************************************** * @fn Uart_Msg_Send_Action * * @brief pack uart Msg,this msg was came to e009 uart * * @param pBuffer: msg; length: msg length * * @return None ***************************************************************************************************/ bool Uart_Msg_Send_Action(UART_MSG msg) { NPI_WriteTransport(msg.msg_buffer, msg.msg_len); if(msg.need_rsp) { osal_memcpy(last_uart_send.msg_buffer, msg.msg_buffer, msg.msg_len); last_uart_send.msg_len = msg.msg_len; last_uart_send.need_rsp = msg.need_rsp; //start a timer to check respond waiting_rsp = true; osal_start_timerEx( simpleBLETaskId, SBP_UART_RSP, TIME_SECOND(1) ); } return true; }
/*************************************************************************************************** * @fn Uart_Msg_Retransform * * @brief handle uart1 Msg,this msg was came from e009 uart1 * * @param pBuffer: msg; length: msg length * * @return None ***************************************************************************************************/ uint8 Uart_Msg_Calculate_Checkcode(uint8 *pBuffer, uint8 length ) { uint8 i; uint8 checkCode, checkCodeLocation; checkCode = pBuffer[1]; checkCodeLocation = length - 2; for( i = 2; i < checkCodeLocation; i++ ) { checkCode = checkCode ^ pBuffer[i]; } #if 0 char strTemp[50] = {0}; sprintf(strTemp, "checkCode=0x%x,%d\r\n",checkCode,checkCodeLocation); NPI_WriteTransport((uint8*)strTemp, osal_strlen(strTemp)); #endif return checkCode; }
uint8 char2int(char *a) { uint8 high,low,tmp; if (a[0]>='0' && a[0]<='9') high=a[0]-'0'; else if(a[0]>='a' && a[0]<='f') high=a[0]-'a'+10; else if(a[0]>='A' && a[0]<='F') high=a[0]-'A'+10; else return -1; if (a[1]>='0' && a[1]<='9') low=a[1]-'0'; else if(a[1]>='a' && a[1]<='f') low=a[1]-'a'+10; else if(a[1]>='A' && a[1]<='F') low=a[1]-'A'+10; else return -1; tmp = high*16+low; #if 0 char strTemp[35] = {0}; sprintf(strTemp, "tmp=0x%x\r\n",tmp); NPI_WriteTransport((uint8*)strTemp, osal_strlen(strTemp)); halSleep(20); #endif return tmp; }
bool string2int(uint8 *pBuffer, uint16 length) { int i; int j = 0; for (i=0; i < length; ) { gBuffer_Receive[j] = char2int(pBuffer+i); #if 0 char strTemp[35] = {0}; sprintf(strTemp, "gUint8Buffer[%d]=0x%x\r\n",j,gBuffer_Receive[j]); NPI_WriteTransport((uint8*)strTemp, osal_strlen(strTemp)); halSleep(50); #endif j++; i=i+2; } gNumBytes_Receive = j; return true; }
// 串口回调函数 static void simpleBLE_NpiSerialCallback( uint8 port, uint8 events ) { (void)port; if (events & (HAL_UART_RX_TIMEOUT | HAL_UART_RX_FULL)) //串口有数据 { uint8 numBytes = 0; numBytes = NPI_RxBufLen(); //读出串口缓冲区有多少字节 if(numBytes > 0) { uint8 *buffer = osal_mem_alloc(numBytes); if(buffer) { NPI_ReadTransport(buffer,numBytes); NPI_WriteTransport(buffer,numBytes); osal_mem_free(buffer); } } } }
/************************************************************************************************** z-stack代码,未修改 **************************************************************************************************/ void HalLcdWriteString ( char *str, uint8 option) { #ifdef LCD_TO_UART NPI_WriteTransport ( (uint8*)str,osal_strlen(str)); NPI_WriteTransport ("\r\n",2); #endif #if (HAL_LCD == TRUE) uint8 strLen = 0; uint8 totalLen = 0; uint8 *buf; uint8 tmpLen; if ( Lcd_Line1 == NULL ) { Lcd_Line1 = osal_mem_alloc( HAL_LCD_MAX_CHARS+1 ); HalLcdWriteString( "TexasInstruments", 1 ); } strLen = (uint8)osal_strlen( (char*)str ); /* Check boundries */ if ( strLen > HAL_LCD_MAX_CHARS ) strLen = HAL_LCD_MAX_CHARS; if ( option == HAL_LCD_LINE_1 ) { /* Line 1 gets saved for later */ osal_memcpy( Lcd_Line1, str, strLen ); Lcd_Line1[strLen] = '\0'; } else { /* Line 2 triggers action */ tmpLen = (uint8)osal_strlen( (char*)Lcd_Line1 ); totalLen = tmpLen + 1 + strLen + 1; buf = osal_mem_alloc( totalLen ); if ( buf != NULL ) { /* Concatenate strings */ osal_memcpy( buf, Lcd_Line1, tmpLen ); buf[tmpLen++] = ' '; osal_memcpy( &buf[tmpLen], str, strLen ); buf[tmpLen+strLen] = '\0'; /* Send it out */ #if defined (ZTOOL_P1) || defined (ZTOOL_P2) #if defined(SERIAL_DEBUG_SUPPORTED) debug_str( (uint8*)buf ); #endif //LCD_SUPPORTED #endif //ZTOOL_P1 /* Free mem */ osal_mem_free( buf ); } } /* Display the string */ HalLcd_HW_WriteLine (option, str); #endif //HAL_LCD }
/* 打印一个字符串 str不可以包含0x00,除非结尾 */ void NPI_PrintString(uint8 *str) { NPI_WriteTransport(str, osal_strlen((char*)str)); }
/*************************************************************************************************** * @fn Uart_Msg_Retransform * * @brief Retransform Msg,this msg was came from e009 uart1 * * @param pBuffer: msg; length: msg length * * @return None ***************************************************************************************************/ bool Uart_Msg_Retransform(uint8 *pBuffer, uint8 length ) { // sprintf(strTemp, "Uart_Msg_Retransform\r\n"); // NPI_WriteTransport((uint8*)strTemp, osal_strlen(strTemp)); // string2int(pBuffer,length); //halSleep(1000); //sprintf(strTemp, "gUint8NumBytes=%d\r\n",gUint8NumBytes); //NPI_WriteTransport((uint8*)strTemp, osal_strlen(strTemp)); //halSleep(1000); #if 0 { int i = 0; int j = 5; for(i = 0; i < gUint8NumBytes; i++) { sprintf(strTemp, "%d=0x%x\n",i,gUint8Buffer[i]); NPI_WriteTransport((uint8*)strTemp, osal_strlen(strTemp)); while(j--); }} #endif if(pBuffer[MSG_IDENTIFICATION_LOCATION] != MSG_IDENTIFICATION) { NPI_PrintValue("not a complete msg", 0); return false; } gBuffer_Receive[MSG_IDENTIFICATION_LOCATION]= pBuffer[MSG_IDENTIFICATION_LOCATION]; uint8 i; uint8 j = 1; for( i= 1; i < length; i++) { if( Uart_Byte_istransformed(pBuffer, i) ) { if( pBuffer[i+1] == 0x01 ) { gBuffer_Receive[j] = 0x56; j++; i++; } else if( pBuffer[i+1] == 0x02 ) { gBuffer_Receive[j] = 0x55; j++; i++; } } else { gBuffer_Receive[j] = pBuffer[i]; j++; } } gNumBytes_Receive = j; // sprintf(strTemp, "gNumBytes=%d\r\n",gNumBytes); // NPI_WriteTransport((uint8*)strTemp, osal_strlen(strTemp)); #if 0 { int i = 0; int j = 5; for(i = 0; i < gNumBytes_Receive; i++) { sprintf(strTemp, "%d=0x%x \n",i,gBuffer_Receive[i]); NPI_WriteTransport((uint8*)strTemp, osal_strlen(strTemp)); //while(j--); }} NPI_WriteTransport("\r\n", 2); #endif return true; }
/*************************************************************************************************** * @fn Uart_Msg_Transform * * @brief Transform msg * * @param pBuffer: msg; length: msg length * * @return true: transform ok;false:transform failed ***************************************************************************************************/ bool Uart_Msg_Transform(uint8 *pBuffer, uint8 length ) { if( pBuffer == NULL || length < 2 ) //error accured return false; if(pBuffer[MSG_IDENTIFICATION_LOCATION] != MSG_IDENTIFICATION) { NPI_PrintValue("not a complete msg", 0); return false; } uart_send.msg_buffer[MSG_IDENTIFICATION_LOCATION]= pBuffer[MSG_IDENTIFICATION_LOCATION]; uint8 i; uint8 j = 1; for( i= 1; i < length - 1; i++) { if( Uart_Byte_Needtransformed(pBuffer, i) ) { if( pBuffer[i] == 0x55 ) { uart_send.msg_buffer[j] = 0x56; j++; uart_send.msg_buffer[j] = 0x02; j++; } else if( pBuffer[i] == 0x56 ) { uart_send.msg_buffer[j] = 0x56; j++; uart_send.msg_buffer[j] = 0x01; j++; } } else { uart_send.msg_buffer[j] = pBuffer[i]; j++; } } uart_send.msg_buffer[j] = MSG_IDENTIFICATION; uart_send.msg_len = j + 1; // sprintf(strTemp, "gNumBytes=%d\r\n",gNumBytes); // NPI_WriteTransport((uint8*)strTemp, osal_strlen(strTemp)); #if 0 { char strTemp[35] = {0}; int i = 0; int j = 5; for(i = 0; i < uart_send.msg_len; i++) { sprintf(strTemp, "%d=0x%x \n",i,uart_send.msg_buffer[i]); NPI_WriteTransport((uint8*)strTemp, osal_strlen(strTemp)); //while(j--); }} #endif return true; }
/********************************************************************* * @fn simpleProfileChangeCB * * @brief Callback from SimpleBLEProfile indicating a value change * * @param paramID - parameter ID of the value that was changed. * * @return none */ static void simpleProfileChangeCB( uint8 paramID ) { uint8 newValue[20]; uint8 returnBytes; switch( paramID ) { case SIMPLEPROFILE_CHAR1: // 收到 CHAR1 的数据 SimpleProfile_GetParameter( SIMPLEPROFILE_CHAR1, &newValue, &returnBytes); #if (defined HAL_LCD) && (HAL_LCD == TRUE) HalLcdWriteStringValue( "Char 1:", (uint16)(newValue[0]), 10, HAL_LCD_LINE_5 ); #endif // (defined HAL_LCD) && (HAL_LCD == TRUE) HalLedBlink (HAL_LED_1, 1, 50, 100);//这个的意思是, 100ms内,以50%的占空比闪烁1次, 实际就是点亮50ms break; case SIMPLEPROFILE_CHAR5: // 收到 CHAR5 的数据 SimpleProfile_GetParameter( SIMPLEPROFILE_CHAR5, &newValue, &returnBytes); #if (defined HAL_LCD) && (HAL_LCD == TRUE) HalLcdWriteStringValue( "Char 5[0]:", (uint16)(newValue[0]), 16, HAL_LCD_LINE_5 ); HalLcdWriteStringValue( "Char 5[1]:", (uint16)(newValue[1]), 16, HAL_LCD_LINE_6 ); HalLcdWriteStringValue( "Char 5[2]:", (uint16)(newValue[2]), 16, HAL_LCD_LINE_7 ); HalLcdWriteStringValue( "Char 5[3]:", (uint16)(newValue[3]), 16, HAL_LCD_LINE_8 ); #endif // (defined HAL_LCD) && (HAL_LCD == TRUE) // 设定温度更新时间, 注意高位在前 if(returnBytes == 4) { sys_config.update_time_ms = (uint32)newValue[0]<<24 | (uint32)newValue[1]<<16| (uint32)newValue[2]<<8| (uint32)newValue[3]; osal_snv_write(0x80, sizeof(SYS_CONFIG), &sys_config); // 写所有参数 if(sys_config.update_time_ms > 0) { osal_start_timerEx( simpleBLEPeripheral_TaskID, SBP_READ_SENSOR_EVT, sys_config.update_time_ms); } else { osal_stop_timerEx( simpleBLEPeripheral_TaskID, SBP_READ_SENSOR_EVT); } } HalLedBlink (HAL_LED_2, 1, 50, 100);//这个的意思是, 100ms内,以50%的占空比闪烁1次, 实际就是点亮50ms break; case SIMPLEPROFILE_CHAR6: // 这个是我们添加char6, 用于做串口透传 与从机 notify 数据到主机 很合适 SimpleProfile_GetParameter( SIMPLEPROFILE_CHAR6, &newValue, &returnBytes); { char str[21]={0}; char str2[32]={0}; osal_memcpy(str, newValue, returnBytes); sprintf(str2,"Char 6: %s", str); #if (defined HAL_LCD) && (HAL_LCD == TRUE) HalLcdWriteString(str2, HAL_LCD_LINE_6 ); #endif // (defined HAL_LCD) && (HAL_LCD == TRUE) // 通过串口透传出去,达到透传目的,amo家的透传就是使用 CHAR6 NPI_WriteTransport(newValue, returnBytes); HalLedBlink (HAL_LED_3, 1, 50, 100);//这个的意思是, 100ms内,以50%的占空比闪烁1次, 实际就是点亮50ms } break; case SIMPLEPROFILE_CHAR7: // 收到 CHAR7 的数据 SimpleProfile_GetParameter( SIMPLEPROFILE_CHAR7, &newValue, &returnBytes); osal_memset(sys_config.name, 0, sizeof(sys_config.name)); osal_memcpy(sys_config.name, newValue, returnBytes); osal_snv_write(0x80, sizeof(SYS_CONFIG), &sys_config); // 写所有参数 HalLcdWriteString( "Char 7 Set", HAL_LCD_LINE_4 ); HalLcdWriteString( (char*)sys_config.name, HAL_LCD_LINE_5 ); // 需要重启后设备名生效 break; case SIMPLEPROFILE_CHAR8: // 收到 CHAR8 的数据 SimpleProfile_GetParameter( SIMPLEPROFILE_CHAR8, &newValue, &returnBytes); // 最高温度报警 sys_config.tempeature_hight = newValue[0]<<8; sys_config.tempeature_hight |= newValue[1]; // 最低温度报警 sys_config.tempeature_low = newValue[2]<<8; sys_config.tempeature_low |= newValue[3]; break; case SIMPLEPROFILE_CHAR9: // adc 只读 break; case SIMPLEPROFILE_CHARA: // // pwm SimpleProfile_GetParameter( SIMPLEPROFILE_CHARA, &newValue, &returnBytes); #if (defined HAL_LCD) && (HAL_LCD == TRUE) HalLcdWriteStringValue( "Char A[0]:", (uint16)(newValue[0]), 16, HAL_LCD_LINE_5 ); HalLcdWriteStringValue( "Char A[1]:", (uint16)(newValue[1]), 16, HAL_LCD_LINE_6 ); HalLcdWriteStringValue( "Char A[2]:", (uint16)(newValue[2]), 16, HAL_LCD_LINE_7 ); HalLcdWriteStringValue( "Char A[3]:", (uint16)(newValue[3]), 16, HAL_LCD_LINE_8 ); #endif // (defined HAL_LCD) && (HAL_LCD == TRUE) // 设定pwm if(returnBytes == 4) { sys_config.pwm[3] = newValue[0]; // 白色 sys_config.pwm[2] = newValue[1]; // 红色 sys_config.pwm[1] = newValue[2]; // 绿色 sys_config.pwm[0] = newValue[3]; // 蓝色 osal_start_timerEx( simpleBLEPeripheral_TaskID, SBP_SET_PWM_EVT, 50); } break; default: // should not reach here! break; } }
/*************************************************************************************************** * @fn Uart_Msg_Pack * * @brief pack uart Msg,this msg was came to e009 uart * * @param pBuffer: msg; length: msg length * * @return None ***************************************************************************************************/ bool Uart_Msg_Pack(uint8 *pBuffer, uint8 length ) { uint8 i; uint8 *buffer; if( pBuffer == NULL || length < 2 ) //error accured return false; //identification + checkcode + identification = 3 bytes buffer = osal_mem_alloc(length + 3); //add identification buffer[0] = 0x55; //add msg for( i = 0; i < length; i++ ) { buffer[i+1] = pBuffer[i]; } uart_send.msg_len = i+1; //default checkcode 0x00; buffer[uart_send.msg_len] = 0x00; uart_send.msg_len++; //add identification buffer[uart_send.msg_len] = 0x55; uart_send.msg_len++; #if 0 { char strTemp[35] = {0}; int i = 0; int j = 5; for(i = 0; i < uart_send.msg_len; i++) { sprintf(strTemp, "%d=0x%x \n",i,buffer[i]); NPI_WriteTransport((uint8*)strTemp, osal_strlen(strTemp)); //while(j--); }} NPI_WriteTransport("\r\n", 2); #endif //add checkcode Uart_Msg_Add_Checkcode(buffer,uart_send.msg_len); #if 0 { char strTemp[35] = {0}; int i = 0; int j = 5; for(i = 0; i < uart_send.msg_len; i++) { sprintf(strTemp, "%d=0x%x \n",i,buffer[i]); NPI_WriteTransport((uint8*)strTemp, osal_strlen(strTemp)); //while(j--); }} NPI_WriteTransport("\r\n", 2); #endif //transform msg Uart_Msg_Transform(buffer,uart_send.msg_len); //free memory osal_mem_free(buffer); return true; }
/********************************************************************* * @fn simpleBLECentralProcessGATTMsg * * @brief Process GATT messages * * @return none */ static void simpleBLECentralProcessGATTMsg( gattMsgEvent_t *pMsg ) { if ( simpleBLEState != BLE_STATE_CONNECTED ) { // In case a GATT message came after a connection has dropped, // ignore the message return; } if ( ( pMsg->method == ATT_READ_RSP ) || ( ( pMsg->method == ATT_ERROR_RSP ) && ( pMsg->msg.errorRsp.reqOpcode == ATT_READ_REQ ) ) ) { if ( pMsg->method == ATT_ERROR_RSP ) { uint8 status = pMsg->msg.errorRsp.errCode; LCD_WRITE_STRING_VALUE( "Read Error", status, 10, HAL_LCD_LINE_1 ); } else { // After a successful read, display the read value uint8 valueRead = pMsg->msg.readRsp.value[0]; if (valueRead == 0x55) { P0_4 = 1; } #if 0 char strTemp[35] = {0}; sprintf(strTemp, "raad value = %d\r\n",valueRead); NPI_WriteTransport((uint8*)strTemp, osal_strlen(strTemp)); #endif LCD_WRITE_STRING_VALUE( "Read rsp:", valueRead, 10, HAL_LCD_LINE_1 ); } #if 0 char strTemp[35] = {0}; sprintf(strTemp, "raad process function\r\n"); NPI_WriteTransport((uint8*)strTemp, osal_strlen(strTemp)); #endif simpleBLEProcedureInProgress = FALSE; } else if ( ( pMsg->method == ATT_WRITE_RSP ) || ( ( pMsg->method == ATT_ERROR_RSP ) && ( pMsg->msg.errorRsp.reqOpcode == ATT_WRITE_REQ ) ) ) { if ( pMsg->method == ATT_ERROR_RSP == ATT_ERROR_RSP ) { uint8 status = pMsg->msg.errorRsp.errCode; LCD_WRITE_STRING_VALUE( "Write Error", status, 10, HAL_LCD_LINE_1 ); } else { // After a succesful write, display the value that was written and increment value LCD_WRITE_STRING_VALUE( "Write sent:", simpleBLECharVal++, 10, HAL_LCD_LINE_1 ); } simpleBLEProcedureInProgress = FALSE; } else if ( simpleBLEDiscState != BLE_DISC_STATE_IDLE ) { simpleBLEGATTDiscoveryEvent( pMsg ); } }