Ejemplo n.º 1
0
QRcodeManager::~QRcodeManager()
{
	if(getConnectionStatus())   //如果保持链接则断开链接
	{
			this->destroyConnection();
	}		
}
Ejemplo n.º 2
0
bool StationClass::isConnected()
{
	if (getConnectionStatus() != eSCS_GotIP) return false;
	if (getIP().isNull()) return false;

	return true;
}
/**
 * @brief Looks up the IP address of a given hostname
 *
 * @param[in] hostname the name of the host or website (e.g. www.google.com)
 * @param[out] ip_address returned IP address of the hostname
 * @return True if lookup completed successfully. False otherwise.
 */
bool SFE_CC3000::dnsLookup(char *hostname, IPAddress *ip_address)
{
    unsigned long ret_ip_addr = 0;

    /* If CC3000 is not initialized, return false. */
	if (!getInitStatus()) {
        return false;
    }
    
    /* If not connected, return false. */
    if (!getConnectionStatus()) {
        return false;
    }
    
    /* If DHCP has not been assigned, return false. */
    if (!getDHCPStatus()) {
        return false;
    }

    /* Attempt to get IP address by hostname */
    if (!gethostbyname(hostname, strlen(hostname), &ret_ip_addr)) {
        return false;
    }

    *ip_address = IPAddress(
        (uint8_t)(ret_ip_addr >> 24) & 0xFF,
        (uint8_t)(ret_ip_addr >> 16) & 0xFF,
        (uint8_t)(ret_ip_addr >> 8) & 0xFF,
        (uint8_t)ret_ip_addr & 0xFF);

    return true;
}
Ejemplo n.º 4
0
bool
SCI_Transporter::init_remote()
{
  DBUG_ENTER("SCI_Transporter::init_remote");
  sci_error_t err; 
  Uint32 offset = 0;
  if(!m_mapped ) {
    DBUG_PRINT("info", ("Map remote segments"));
    for(Uint32 i=0; i < m_adapters ; i++) {
      m_TargetSegm[i].rhm[i].remoteHandle=0;
      SCIConnectSegment(sciAdapters[i].scidesc,
                        &(m_TargetSegm[i].rhm[i].remoteHandle),
                        m_remoteNodes[i],
                        remoteSegmentId(localNodeId, remoteNodeId),
                        i,
                        0,
                        0,
                        0,
                        0,
                        &err);

      if(err != SCI_ERR_OK) {
        NdbSleep_MilliSleep(10);
        DBUG_PRINT("error", ("Error connecting segment, err 0x%x", err));
        DBUG_RETURN(false);
      }
    }
    // Map the remote memory segment into program space  
    for(Uint32 i=0; i < m_adapters ; i++) {
      m_TargetSegm[i].mappedMemory =
        SCIMapRemoteSegment((m_TargetSegm[i].rhm[i].remoteHandle),
                            &(m_TargetSegm[i].rhm[i].map),
                            offset,
                            m_BufferSize,
                            NULL,
                            FLAGS,
                            &err);

      if(err!= SCI_ERR_OK) {
        DBUG_PRINT("error",
          ("Cannot map a segment to the remote node %d. Error code 0x%x",
          m_RemoteSciNodeId, err));
        //NDB SHOULD TERMINATE AND COMPUTER REBOOTED! 
        report_error(TE_SCI_CANNOT_MAP_REMOTESEGMENT);
        DBUG_RETURN(false);
      }
    }
    m_mapped=true;
    setupRemoteSegment();
    setConnected();
    DBUG_PRINT("info", ("connected and mapped to segment, remoteNode: %d",
               remoteNodeId));
    DBUG_PRINT("info", ("remoteSegId: %d",
               remoteSegmentId(localNodeId, remoteNodeId)));
    DBUG_RETURN(true);
  } else {
    DBUG_RETURN(getConnectionStatus());
  }
}
Ejemplo n.º 5
0
const char* StationClass::getConnectionStatusName()
{
	switch (getConnectionStatus())
	{
	case eSCS_Idle:
		return "Idle";
	case eSCS_Connecting:
		return "Connecting";
	case eSCS_WrongPassword:
		return "Wrong password";
	case eSCS_AccessPointNotFound:
		return "Access point not found";
	case eSCS_ConnectionFailed:
		return "Connection failed";
	case eSCS_GotIP:
		return "Successful connected";
	default:
		SYSTEM_ERROR("Unknown status: %d", getConnectionStatus());
		return "";
	};
}
Ejemplo n.º 6
0
void SCI_Transporter::disconnectImpl() 
{ 
  DBUG_ENTER("SCI_Transporter::disconnectImpl");
  sci_error_t err; 
  if(m_mapped){ 
    setDisconnect(); 
    DBUG_PRINT("info", ("connect status = %d, remote node = %d",
    (int)getConnectionStatus(), remoteNodeId)); 
    disconnectRemote(); 
    disconnectLocal(); 
  } 
  
  // Empty send buffer 

  m_sendBuffer.m_dataSize = 0;

  m_initLocal=false; 
  m_mapped = false; 
  
  if(m_sciinit) { 
    for(Uint32 i=0; i<m_adapters ; i++) {       
      SCIClose(sciAdapters[i].scidesc, FLAGS, &err);  
      
      if(err != SCI_ERR_OK)  { 
	report_error(TE_SCI_UNABLE_TO_CLOSE_CHANNEL); 
        DBUG_PRINT("error",
        ("Cannot close channel to the driver. Error code 0x%x",  
		    err)); 
      } 
    } 
  } 
  m_sciinit=false; 
   
#ifdef DEBUG_TRANSPORTER 
      ndbout << "total: " <<  i1024+ i10242048 + i2048+i2049 << endl; 
      ndbout << "<1024: " << i1024 << endl; 
      ndbout << "1024-2047: " << i10242048 << endl; 
      ndbout << "==2048: " << i2048 << endl; 
      ndbout << "2049-4096: " << i20484096 << endl; 
      ndbout << "==4096: " << i4096 << endl; 
      ndbout << ">4096: " << i4097 << endl; 
#endif 
  DBUG_VOID_RETURN;  
}  
/**
 * @brief Pings IP address [attempts] times and returns a ping report
 *
 * @param[in] ip_address the IP address to ping
 * @param[out] ping_report returned ping report with statistics
 * @param[in] attempts optional number of times to ping the address
 * @param[in] size optional size of ping buffer (up to 1400 bytes)
 * @param[in] timeout optional time to wait for ping response (milliseconds)
 * @return True if ping command succeeded. False otherwise.
 */
bool SFE_CC3000::ping(  IPAddress ip_address, 
                        PingReport &ping_report,
                        unsigned int attempts, 
                        unsigned int size, 
                        unsigned int timeout)
{
    
    unsigned long ip_addr;
    
    /* If CC3000 is not initialized, return false. */
	if (!getInitStatus()) {
        return false;
    }
    
    /* If not connected, return false. */
    if (!getConnectionStatus()) {
        return false;
    }
    
    /* If DHCP has not been assigned, return false. */
    if (!getDHCPStatus()) {
        return false;
    }
    
    /* Create unsigned long IP address out of char array */
    ip_addr = (unsigned long)ip_address[0] | 
                ((unsigned long)ip_address[1] << 8) |
                ((unsigned long)ip_address[2] << 16) |
                ((unsigned long)ip_address[3] << 24);
                
    /* Send pings and wait for report */
    if (netapp_ping_send(&ip_addr, attempts, size, timeout) != CC3000_SUCCESS) {
        return false;
    }
    delay((timeout * attempts) * 2);
    
    /* Copy output of ping report to return sruct */
    memcpy(&ping_report, &g_ping_report, sizeof(PingReport));
    
    return true;
}
Ejemplo n.º 8
0
//初始化mysql链接
void QRcodeManager::initConnection()
{
	if(!getConnectionStatus())
	{
		mysql_init(&mysql);
    	if(mysql_real_connect(
						&mysql,
						"localhost",
						"zhoufeizhou",
						NULL,
						"QRcode_base",
						3306,
						NULL,
						0))
		{
		this->IsConnected = true;

		mysql_query(&mysql,"SET NAMES UTF8");
		}
	}
}
Ejemplo n.º 9
0
bool StationClass::isConnectionFailed()
{
	EStationConnectionStatus status = getConnectionStatus();
	return status == eSCS_WrongPassword || status == eSCS_AccessPointNotFound || status == eSCS_ConnectionFailed;
}
Ejemplo n.º 10
0
/**
 * @brief Fills out ConnectionInfo struct with AP connection details
 *
 * @param[out] info struct containing information about the AP connection
 * @return True if connection is valid. False otherwise.
 */
bool SFE_CC3000::getConnectionInfo(ConnectionInfo &info) 
{
    uint8_t i;
    uint8_t max;
    
    /* If CC3000 is not initialized, return false. */
	if (!getInitStatus()) {
        return false;
    }
    
    /* If not connected, return false. */
    if (!getConnectionStatus()) {
        return false;
    }
    
    /* If DHCP has not been assigned, return false. */
    if (!getDHCPStatus()) {
        return false;
    }
    
    /* Copy IP address to return struct. Reverse byte order. */
    max = sizeof(connection_info_.aucIP);
    for (i = 0; i < max; i++) {
        info.ip_address[i] = connection_info_.aucIP[max - 1 - i];
    }

    /* Copy subnet mask to return struct. Reverse byte order. */
    max = sizeof(connection_info_.aucSubnetMask);
    for (i = 0; i < max; i++) {
        info.subnet_mask[i] = connection_info_.aucSubnetMask[max - 1 - i];
    }
    
    /* Copy default gateway to return struct. Reverse byte order. */
    max = sizeof(connection_info_.aucDefaultGateway);
    for (i = 0; i < max; i++) {
        info.default_gateway[i] = connection_info_.aucDefaultGateway[max - 
                                                                        1 - i];
    }
    
    /* Copy DHCP server address to return struct. Reverse byte order. */
    max = sizeof(connection_info_.aucDHCPServer);
    for (i = 0; i < max; i++) {
        info.dhcp_server[i] = connection_info_.aucDHCPServer[max - 1 - i];
    }
    
    /* Copy DNS server address to return struct. Reverse byte order. */
    max = sizeof(connection_info_.aucDNSServer);
    for (i = 0; i < max; i++) {
        info.dns_server[i] = connection_info_.aucDNSServer[max - 1 - i];
    }
    
    /* Copy MAC address to return struct. Reverse byte order. */
    max = sizeof(connection_info_.uaMacAddr);
    for (i = 0; i < max; i++) {
        info.mac_address[i] = connection_info_.uaMacAddr[max - 1 - i];
    }

    /* Copy SSID to return struct. Keep byte order. */
    memcpy(info.ssid, connection_info_.uaSSID, 32);
    
    return true;
}
Ejemplo n.º 11
0
/**
 * @brief Begins SmartConfig. The user needs to run the SmartConfig phone app.
 *
 * @param[in] timeout optional time (ms) to wait before stopping. 0 = no timeout
 * @return True if connected to wireless network. False otherwise.
 */
bool SFE_CC3000::startSmartConfig(unsigned int timeout)
{
    char cc3000_prefix[] = {'T', 'T', 'T'};
    unsigned long time;
    
    /* Reset all global connection variables */
    ulSmartConfigFinished = 0;
	ulCC3000Connected = 0;
	ulCC3000DHCP = 0;
	OkToDoShutDown=0;
    
    /* If CC3000 is not initialized, return false. */
	if (!getInitStatus()) {
        return false;
    }
    
    /* Set connection profile to manual (no fast or auto connect) */
    if (wlan_ioctl_set_connection_policy(DISABLE, DISABLE, DISABLE) != 
                                                            CC3000_SUCCESS) {
        return false;
    }
    
    /* Delete old connection profiles */
    if (wlan_ioctl_del_profile(255) != CC3000_SUCCESS) {
        return false;
    }
    
    /* Wait until CC3000 is disconnected */
    while (getConnectionStatus()) {
        delay(1);
    }
    
    /* Sets the prefix for SmartConfig. Should always be "TTT" */
    if (wlan_smart_config_set_prefix((char*)cc3000_prefix) != CC3000_SUCCESS) {
        return false;
    }
    
    /* Start the SmartConfig process */
    if (wlan_smart_config_start(0) != CC3000_SUCCESS) {
        return false;
    }
    
    /* Wait for SmartConfig to complete */
    time = millis();
    while (ulSmartConfigFinished == 0) {
        if (timeout != 0) {
            if ( (millis() - time) > timeout ) {
                return false;
            }
        }
    }
    
    /* Configure to connect automatically to AP from SmartConfig process */
    if (wlan_ioctl_set_connection_policy(DISABLE, DISABLE, ENABLE) != 
                                                            CC3000_SUCCESS) {
        return false;
    }
    
    /* Reset CC3000 */
    wlan_stop();
    delay(400);
    wlan_start(0);
    
    /* Wait for connection and DHCP-assigned IP address */
    while (getDHCPStatus() == false) {
        if (timeout != 0) {
            if ( (millis() - time) > timeout ) {
                return false;
            }
        }
    }
    
    /* If we make it this far, we need to tell the SmartConfig app to stop */
    mdnsAdvertiser(1, DEVICE_NAME, strlen(DEVICE_NAME));
    
    /* Get connection information */
    netapp_ipconfig(&connection_info_);

    return true;
}
Ejemplo n.º 12
0
/**
 * @brief Connects to a WAP using the given SSID and password
 *
 * @param[in] ssid the SSID for the wireless network
 * @param[in] security type of security for the network
 * @param[in] password optional ASCII password if connecting to a secured AP
 * @param[in] timeout optional time (ms) to wait before stopping. 0 = no timeout
 * @return True if connected to wireless network. False otherwise.
 */
bool SFE_CC3000::connect(   char *ssid, 
                            unsigned int security, 
                            char *password,
                            unsigned int timeout)
{
    unsigned long time;

    /* If CC3000 is not initialized, return false. */
	if (!getInitStatus()) {
        return false;
    }
    
    /* If already connected, return false. */
    if (getDHCPStatus()) {
        return false;
    }
    
    /* If security mode is not a predefined type, return false. */
    if ( !( security == WLAN_SEC_UNSEC ||
            security == WLAN_SEC_WEP ||
            security == WLAN_SEC_WPA ||
            security == WLAN_SEC_WPA2) ) {
        return false;
    }
    
    /* Set connection profile to manual (no fast or auto connect) */
    if (wlan_ioctl_set_connection_policy(DISABLE, DISABLE, DISABLE) != 
                                                            CC3000_SUCCESS) {
        return false;
    }
    
    /* Connect to the given access point*/
    time = millis();
    while (getConnectionStatus() == false) {
    
        /* Attempt to connect to an AP */
        delay(10);
        if (security == WLAN_SEC_UNSEC) {

            if (wlan_connect(   WLAN_SEC_UNSEC, 
                                ssid, 
                                strlen(ssid), 
                                0, 
                                0, 
                                0) == CC3000_SUCCESS) {
                break;
            }
        } else {
            if (wlan_connect(   security, 
                                ssid, 
                                strlen(ssid), 
                                0, 
                                (unsigned char*)password, 
                                strlen(password)) == CC3000_SUCCESS) {
                break;
            }
        }
        
        /* Check against timeout. Return if out of time. */
        if (timeout != 0) {
            if ( (millis() - time) > timeout ) {
                return false;
            }
        }
    }
    
    /* Wait for DHCP */
    while (getDHCPStatus() == false) {
        if (timeout != 0) {
            if ( (millis() - time) > timeout ) {
                return false;
            }
        }
    }

    /* Get connection information */
    netapp_ipconfig(&connection_info_);

    return true;
}
Ejemplo n.º 13
0
/**
 * @brief Process a message received from the Chromecast
 * @param msg the CastMessage to process
 * @return 0 if the message has been successfuly processed else -1
 */
void intf_sys_t::processMessage(const castchannel::CastMessage &msg)
{
    const std::string & namespace_ = msg.namespace_();

#ifndef NDEBUG
    msg_Dbg(p_stream,"processMessage: %s->%s %s", namespace_.c_str(), msg.destination_id().c_str(), msg.payload_utf8().c_str());
#endif

    if (namespace_ == NAMESPACE_DEVICEAUTH)
    {
        castchannel::DeviceAuthMessage authMessage;
        authMessage.ParseFromString(msg.payload_binary());

        if (authMessage.has_error())
        {
            msg_Err(p_stream, "Authentification error: %d", authMessage.error().error_type());
        }
        else if (!authMessage.has_response())
        {
            msg_Err(p_stream, "Authentification message has no response field");
        }
        else
        {
            vlc_mutex_locker locker(&lock);
            setConnectionStatus(CHROMECAST_AUTHENTICATED);
            msgConnect(DEFAULT_CHOMECAST_RECEIVER);
            msgReceiverLaunchApp();
        }
    }
    else if (namespace_ == NAMESPACE_HEARTBEAT)
    {
        json_value *p_data = json_parse(msg.payload_utf8().c_str());
        std::string type((*p_data)["type"]);

        if (type == "PING")
        {
            msg_Dbg(p_stream, "PING received from the Chromecast");
            msgPong();
        }
        else if (type == "PONG")
        {
            msg_Dbg(p_stream, "PONG received from the Chromecast");
        }
        else
        {
            msg_Warn(p_stream, "Heartbeat command not supported: %s", type.c_str());
        }

        json_value_free(p_data);
    }
    else if (namespace_ == NAMESPACE_RECEIVER)
    {
        json_value *p_data = json_parse(msg.payload_utf8().c_str());
        std::string type((*p_data)["type"]);

        if (type == "RECEIVER_STATUS")
        {
            json_value applications = (*p_data)["status"]["applications"];
            const json_value *p_app = NULL;

            vlc_mutex_locker locker(&lock);
            for (unsigned i = 0; i < applications.u.array.length; ++i)
            {
                std::string appId(applications[i]["appId"]);
                if (appId == APP_ID)
                {
                    const char *pz_transportId = applications[i]["transportId"];
                    if (pz_transportId != NULL)
                    {
                        appTransportId = std::string(pz_transportId);
                        p_app = &applications[i];
                    }
                    break;
                }
            }

            if ( p_app )
            {
                if (!appTransportId.empty()
                        && getConnectionStatus() == CHROMECAST_AUTHENTICATED)
                {
                    msgConnect(appTransportId);
                    setConnectionStatus(CHROMECAST_APP_STARTED);
                    msgPlayerLoad();
                    setConnectionStatus(CHROMECAST_MEDIA_LOAD_SENT);
                    vlc_cond_signal(&loadCommandCond);
                }
            }
            else
            {
                switch(getConnectionStatus())
                {
                /* If the app is no longer present */
                case CHROMECAST_APP_STARTED:
                case CHROMECAST_MEDIA_LOAD_SENT:
                    msg_Warn(p_stream, "app is no longer present. closing");
                    msgReceiverClose(appTransportId);
                    setConnectionStatus(CHROMECAST_CONNECTION_DEAD);
                    break;

                case CHROMECAST_AUTHENTICATED:
                    msg_Dbg(p_stream, "Chromecast was running no app, launch media_app");
                    appTransportId = "";
                    msgReceiverLaunchApp();
                    break;

                default:
                    break;
                }

            }
        }
        else if (type == "LAUNCH_ERROR")
        {
            json_value reason = (*p_data)["reason"];
            msg_Err(p_stream, "Failed to start the MediaPlayer: %s",
                    (const char *)reason);
        }
        else
        {
            msg_Warn(p_stream, "Receiver command not supported: %s",
                    msg.payload_utf8().c_str());
        }

        json_value_free(p_data);
    }
    else if (namespace_ == NAMESPACE_MEDIA)
    {
        json_value *p_data = json_parse(msg.payload_utf8().c_str());
        std::string type((*p_data)["type"]);

        if (type == "MEDIA_STATUS")
        {
            json_value status = (*p_data)["status"];
            msg_Dbg(p_stream, "Player state: %s sessionId:%d",
                    status[0]["playerState"].operator const char *(),
                    (int)(json_int_t) status[0]["mediaSessionId"]);
        }
        else if (type == "LOAD_FAILED")
        {
            msg_Err(p_stream, "Media load failed");
            msgReceiverClose(appTransportId);
            vlc_mutex_locker locker(&lock);
            setConnectionStatus(CHROMECAST_CONNECTION_DEAD);
        }
        else if (type == "INVALID_REQUEST")
        {
            msg_Dbg(p_stream, "We sent an invalid request reason:%s", (*p_data)["reason"].operator const char *());
        }
        else
        {
            msg_Warn(p_stream, "Media command not supported: %s",
                    msg.payload_utf8().c_str());
        }

        json_value_free(p_data);
    }
    else if (namespace_ == NAMESPACE_CONNECTION)
    {
        json_value *p_data = json_parse(msg.payload_utf8().c_str());
        std::string type((*p_data)["type"]);
        json_value_free(p_data);

        if (type == "CLOSE")
        {
            msg_Warn(p_stream, "received close message");
            vlc_mutex_locker locker(&lock);
            setConnectionStatus(CHROMECAST_CONNECTION_DEAD);
        }
        else
        {
            msg_Warn(p_stream, "Connection command not supported: %s",
                    type.c_str());
        }
    }
    else
    {
        msg_Err(p_stream, "Unknown namespace: %s", msg.namespace_().c_str());
    }
}
Ejemplo n.º 14
0
/** \brief
 *
 *  \type         local
 *
 *  \param[in]	  pvData    not used
 *
 *  \return       void
 *
 ******************************************************************************/
void vConnectionTask(void *pvData) {
	
		//nRF8001 initialisieren
		nRF8001();
		vTaskDelay(10);

    while (1) {
			

			
			//Check the current DeviceState
			deviceCurrentState=getDeviceState();
			switch(deviceCurrentState)
			{
					case Initial:
						setup(); 				//DeviceStartedEvent
						break;
					
					case Setup:
						break;
					
					case Standby:
						
						//Check the current connectionState
						connectionState=getConnectionStatus();
						switch(connectionState)
						{
								//Is not connected
								case Disconnected:
									connect(0x3f,0xff,0x40,0x00);
									poll(0x200);		//CommandResponseEvent
									pollvoid();			//ConnectEvent
								break;
								
								//Is connected
								case Connected:
											//Open the Pipe to Receive
											openRemotePipe(1);
											pollvoid();				//CommandResponseEvent
								
											//Request the Data
											requestData(1);
											pollvoid();				//DataReceivedEvent
										
											//Write the Data in local varible
											length = rxEvent->length;
											for(txcount=0;txcount<=length-3;txcount++)
											{
												Data[txcount]=rxEvent->msg.dataReceived.data[txcount];
											}
											
											//Close the Pipe
											closeRemotePipe(1);
											pollvoid();								

											// Check the Received Message from the PeerDevice
											switch((Data[0]<<8)|Data[1])
											{
												//Turn the Socket on
												case PLUG_ON:
													//Sets the Control LED
													GPIO_SetBits(GPIOB, GPIO_Pin_11);
													//Solid State Relay active
													GPIO_SetBits(GPIOB, GPIO_Pin_0);
													break;
												
												//Turn the Socket off
												case PLUG_OFF:
													//Resets the Control LED
													GPIO_ResetBits(GPIOB, GPIO_Pin_11);
													//Resets the Solid State Relay
													GPIO_ResetBits(GPIOB, GPIO_Pin_0);
													break;
												
												// Get the data
												case GET_DATA:
														//write the received time in a local varible
														CurrentTime.hour[0]=Data[4];
														CurrentTime.hour[1]=Data[3];
														
														CurrentTime.minute[0]=Data[6];
														CurrentTime.minute[1]=Data[5];
												
														//update the time
														xQueueSend(xQueueTime, (void *) &CurrentTime, portMAX_DELAY);

														//Receive PowerMessage from Logger Task
													
														xQueueReceive( xQueuePowerMessage, &( PowerMessage ), portMAX_DELAY );
															active=(float)PowerMessage.active/60;
															voltage=(float)PowerMessage.voltage/4;
															current=(float)PowerMessage.current*4;
														
														switch(Data[2])
														{
															case ACTIVE_POWER:
																//write the active Power in the Outgoing Message
																sprintf(OutMessage,"P:%4.1f W %c%c:%c%c",active, PowerMessage.hour[1], PowerMessage.hour[0], PowerMessage.minute[1], PowerMessage.minute[0]);
																break;
															
															case REACTIVE_POWER:
																//write the reactive Power in the Outgoing Message
																sprintf(OutMessage,"Q:%d mVAr %c%c:%c%c",PowerMessage.reactive, PowerMessage.hour[1], PowerMessage.hour[0], PowerMessage.minute[1], PowerMessage.minute[0]);
																break;
															
															case APPARENT_POWER:
																//write the apparent Power in the Outgoing Message
																sprintf(OutMessage,"S:%d mVA %c%c:%c%c",PowerMessage.apparent, PowerMessage.hour[1], PowerMessage.hour[0], PowerMessage.minute[1], PowerMessage.minute[0]);
																break;
															
															case U_RMS:
																//write the RMS voltage in the Outgoing Message
																sprintf(OutMessage,"U:%4.1f V %c%c:%c%c",voltage, PowerMessage.hour[1], PowerMessage.hour[0], PowerMessage.minute[1], PowerMessage.minute[0]);
																break;
															
															case I_RMS:
																//write the RMS current in the Outgoing Message
																sprintf(OutMessage,"I:%4.1f mA %c%c:%c%c",current, PowerMessage.hour[1], PowerMessage.hour[0], PowerMessage.minute[1], PowerMessage.minute[0]);
																break;
															default:
																break;
												
															
														}		
														
														//Open the send Pipe
														openRemotePipe(2);
														pollvoid();				//CommandResponseEvent
												
														// Send the Output Message to the Peer Device
														sendData(2,20,OutMessage);//s135k
														
														for(txcount=0;txcount<20;txcount++)
														{
															OutMessage[txcount]=0;
														}
												
														//Close the Send Pipe
														closeRemotePipe(2);
														pollvoid();							
													break;
												default:
													break;
											}
									break;
									
								//Is connecting
								case Connecting:
									break;
							
								default:
									break;	
						}
						break;
					
					case Invalid:
						break;
					
					default:
						break;			
			}

			
			vTaskDelay(10);
	}
}