本文整理汇总了C++中putrsUART函数的典型用法代码示例。如果您正苦于以下问题:C++ putrsUART函数的具体用法?C++ putrsUART怎么用?C++ putrsUART使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了putrsUART函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: WF_Connect
/*****************************************************************************
* FUNCTION: WF_Connect
*
* RETURNS: None
*
* PARAMS: None
*
* NOTES: Connects to an 802.11 network. Customize this function as needed
* for your application.
*****************************************************************************/
static void WF_Connect(void)
{
UINT8 ConnectionProfileID;
UINT8 channelList[] = MY_DEFAULT_CHANNEL_LIST;
#if defined(WF_USE_POWER_SAVE_FUNCTIONS)
BOOL PsPollEnabled;
#endif
/* create a Connection Profile */
WF_CPCreate(&ConnectionProfileID);
#if defined(STACK_USE_UART)
putrsUART("Set SSID (");
putsUART(AppConfig.MySSID);
putrsUART(")\r\n");
#endif
WF_CPSetSsid(ConnectionProfileID,
AppConfig.MySSID,
AppConfig.SsidLength);
#if defined(STACK_USE_UART)
putrsUART("Set Network Type\r\n");
#endif
WF_CPSetNetworkType(ConnectionProfileID, MY_DEFAULT_NETWORK_TYPE);
#if defined(STACK_USE_UART)
putrsUART("Set Scan Type\r\n");
#endif
WF_CASetScanType(MY_DEFAULT_SCAN_TYPE);
#if defined(STACK_USE_UART)
putrsUART("Set Channel List\r\n");
#endif
WF_CASetChannelList(channelList, sizeof(channelList));
#if defined(STACK_USE_UART)
putrsUART("Set list retry count\r\n");
#endif
// The Retry Count parameter tells the WiFi Connection manager how many attempts to make when trying
// to connect to an existing network. In the Infrastructure case, the default is to retry forever so that
// if the AP is turned off or out of range, the radio will continue to attempt a connection until the
// AP is eventually back on or in range. In the Adhoc case, the default is to retry 3 times since the
// purpose of attempting to establish a network in the Adhoc case is only to verify that one does not
// initially exist. If the retry count was set to WF_RETRY_FOREVER in the AdHoc mode, an AdHoc network
// would never be established. The constants MY_DEFAULT_LIST_RETRY_COUNT_ADHOC and
// MY_DEFAULT_LIST_RETRY_COUNT_INFRASTRUCTURE have been created specifically for the June 2011 MAL release.
#if defined(EZ_CONFIG_STORE)
if (AppConfig.networkType == WF_ADHOC)
WF_CASetListRetryCount(MY_DEFAULT_LIST_RETRY_COUNT_ADHOC);
else
WF_CASetListRetryCount(MY_DEFAULT_LIST_RETRY_COUNT_INFRASTRUCTURE);
#else
#if (MY_DEFAULT_NETWORK_TYPE == WF_ADHOC)
WF_CASetListRetryCount(MY_DEFAULT_LIST_RETRY_COUNT_ADHOC);
#else
WF_CASetListRetryCount(MY_DEFAULT_LIST_RETRY_COUNT_INFRASTRUCTURE);
#endif
#endif
#if defined(STACK_USE_UART)
putrsUART("Set Event Notify\r\n");
#endif
WF_CASetEventNotificationAction(MY_DEFAULT_EVENT_NOTIFICATION_LIST);
#if defined(WF_USE_POWER_SAVE_FUNCTIONS)
PsPollEnabled = (MY_DEFAULT_PS_POLL == WF_ENABLED);
if (!PsPollEnabled)
{
/* disable low power (PS-Poll) mode */
#if defined(STACK_USE_UART)
putrsUART("Disable PS-Poll\r\n");
#endif
WF_PsPollDisable();
}
else
{
/* Enable low power (PS-Poll) mode */
#if defined(STACK_USE_UART)
putrsUART("Enable PS-Poll\r\n");
#endif
WF_PsPollEnable(TRUE);
}
#endif
#if defined(STACK_USE_UART)
putrsUART("Set Beacon Timeout\r\n");
#endif
WF_CASetBeaconTimeout(40);
/* Set Security */
//.........这里部分代码省略.........
开发者ID:Athuli7,项目名称:Microchip,代码行数:101,代码来源:MainDemo.c
示例2: OutputConnectionFailedMsg
static void OutputConnectionFailedMsg(UINT16 eventInfo)
{
#if defined(MRF24WG)
UINT8 status;
UINT8 reason;
status = (UINT8)(eventInfo >> 8);
reason = (UINT8)(eventInfo & 0xff);
if (status == WF_RECV_DEAUTH || status == WF_RECV_DISASSOC)
{
putrsUART("Event: Connection Failed : ");
putrsUART(connectionFailureStrings[status]);
putrsUART(" : ");
#if !defined(__18CXX)
putrsUART(deauthDisssocReasonCodes[reason]);
#endif
}
else if (status == WF_AUTHENTICATION_FAILURE || status == WF_ASSOCIATION_FAILURE)
{
putrsUART("Event: Connection Failed : ");
putrsUART(connectionFailureStrings[status]);
putrsUART(" : ");
#if !defined(__18CXX)
putrsUART(statusCodes[reason]);
#endif
}
else if (status == WF_WPS_FAILURE)
{
putrsUART("Event: Connection Failed : ");
putrsUART(connectionFailureStrings[status]);
putrsUART(" : ");
#if !defined(__18CXX)
putrsUART(wpsState[reason >> 4]);
putrsUART(" : ");
putrsUART(wpsConfigErr[reason & 0x0f]);
#endif
}
开发者ID:guillaume9433,项目名称:Microchip,代码行数:38,代码来源:WFDebugStrings.c
示例3: DHCPTask
//.........这里部分代码省略.........
// Start a timer and begin looking for a response
DHCPClient.dwTimer = TickGet();
DHCPClient.smState = SM_DHCP_GET_REQUEST_ACK;
break;
case SM_DHCP_GET_REQUEST_ACK:
// Check to see if a packet has arrived
if(UDPIsGetReady(DHCPClient.hDHCPSocket) < 250u)
{
// Go back and transmit a new discovery if we didn't get an ACK after 2 seconds
if(TickGet() - DHCPClient.dwTimer >= DHCP_TIMEOUT)
DHCPClient.smState = SM_DHCP_SEND_DISCOVERY;
break;
}
// Check to see if we received an offer
switch(_DHCPReceive())
{
case DHCP_ACK_MESSAGE:
UDPClose(DHCPClient.hDHCPSocket);
DHCPClient.hDHCPSocket = INVALID_UDP_SOCKET;
DHCPClient.dwTimer = TickGet();
DHCPClient.smState = SM_DHCP_BOUND;
DHCPClient.flags.bits.bEvent = 1;
DHCPClient.flags.bits.bIsBound = TRUE;
if(DHCPClient.validValues.bits.IPAddress)
{
AppConfig.MyIPAddr = DHCPClient.tempIPAddress;
#if defined(WF_CS_IO)
#if defined(STACK_USE_UART )
putrsUART("DHCP client successful\r\n");
#endif
SignalDHCPSuccessful();
#endif
}
if(DHCPClient.validValues.bits.Mask)
AppConfig.MyMask = DHCPClient.tempMask;
if(DHCPClient.validValues.bits.Gateway)
AppConfig.MyGateway = DHCPClient.tempGateway;
#if defined(STACK_USE_DNS)
if(DHCPClient.validValues.bits.DNS)
AppConfig.PrimaryDNSServer.Val = DHCPClient.tempDNS.Val;
AppConfig.SecondaryDNSServer.Val = 0x00000000ul;
if(DHCPClient.validValues.bits.DNS2)
AppConfig.SecondaryDNSServer.Val = DHCPClient.tempDNS2.Val;
#endif
//if(DHCPClient.validValues.bits.HostName)
// memcpy(AppConfig.NetBIOSName, (void*)DHCPClient.tempHostName, sizeof(AppConfig.NetBIOSName));
break;
case DHCP_NAK_MESSAGE:
DHCPClient.smState = SM_DHCP_SEND_DISCOVERY;
break;
}
break;
case SM_DHCP_BOUND:
if(TickGet() - DHCPClient.dwTimer < TICK_SECOND)
break;
// Check to see if our lease is still valid, if so, decrement lease
开发者ID:MechAlucard,项目名称:NETWORKS,代码行数:67,代码来源:DHCP.c
示例4: CursorRight_N
/* move cursor to point of backspace */
CursorRight_N(orig_index - 1 - gCmdLinePromptLength);
}
}
static void EraseEntireLine()
{
// int i;
putrsUART( (ROM FAR char*) eraseEntireLineEscapeSequence);
CursorLeft_N(GET_CURSOR());
SET_CURSOR(0);
}
#if 0 /* add back if you want this feature */
static void EraseEntireScreen()
{
putrsUART( (ROM FAR char*) eraseEntireScreenEscapeSequence);
}
开发者ID:Subaru-PFS,项目名称:ics_xcu_pcm,代码行数:21,代码来源:WFConsole.c
示例5: WaitForMgmtResponse
/*******************************************************************************
Function:
void WaitForMgmtResponse(UINT8 expectedSubtype, UINT8 freeAction)
Summary:
Waits for a management response
Description:
Called after sending a mgmt request. This function waits for a mgmt
response. The caller can optionally request the the management
response be freed immediately (by this function) or not freed. If not
freed, the caller is responsible to free the response buffer.
Precondition:
MACInit must be called.
Parameters:
expectedSubtype -- Expected subtype of the mgmt response
freeAction -- FREE_MGMT_BUFFER or DO_NOT_FREE_MGMT_BUFFER
Returns:
None
Remarks:
*****************************************************************************/
void WaitForMgmtResponse(UINT8 expectedSubtype, UINT8 freeAction)
{
#if defined(__18CXX)
static tMgmtMsgRxHdr hdr;
#else
tMgmtMsgRxHdr hdr;
#endif
g_WaitingForMgmtResponse = TRUE;
/* Wait until mgmt response is received */
while (gMgmtConfirmMsgReceived == FALSE)
{
WFProcess();
/* if received a data packet while waiting for mgmt packet */
if (g_HostRAWDataPacketReceived)
{
// We can't let the StackTask processs data messages that come in while waiting for mgmt
// response because the application might send another mgmt message, which is illegal until the response
// is received for the first mgmt msg. And, we can't prevent the race condition where a data message
// comes in before a mgmt response is received. Thus, the only solution is to throw away a data message
// that comes in while waiting for a mgmt response. This should happen very infrequently. If using TCP then the
// stack takes care of retries. If using UDP, the application has to deal with occasional data messages not being
// received. Also, applications typically do not send a lot of management messages after connected.
// throw away the data rx
RawMountRxBuffer(RAW_DATA_RX_ID);
DeallocateDataRxBuffer();
g_HostRAWDataPacketReceived = FALSE;
/* ensure interrupts enabled */
WF_EintEnable();
}
}
g_WaitingForMgmtResponse = FALSE;
/* set this back to FALSE so the next mgmt send won't think he has a response before one is received */
gMgmtConfirmMsgReceived = FALSE;
/* if the caller wants to delete the response immediately (doesn't need any data from it */
if (freeAction == FREE_MGMT_BUFFER)
{
/* read and verify result before freeing up buffer to ensure our message send was successful */
RawRead(RAW_MGMT_RX_ID, 0, (UINT16)(sizeof(tMgmtMsgRxHdr)), (UINT8 *)&hdr);
/* mgmt response subtype had better match subtype we were expecting */
WF_ASSERT(hdr.subtype == expectedSubtype);
/* Mgmt response 'result' field should always indicate success. If this assert is hit the error codes are located */
/* WFApi.h. Search for WF_SUCCESS for the list of error codes. */
if (hdr.result == WF_ERROR_HOST_SCAN_NOT_ALLOWED)
{
#if defined(STACK_USE_UART)
putrsUART("Host Scan Failed. Host scan is allowed only in idle or connected state\r\n");
#endif
} else if (hdr.result == WF_ERROR_INVALID_WPS_PIN)
{
#if defined(STACK_USE_UART)
putrsUART("WPS failed : Invalid WPS PIN data\r\n");
#endif
} else if (hdr.result == WF_ERROR_DISCONNECT_FAILED)
{
#if defined(STACK_USE_UART)
putrsUART("Disconnect failed. Disconnect is allowed only when module is in connected state\r\n");
#endif
}
else if (hdr.result == WF_ERROR_NO_STORED_BSS_DESCRIPTOR)
{
#if defined(STACK_USE_UART)
putrsUART("No stored scan results\r\n");
#endif
}
else if (hdr.result != WF_SUCCESS)
//.........这里部分代码省略.........
开发者ID:lynxeyed-atsu,项目名称:PIC32MX_DP83848_test,代码行数:101,代码来源:WFMgmtMsg_24G.c
示例6: UnderlineMode
static void UnderlineMode(void)
{
putrsUART(inverseVideoEscapeSequence);
}
开发者ID:Subaru-PFS,项目名称:ics_xcu_pcm,代码行数:4,代码来源:WFConsole.c
示例7: InsertCharacter
/*= InsertCharacter =========================================================
Purpose: Inserts and echoes an printable character into the command line at the
cursor location.
Inputs: c -- char to insert
Returns: none
============================================================================*/
static void InsertCharacter(INT8 c)
{
UINT8 len;
UINT8 i;
UINT8 orig_cursor_index = GET_CURSOR();
UINT8 count;
/* throw away characters if exceeded cmd line length */
if (GET_LEN_RX_CMD_STRING() >= sizeof(g_ConsoleContext.rxBuf)-1)
{
return;
}
len = GET_LEN_RX_CMD_STRING() + gCmdLinePromptLength;
/* if inserting a character at end of cmd line */
if (GET_CURSOR() == len)
{
g_ConsoleContext.rxBuf[GET_CURSOR() - gCmdLinePromptLength] = c;
SET_CURSOR(GET_CURSOR() + 1);
EchoCharacter(c);
}
/* inserting a character somewhere before the end of command line */
else
{
/* Null out tmp cmd line */
memset(gTmpCmdLine, 0x00, sizeof(gTmpCmdLine));
/* copy up to the point of insertion */
strncpy( (char *) gTmpCmdLine, (const char *) g_ConsoleContext.rxBuf, GET_CURSOR() - gCmdLinePromptLength);
/* insert the new character */
gTmpCmdLine[GET_CURSOR() - gCmdLinePromptLength] = c;
/* copy the chars after the new character */
strncpy( (char *) &gTmpCmdLine[GET_CURSOR() - gCmdLinePromptLength + 1],
(const char *) &g_ConsoleContext.rxBuf[GET_CURSOR() - gCmdLinePromptLength],
len - GET_CURSOR());
/* put the first part of new string in the cmd line buffer */
strcpy( (char *) g_ConsoleContext.rxBuf, (const char *) gTmpCmdLine);
/* erase entire line, put the cursor at index 0 */
EraseEntireLine();
/* output the prompt */
putrsUART( (ROM FAR char *) gCmdLinePrompt);
/* Output the updated command line */
putsUART( (char *) &g_ConsoleContext.rxBuf[0]);
/* move the cursor to the next insert location */
count = (len + 1) - orig_cursor_index - 1;
for (i = 0; i < count; ++i)
{
putrsUART( (ROM FAR char *) cursorLeftEscapeSequence);
}
SET_CURSOR(orig_cursor_index + 1);
}
}
开发者ID:Subaru-PFS,项目名称:ics_xcu_pcm,代码行数:70,代码来源:WFConsole.c
示例8: IsZoneTriggered
Zone_States IsZoneTriggered (int ZoneID) {
Zone_States TheZoneState, PreviousZoneState;
WORD Ignore;
//ensure zone is not bypassed or isolated, if so return nothing
if ((ZoneConfig[ZoneID].IsIsolated) || (ZoneConfig[ZoneID].IsBypassed))
return StateNothing;
// What is the previous state
if (ZoneConfig[ZoneID].IsTampered) PreviousZoneState = StateTamper;
else if (ZoneConfig[ZoneID].IsTriggered) PreviousZoneState = StateTrigger;
else PreviousZoneState = StateNormal;
// Determine the state of the zone
TheZoneState = CheckEOL(ZoneID, &Ignore);
//If the state is the same as the previous check and bounce timer not active return nothing.
if ((PreviousZoneState == TheZoneState ) && (ZoneConfig[ZoneID].BounceDelay == (unsigned) 0))
return StateNothing;
// *** TAMPER ***
// Zone is Tampered
if (TheZoneState == StateTamper) {
ZoneConfig[ZoneID].IsTampered = TRUE;
ZoneConfig[ZoneID].BounceDelay = 0; // Will cause a loop always returning StateTamper if left out
// find out what Areas the zone is a part of and set them to tampered
for(iCount = 0; iCount < AREACOUNT; iCount++) {
if (isZoneMemberOfArea(ZoneID, iCount)) {
AreaConfig[iCount].IsTampered = TRUE;
#if defined(DEBUG_UART)
putrsUART((ROM char*)" Area ");
uitoa(iCount, xPLMsgKey);
putsUART(xPLMsgKey);
putrsUART((ROM char*)" is Tampered. \r\n");
#endif
}// isZoneMemberOfArea(ZoneID, iCount)
}// iCount
return StateTamper;
} // StateTamper
// Return from Tamper
if (PreviousZoneState == StateTamper) {
ZoneConfig[ZoneID].IsTampered = FALSE;
ZoneConfig[ZoneID].BounceDelay = 0;
// find out what Areas the zone is a part and set tamper to false if no other zones in the area are tampered
for(iCount = 0; iCount < AREACOUNT; iCount++) {
if (isZoneMemberOfArea(ZoneID, iCount)) {
for(i2Count=0; i2Count < ZONECOUNT; i2Count++) {
if ((i2Count != ZoneID) && isZoneMemberOfArea(i2Count, iCount)) {
if( ZoneConfig[i2Count].IsTampered == TRUE) {
i2Count = 1;
break;
}// is triggered
}// is member of the zone
}//i2Count, Area in question
if (i2Count >= ZONECOUNT) { // no zones in the area found to be triggered
AreaConfig[iCount].IsTampered = FALSE;
#if defined(DEBUG_UART)
putrsUART((ROM char*)" Area ");
uitoa(iCount, xPLMsgKey);
putsUART(xPLMsgKey);
putrsUART((ROM char*)" is not tampered. \r\n");
#endif
}// i2Count >= ZONECOUNT
}// isZoneMemberOfArea(ZoneID, iCount)
}// iCount
// When changing from Tampered to Triggered this will generate a Triggered event after the tamper cleared event
ZoneConfig[ZoneID].IsTriggered = FALSE;
// Return as normal even if triggered to ensure message sequence is correct
return StateNormal;
}
// *** BOUNCE / TRIGGER CLEARED ***
//Every time we return from Triggered to Normal there is a delay of .5 Second, this limits bouncing speed.
//If BounceTimer not expired return Nothing. If we are bouncing it will only send 2 msg per 1/2 second. Do not change previous state
if (ZoneConfig[ZoneID].BounceDelay > (unsigned) 1) {
ZoneConfig[ZoneID].BounceDelay--;
if (TheZoneState == StateTrigger)
ZoneConfig[ZoneID].BounceDelay = 0;
return StateNothing;
}
//if BounceTimer is expired clear BounceTimer
if (ZoneConfig[ZoneID].BounceDelay == (unsigned) 1) {
// if state = Trigger then return nothing as we have bounced back (Trigger, Normal Trigger)
if (TheZoneState == StateTrigger) {
ZoneConfig[ZoneID].BounceDelay = 0;
#if defined(DEBUG_UART)
putrsUART((ROM char*)" Bounce prevented. Zone ");
//.........这里部分代码省略.........
开发者ID:oden65,项目名称:xPL_PIC,代码行数:101,代码来源:EOL.c
示例9: CheckEOL
Zone_States CheckEOL (int ZoneID, WORD* ADval) {
char AN0String[7];
char DebugTemp[7];
int PlexerDevice, BinaryValue;
// Disable all analogue multiplexer
PLEXERA_S_IO = 1; // High = disabled
PLEXERB_S_IO = 1;
PLEXERC_S_IO = 1;
// Select the analogue multiplexer
PlexerDevice = ZoneID / 8;
BinaryValue = ZoneID - ((ZoneID / 8) * 8); // The value can now be expressed as a 3 bit value
if (PlexerDevice == 0) {
PLEXERA_S_IO = 0; //enable this device
PLEXERA_2_IO = ((BinaryValue / 4 > 0)?TRUE:FALSE);
BinaryValue -= (BinaryValue / 4) * 4;
PLEXERA_1_IO = ((BinaryValue / 2 > 0)?TRUE:FALSE);
BinaryValue -= (BinaryValue / 2) * 2;
PLEXERA_0_IO = ((BinaryValue > 0)?TRUE:FALSE);
} // PlexerDevice ==0
else if (PlexerDevice == 1) {
PLEXERB_S_IO = 0; //enable this device
PLEXERB_2_IO = BinaryValue / 4;
BinaryValue -= (BinaryValue / 4) * 4;
PLEXERB_1_IO = BinaryValue / 2;
BinaryValue -= (BinaryValue / 2) * 2;
PLEXERB_0_IO = BinaryValue;
} // PlexerDevice == 1
else if (PlexerDevice == 2) {
PLEXERC_S_IO = 0; //enable this device
PLEXERC_2_IO = BinaryValue / 4;
BinaryValue -= (BinaryValue / 4) * 4;
PLEXERC_1_IO = BinaryValue / 2;
BinaryValue -= (BinaryValue / 2) * 2;
PLEXERC_0_IO = BinaryValue;
} // PlexerDevice == 2
else {
#if defined(DEBUG_UART)
putrsUART((ROM char*)" !!! CheckEOL is out of range !!!!! ");
#endif
*ADval = 0;
return StateNormal;
}
//60 ns delay is required for the Multiplexer to swith analogue channels
//Nop();Nop();Nop();Nop();Nop();
// Select A/D channel AN4
ADCON0 = 0b00010000; // ADON = On(1), GO/DONE = Idle (0), AN4 selected (0100), not used (0), calibration off (0)
ADCON0bits.ADON = 1;
ADCON0bits.GO = 1;
// Wait until A/D conversion is done
while(ADCON0bits.GO);
// Convert 10-bit value into ASCII string
*ADval = (WORD)ADRES;
uitoa(*ADval, AN0String);
if (ZoneID == 1) {
memset(LCDText, '\0', 32);
if (strlen(AN0String) < (unsigned int)4 ) strcatpgm2ram(AN0String, (rom char *) " ");
if (strlen(AN0String) < (unsigned int)4 ) strcatpgm2ram(AN0String, (rom char *) " ");
if (strlen(AN0String) < (unsigned int)4 ) strcatpgm2ram(AN0String, (rom char *) " ");
strcat(LCDText, AN0String);
strcatpgm2ram(LCDText, (rom char *) "->");
}
if ( (*ADval >= (WORD)(EOLNORMAL - EOLTOLERANCE)) && (*ADval <= (WORD)(EOLNORMAL + EOLTOLERANCE))) {
if (ZoneID == 1) {
strcatpgm2ram(LCDText, (rom char *) "Normal");
LCDUpdate();
}
// Need to consider if the zone is Normaly Open or Normaly Closed
if (ZoneConfig[ZoneID].IsNO == FALSE)
return StateNormal;
else
return StateTrigger;
}
else if ( (*ADval >= (WORD)(EOLTRIGGER - EOLTOLERANCE)) && (*ADval <= (WORD)(EOLTRIGGER + EOLTOLERANCE))) {
if (ZoneID == 1) {
strcatpgm2ram(LCDText, (rom char *) "Trigger");
LCDUpdate();
}
// Need to consider if the zone is Normaly Open or Normaly Closed
if (ZoneConfig[ZoneID].IsNO == FALSE)
//.........这里部分代码省略.........
开发者ID:oden65,项目名称:xPL_PIC,代码行数:101,代码来源:EOL.c
示例10: WF_Connect
/*****************************************************************************
* FUNCTION: WF_Connect
*
* RETURNS: None
*
* PARAMS: None
*
* NOTES: Connects to an 802.11 network. Customize this function as needed
* for your application.
*****************************************************************************/
static void WF_Connect(void)
{
UINT8 ConnectionProfileID;
UINT8 channelList[] = MY_DEFAULT_CHANNEL_LIST;
#if defined(WF_USE_POWER_SAVE_FUNCTIONS)
BOOL PsPollEnabled;
#endif
/* create a Connection Profile */
WF_CPCreate(&ConnectionProfileID);
#if defined(STACK_USE_UART)
putrsUART("Set SSID (");
putsUART(AppConfig.MySSID);
putrsUART(")\r\n");
#endif
WF_CPSetSsid(ConnectionProfileID,
AppConfig.MySSID,
AppConfig.SsidLength);
#if defined(STACK_USE_UART)
putrsUART("Set Network Type\r\n");
#endif
WF_CPSetNetworkType(ConnectionProfileID, AppConfig.networkType);
if (AppConfig.networkType == WF_ADHOC)
{
WF_CPSetAdHocBehavior(ConnectionProfileID, WF_ADHOC_CONNECT_THEN_START);
}
#if defined(STACK_USE_UART)
putrsUART("Set Security\r\n");
#endif
switch(AppConfig.SecurityMode) {
case WF_SECURITY_OPEN:
WF_CPSetSecurity(ConnectionProfileID, WF_SECURITY_OPEN, 0, NULL, 0);
break;
case WF_SECURITY_WEP_40:
// assume key 0
WF_CPSetSecurity(ConnectionProfileID, AppConfig.SecurityMode, 0, AppConfig.SecurityKey, 5);
break;
case WF_SECURITY_WEP_104:
// assume key 0
WF_CPSetSecurity(ConnectionProfileID, AppConfig.SecurityMode, 0, AppConfig.SecurityKey, 13);
break;
case WF_SECURITY_WPA_AUTO_WITH_PASS_PHRASE:
WF_CPSetSecurity(ConnectionProfileID, WF_SECURITY_WPA_AUTO_WITH_PASS_PHRASE,
0, AppConfig.SecurityKey, strlen((char*)AppConfig.SecurityKey));
break;
case WF_SECURITY_WPA_AUTO_WITH_KEY:
WF_CPSetSecurity(ConnectionProfileID, WF_SECURITY_WPA_AUTO_WITH_KEY,
0, AppConfig.SecurityKey, 32);
break;
default:
{
}
//#if defined(STACK_USE_UART)
// putrsUART("\r\n\r\nCaptain this should NOT happen.\r\n\r\n");
//#endif
}
#if defined(STACK_USE_UART)
putrsUART("Set Scan Type\r\n");
#endif
WF_CASetScanType(MY_DEFAULT_SCAN_TYPE);
#if defined(STACK_USE_UART)
putrsUART("Set Channel List\r\n");
#endif
WF_CASetChannelList(channelList, sizeof(channelList));
#if defined(STACK_USE_UART)
putrsUART("Set list retry count\r\n");
#endif
WF_CASetListRetryCount(MY_DEFAULT_LIST_RETRY_COUNT);
#if defined(STACK_USE_UART)
putrsUART("Set Event Notify\r\n");
#endif
WF_CASetEventNotificationAction(MY_DEFAULT_EVENT_NOTIFICATION_LIST);
#if defined(WF_USE_POWER_SAVE_FUNCTIONS)
PsPollEnabled = (MY_DEFAULT_PS_POLL == WF_ENABLED);
if (!PsPollEnabled)
{
/* disable low power (PS-Poll) mode */
#if defined(STACK_USE_UART)
putrsUART("Disable PS-Poll\r\n");
#endif
WF_PsPollDisable();
//.........这里部分代码省略.........
开发者ID:OptecInc,项目名称:FocusLynx_FW,代码行数:101,代码来源:MainDemo.c
示例11: ChipReset
/*****************************************************************************
* FUNCTION: ChipReset
*
* RETURNS: N/A
*
* PARAMS:
* N/A
*
*
* NOTES: Performs the necessary SPI operations to cause the MRF24W to reset.
* This function also implements a delay so that it will not return until
* the WiFi device is ready to receive messages again. The delay time will
* vary depending on the amount of code that must be loaded from serial
* flash.
*****************************************************************************/
static void ChipReset(void)
{
UINT16 value;
UINT32 timeoutPeriod;
UINT32 startTickCount;
#if 0
putrsUART(" **** Bypass chip reset\r\n");
return;
#endif
timeoutPeriod = TICKS_PER_SECOND * 3; /* 3000 ms */
/* needed for Microchip PICTail (chip enable active low) */
WF_SetCE_N(WF_LOW); /* set low to enable regulator */
/* Configure reset pin */
WF_SetRST_N(WF_HIGH);
/* Let SPI lines settle before first SPI transaction */
DelayMs(1);
/* clear the power bit to disable low power mode on the MRF24W */
Write16BitWFRegister(WF_PSPOLL_H_REG, 0x0000);
/* Set HOST_RESET bit in register to put device in reset */
Write16BitWFRegister(WF_HOST_RESET_REG, Read16BitWFRegister(WF_HOST_RESET_REG) | WF_HOST_RESET_MASK);
/* Clear HOST_RESET bit in register to take device out of reset */
Write16BitWFRegister(WF_HOST_RESET_REG, Read16BitWFRegister(WF_HOST_RESET_REG) & ~WF_HOST_RESET_MASK);
/* after reset is started poll register to determine when HW reset has completed */
startTickCount = (UINT32)TickGet();
do
{
Write16BitWFRegister(WF_INDEX_ADDR_REG, WF_HW_STATUS_REG);
value = Read16BitWFRegister(WF_INDEX_DATA_REG);
if (TickGet() - startTickCount >= timeoutPeriod)
{
WF_ASSERT(FALSE);
}
} while ( (value & WF_HW_STATUS_NOT_IN_RESET_MASK) == 0);
/* if SPI not connected will read all 1's */
WF_ASSERT(value != 0xffff);
/* now that chip has come out of HW reset, poll the FIFO byte count register */
/* which will be set to a non-zero value when the MRF24W initialization is */
/* complete. */
startTickCount = (UINT32)TickGet();
do
{
value = Read16BitWFRegister(WF_HOST_WFIFO_BCNT0_REG);
if (TickGet() - startTickCount >= timeoutPeriod)
{
WF_ASSERT(FALSE);
}
} while (value == 0);
}
开发者ID:garyStofer,项目名称:wifi_wx_station,代码行数:76,代码来源:WFDriverCom_24G.c
示例12: main
int main(void)
#endif
{
// static DWORD t = 0;
static DWORD dwLastIP = 0;
#if defined (EZ_CONFIG_STORE)
// static DWORD ButtonPushStart = 0;
#endif
// Initialize application specific hardware
InitializeBoard();
// Initialize stack-related hardware components that may be
// required by the UART configuration routines
TickInit();
MPFSInit();
InitDataBuffers();
Slave_SpiInit();
// Initialize Stack and application related NV variables into AppConfig.
InitAppConfig();
// Initiates board setup process if button is depressed
// on startup
/*
#if defined (WIFI_BOARD_FOC_HUB)
XEEBeginWrite(0x0000);
XEEWrite(0xFF);
XEEWrite(0xFF);
XEEEndWrite();
#else
if(BUTTON0_IO == 0u)
{
#if defined(EEPROM_CS_TRIS) || defined(SPIFLASH_CS_TRIS)
// Invalidate the EEPROM contents if BUTTON0 is held down for more than 4 seconds
DWORD StartTime = TickGet();
LED_PUT(0x00);
while(BUTTON0_IO == 0u)
{
if(TickGet() - StartTime > 4*TICK_SECOND)
{
#if defined(EEPROM_CS_TRIS)
XEEBeginWrite(0x0000);
XEEWrite(0xFF);
XEEWrite(0xFF);
XEEEndWrite();
#elif defined(SPIFLASH_CS_TRIS)
SPIFlashBeginWrite(0x0000);
SPIFlashWrite(0xFF);
SPIFlashWrite(0xFF);
#endif
#if defined(STACK_USE_UART)
putrsUART("\r\n\r\nBUTTON0 held for more than 4 seconds. Default settings restored.\r\n\r\n");
#endif
LED_PUT(0x0F);
while((LONG)(TickGet() - StartTime) <= (LONG)(9*TICK_SECOND/2));
LED_PUT(0x00);
while(BUTTON0_IO == 0u);
Reset();
break;
}
}
#endif
#if defined(STACK_USE_UART)
DoUARTConfig();
#endif
}
#endif
*/
// Initialize core stack layers (MAC, ARP, TCP, UDP) and
// application modules (HTTP, SNMP, etc.)
StackInit();
#if defined ( EZ_CONFIG_SCAN )
WFInitScan();
#endif
#if defined(WF_CS_TRIS)
WF_Connect();
#endif
#if defined(STACK_USE_ZEROCONF_LINK_LOCAL)
ZeroconfLLInitialize();
#endif
#if defined(STACK_USE_ZEROCONF_MDNS_SD)
mDNSInitialize(MY_DEFAULT_HOST_NAME);
mDNSServiceRegister(
//.........这里部分代码省略.........
开发者ID:OptecInc,项目名称:FocusLynx_FW,代码行数:101,代码来源:MainDemo.c
示例13: timeSync
void timeSync(void)
{
BYTE i;
signed char j;
static TICK Timer;
static TICK perodicTick = 0;
static TICK t = 0;
static TCP_SOCKET MySocket = INVALID_SOCKET;
static NODE_INFO Server;
static int arp_tries = 0;
static int tcp_tries = 0;
BYTE rcnt=0;
BYTE ncnt=0;
char foundData=0;
if ((tickGet()-t) >= TICK_1S )
{
t = tickGet();
timeNow++;
}
switch(smTS)
{
case SM_START:
#if defined(TIMESYNC_DEBUG)
putrsUART("Start!\r\n");
#endif
// Set IP adress to connect to.
Server.IPAddr.v[0]=193;
Server.IPAddr.v[1]=11;
Server.IPAddr.v[2]=249;
Server.IPAddr.v[3]=54;
arp_tries = 0;
tcp_tries = 0;
smTS = SM_ARP_RESOLVE;
break;
case SM_ARP_RESOLVE:
#if defined(TIMESYNC_DEBUG)
putrsUART("Resolve..\r\n");
#endif
// If ARP is redy..
if (ARPIsTxReady())
{
// Resolve the IP adress..
ARPResolve(&Server.IPAddr);
arp_tries++;
Timer = tickGet();
smTS = SM_ARP_RESOLVED;
}
break;
case SM_ARP_RESOLVED:
#if defined(TIMESYNC_DEBUG)
putrsUART("Resolved..\r\n");
#endif
// If IP adress is resolved, go to next state
if (ARPIsResolved(&Server.IPAddr, &Server.MACAddr))
{
smTS = SM_CONNECT;
}
// If not resolved and spent long time here,
// Go back to previous state and re-resolve.
else if (tickGet()-Timer > 1*TICK_1S)
{
smTS = SM_ARP_RESOLVE;
}
else if (arp_tries>=MAX_ARP_TRIES)
{
//Abort
smTS = SM_ABORT;
}
break;
case SM_CONNECT:
#if defined(TIMESYNC_DEBUG)
putrsUART("Connect..\r\n");
#endif
// We have an sucessfull ARP, connect..
MySocket = TCPConnect(&Server, ServerPort);
tcp_tries++;
if(MySocket == INVALID_SOCKET)
{
// Do something.
}
Timer = tickGet();
smTS = SM_CONNECT_WAIT;
break;
case SM_CONNECT_WAIT:
#if defined(TIMESYNC_DEBUG)
putrsUART("Connect wait..\r\n");
#endif
//.........这里部分代码省略.........
开发者ID:Cougar,项目名称:HomeAutomation,代码行数:101,代码来源:TimeSync.c
示例14: iwconfigDisplayStatus
//.........这里部分代码省略.........
WFConsolePrintRomStr("\tssid: ", FALSE);
WFConsolePrintRamStr(ws.Ssid.String, TRUE);
}
// power
{
switch (iwconfigCb.powerSaveState)
{
case WF_PS_PS_POLL_DTIM_ENABLED:
WFConsolePrintRomStr("\tpwrsave: enabled", TRUE);
WFConsolePrintRomStr("\tdtim rx: enabled", TRUE);
break;
case WF_PS_PS_POLL_DTIM_DISABLED:
WFConsolePrintRomStr("\tpwrsave: enabled", TRUE);
WFConsolePrintRomStr("\tdtim rx: disabled", TRUE);
break;
case WF_PS_OFF:
WFConsolePrintRomStr("\tpwrsave: disabled", TRUE);
break;
default:
WFConsolePrintRomStr("\tpwrsave: unknown(", FALSE);
WFConsolePrintInteger(iwconfigCb.powerSaveState, 'd');
WFConsolePrintRomStr(")", TRUE);
break;
}
}
#if defined(MRF24WG)
// context
WF_OutputConnectionContext();
// Network Type
putrsUART("\tNetwork: ");
#if defined(EZ_CONFIG_STORE) && !defined(WF_CONSOLE_DEMO) /* if EZConfig demo */
if (AppConfig.networkType == WF_ADHOC)
{
putrsUART("AdHoc\r\n");
}
else
{
putrsUART("Infrastructure\r\n");
}
#else
#if (MY_DEFAULT_NETWORK_TYPE == WF_ADHOC)
putrsUART("AdHoc\r\n");
#elif (MY_DEFAULT_NETWORK_TYPE == WF_P2P)
putrsUART("P2P\r\n");
#elif (MY_DEFAULT_NETWORK_TYPE == WF_INFRASTRUCTURE)
#if (MY_DEFAULT_WIFI_SECURITY_MODE == WF_SECURITY_WPS_PUSH_BUTTON)
putrsUART("Infrastructure (using WPS Push Button)\r\n");
#elif (MY_DEFAULT_WIFI_SECURITY_MODE == WF_SECURITY_WPS_PIN)
putrsUART("Infrastructure (using WPS Pin)\r\n");
#else
putrsUART("Infrastructure\r\n");
#endif
#endif
#endif /* EZ_CONFIG_STORE */
// Retry Count
putrsUART("\tRetries ");
#if (MY_DEFAULT_NETWORK_TYPE == WF_ADHOC)
sprintf(buf, "%d\r\n", ADHOC_RETRY_COUNT);
putsUART(buf);
#elif (MY_DEFAULT_NETWORK_TYPE == WF_INFRASTRUCTURE)
开发者ID:Subaru-PFS,项目名称:ics_xcu_pcm,代码行数:67,代码来源:WFConsoleIwconfig.c
示例15: WaitForMgmtResponse
/*****************************************************************************
* FUNCTION: WaitForMgmtResponse
*
* RETURNS: None
*
* PARAMS: expectedSubtype -- The expected subtype of the mgmt response
* freeAction -- FREE_MGMT_BUFFER or DO_NOT_FREE_MGMT_BUFFER
*
* NOTES: Called after sending a mgmt request. This function waits for a mgmt
* response. The caller can optionally request the the management
* response be freed immediately (by this function) or not freed. If not
* freed the caller is responsible to free the response buffer.
*****************************************************************************/
void WaitForMgmtResponse(UINT8 expectedSubtype, UINT8 freeAction)
{
#if defined(__18CXX)
static tMgmtMsgRxHdr hdr;
#else
tMgmtMsgRxHdr hdr;
#endif
g_WaitingForMgmtResponse = TRUE;
/* Wait until mgmt response is received */
while (gMgmtConfirmMsgReceived == FALSE)
{
WFProcess();
/* if received a data packet while waiting for mgmt packet */
if (g_HostRAWDataPacketReceived)
{
// We can't let the StackTask processs data messages that come in while waiting for mgmt
// response because the application might send another mgmt message, which is illegal until the response
// is received for the first mgmt msg. And, we can't prevent the race condition where a data message
// comes in before a mgmt response is received. Thus, the only solution is to throw away a data message
// that comes in while waiting for a mgmt response. This should happen very infrequently. If using TCP then the
// stack takes care of retries. If using UDP, the application has to deal with occasional data messages not being
// received. Also, applications typically do not send a lot of management messages after connected.
// throw away the data rx
RawMountRxBuffer();
DeallocateDataRxBuffer();
g_HostRAWDataPacketReceived = FALSE;
/* ensure interrupts enabled */
WF_EintEnable();
}
}
/* set this back to FALSE so the next mgmt send won't think he has a response before one is received */
gMgmtConfirmMsgReceived = FALSE;
/* if the caller wants to delete the response immediately (doesn't need any data from it */
if (freeAction == FREE_MGMT_BUFFER)
{
/* read and verify result before freeing up buffer to ensure our message send was successful */
RawRead(RAW_RX_ID, 0, (UINT16)(sizeof(tMgmtMsgRxHdr)), (UINT8 *)&hdr);
/* mgmt response subtype had better match subtype we were expecting */
WF_ASSERT(hdr.subtype == expectedSubtype);
if (hdr.result == WF_ERROR_DISCONNECT_FAILED
|| hdr.result == WF_ERROR_NOT_CONNECTED) {
#if defined(STACK_USE_UART)
putrsUART("Disconnect failed. Disconnect is allowed only when module is in connected state\r\n");
#endif
} else if (hdr.result == WF_ERROR_NO_STORED_BSS_DESCRIPTOR) {
#if defined(STACK_USE_UART)
putrsUART("No stored scan results\r\n");
#endif
} else {
WF_ASSERT(hdr.result == WF_SUCCESS);
}
/* free mgmt buffer */
DeallocateMgmtRxBuffer();
/* if there was a mounted data packet prior to the mgmt tx/rx transaction, then restore it */
if (RestoreRxData == TRUE)
{
RestoreRxData = FALSE;
PopRawWindow(RAW_RX_ID);
SetRawWindowState(RAW_RX_ID, WF_RAW_DATA_MOUNTED);
}
}
}
开发者ID:Subaru-PFS,项目名称:ics_xcu_pcm,代码行数:87,代码来源:WFMgmtMsg.c
示例16: WF_ProcessEvent
/*****************************************************************************
* FUNCTION: WF_ProcessEvent
*
* RETURNS: None
*
* PARAMS: event -- event that occurred
* eventInfo -- additional information about the event. Not all events
* have associated info, in which case this value will be
* set to WF_NO_ADDITIONAL_INFO (0xff)
*
* NOTES: The Host application must NOT directly call this function. This
* function is called by the WiFi Driver code when an event occurs
* that may need processing by the Host CPU.
*
* No other WiFi Driver function should be called from this function, with the
* exception of WF_ASSERT. It is recommended that if the application wishes to be
* notified of an event that it simply set a flag and let application code in the
* main loop handle the event.
*
* WFSetFuncState must be called when entering and leaving this function.
* When WF_ASSERT is enabled this allows a runtime check if any illegal WF functions
* are called from within this function.
*
* For events that the application is not interested in simply leave the
* case statement empty.
*
* Customize this function as needed for your application.
*****************************************************************************/
void WF_ProcessEvent(UINT8 event, UINT16 eventInfo)
{
#if defined(STACK_USE_UART)
char buf[8];
#endif
/* this function tells the WF driver that we are in this function */
WFSetFuncState(WF_PROCESS_EVENT_FUNC, WF_ENTERING_FUNCTION);
switch (event)
{
/*--------------------------------------*/
case WF_EVENT_CONNECTION_SUCCESSFUL:
/*--------------------------------------*/
#if defined(STACK_USE_UART)
putrsUART("Event: Connection Successful\r\n");
#endif
break;
/*--------------------------------------*/
case WF_EVENT_CONNECTION_FAILED:
/*--------------------------------------*/
/* eventInfo will contain value from tWFConnectionFailureCodes */
#if defined(STACK_USE_UART)
putrsUART("Event: Connection Failed -- eventInfo = ");
sprintf(buf, "%d\r\n", eventInfo);
putsUART(buf);
#endif
break;
/*--------------------------------------*/
case WF_EVENT_CONNECTION_TEMPORARILY_LOST:
/*--------------------------------------*/
/* eventInfo will contain value from tWFConnectionLostCodes */
#if defined(STACK_USE_UART)
putrsUART("Event: Connection Temporarily Lost -- eventInfo = ");
sprintf(buf, "%d\r\n", eventInfo);
putsUART(buf);
#endif
break;
/*--------------------------------------*/
case WF_EVENT_CONNECTION_PERMANENTLY_LOST:
/*--------------------------------------*/
/* eventInfo will contain value from tWFConnectionLostCodes */
#if defined(STACK_USE_UART)
putrsUART("Event: Connection Permanently Lost -- eventInfo = ");
sprintf(buf, "%d\r\n", eventInfo);
putsUART(buf);
#endif
break;
/*--------------------------------------*/
case WF_EVENT_CONNECTION_REESTABLISHED:
/*--------------------------------------*/
#if defined(STACK_USE_UART)
putrsUART("Event: Connection Reestablished\r\n");
#endif
break;
/*--------------------------------------*/
case WF_EVENT_SCAN_RESULTS_READY:
/*--------------------------------------*/
#if defined(STACK_USE_UART)
putrsUART("Event: Scan Results Ready,");
sprintf(buf, "%d", eventInfo);
putsUART(buf);
putrsUART("results\r\n");
#endif
#if defined ( EZ_CONFIG_SCAN )
WFScanEventHandler(eventInfo);
#endif /* EZ_CONFIG_SCAN */
//.........这里部分代码省略.........
|
请发表评论