hello
in regards to : e2e.ti.com/.../437134
the issue is not solved, even if i run the program in non debug mode (flash the program through uniflash and reset the device with no sop2)
it is still getting stuck
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
hello
in regards to : e2e.ti.com/.../437134
the issue is not solved, even if i run the program in non debug mode (flash the program through uniflash and reset the device with no sop2)
it is still getting stuck
hello
please try to add LPDS capabilities to the tcp socket, this is what caused the problem, and when i remove the linking (middleware etc) it works
i am attaching the modifications i did and screenshots of the linking
main.c
// Standard includes
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
// driverlib includes
#include "hw_types.h"
#include "hw_ints.h"
#include "hw_memmap.h"
#include "hw_common_reg.h"
//sleep
//#include "hw_apps_rcm.h"
//#include "wdt.h"
//#include "timer_if.h"
//#include "wdt_if.h"
//
#include "interrupt.h"
#include "prcm.h"
#include "rom.h"
#include "rom_map.h"
#include "uart.h"
#include "utils.h"
#include "time.h"
// simplelink includes
#include "simplelink.h"
#include "wlan.h"
// common interface includes
#ifndef NOTERM
#include "uart_if.h"
#endif
#include "udma_if.h"
#include "common.h"
//gpio
//#include "gpio_hal.c"
//#include "gpio_hal.h"
//#include "interrupt_hal.h"
////////////////middleware/////////power managmentframework PM//////////////
#include "cc_types.h"
#include "cc_pm.h"
#include "cc_pm_ops.h"
//////////////////////////////////////OTA////////////////////////////////
#include "flc_api.h"
#include "ota_api.h"
/////////////////////////////////////////////////////////////////////////
//App includes
#include "pinmux.h"
#define APPLICATION_NAME "MyKeeper"
#define APPLICATION_VERSION "1.1.1"
#define IP_ADDR 0x0A00001E /* 10.0.0.30 */
#define PORT_NUM 40000
#define BUF_SIZE 20
#define TCP_PACKET_COUNT 1
#define UartGetChard() MAP_UARTCharGet(DEVICE)
#define UartPutChard(c) MAP_UARTCharPut(DEVICE,c)
#define UartGetChar() MAP_UARTCharGet(CONSOLE)
#define UartPutChar(c) MAP_UARTCharPut(CONSOLE,c)
#define MAX_STRING_LENGTH 6000 //4940 is the number of chars recieved in every batch
//power managment////
#define GPIO_SRC_WKUP PRCM_LPDS_GPIO13
#define WK_LPDS 0 /*Wake from LPDS */
#define APP_SLEEP 0x8
// Application specific status/error codes
typedef enum{
// Choosing -0x7D0 to avoid overlap w/ host-driver's error codes
SOCKET_CREATE_ERROR = -0x7D0,
BIND_ERROR = SOCKET_CREATE_ERROR - 1,
LISTEN_ERROR = BIND_ERROR -1,
SOCKET_OPT_ERROR = LISTEN_ERROR -1,
CONNECT_ERROR = SOCKET_OPT_ERROR -1,
ACCEPT_ERROR = CONNECT_ERROR - 1,
SEND_ERROR = ACCEPT_ERROR -1,
RECV_ERROR = SEND_ERROR -1,
SOCKET_CLOSE_ERROR = RECV_ERROR -1,
DEVICE_NOT_IN_STATION_MODE = SOCKET_CLOSE_ERROR - 1,
STATUS_CODE_MAX = -0xBB8
}e_AppStatusCodes;
//////////////////////////////OTA///////////////////////////////////////
#define OTA_SERVER_NAME "api.dropbox.com"
#define OTA_SERVER_IP_ADDRESS 0x00000000
#define OTA_SERVER_SECURED 1
#define OTA_SERVER_REST_UPDATE_CHK "/1/metadata/auto/" // returns files/folder list
#define OTA_SERVER_REST_RSRC_METADATA "/1/media/auto" // returns A url that serves the media directly
#define OTA_SERVER_REST_HDR "Authorization: Bearer "
#define OTA_SERVER_REST_HDR_VAL "F2A_oo2GSaAAAAAAAAAABpXO8-knU_BWWAv8VreCdAgSLXVqqUm09grmRP1MEfOf"
#define LOG_SERVER_NAME "api-content.dropbox.com"
#define OTA_SERVER_REST_FILES_PUT "/1/files_put/auto/"
#define OTA_VENDOR_STRING "Vid01_Pid00_Ver00"
static OtaOptServerInfo_t g_otaOptServerInfo;
static void *pvOtaApp;
/////////////////////////////////////////////////////////////////////////
//****************************************************************************
// LOCAL FUNCTION PROTOTYPES
//****************************************************************************
int BsdTcpClient(unsigned short usPort);
int BsdTcpServer(unsigned short usPort);
static long WlanConnect();
static void DisplayBanner();
static void BoardInit();
static void InitializeAppVariables();
//*****************************************************************************
// GLOBAL VARIABLES -- Start
//*****************************************************************************
volatile unsigned long g_ulStatus = 0;//SimpleLink Status
unsigned long g_ulGatewayIP = 0; //Network Gateway IP address
unsigned char g_ucConnectionSSID[SSID_LEN_MAX+1]; //Connection SSID
unsigned char g_ucConnectionBSSID[BSSID_LEN_MAX]; //Connection BSSID
unsigned long g_ulDestinationIp = IP_ADDR;
unsigned int g_uiPortNum = PORT_NUM;
volatile unsigned long g_ulPacketCount = TCP_PACKET_COUNT;
unsigned char g_ucConnectionStatus = 0;
unsigned char g_ucSimplelinkstarted = 0;
unsigned long g_ulIpAddr = 0;
char g_cBsdBuf[BUF_SIZE];
char cString[MAX_STRING_LENGTH+1];
char cCharacter;
int iStringLength = 0;
char datatodisplay[30];
#if defined(ccs) || defined (gcc)
extern void (* const g_pfnVectors[])(void);
#endif
#if defined(ewarm)
extern uVectorEntry __vector_table;
#endif
volatile int g_iCounter = 0;
//getting the mac address of the device
unsigned char macAddressVal[SL_MAC_ADDR_LEN];
unsigned char macAddressLen = SL_MAC_ADDR_LEN;
int packetindx=0; //packet counter
int charindx=0; //char counter for every batch
int sockopen=0;
int EOS=0;
int EOBcounter=0; //end of batch counter
int iSockID=-1;
int iStatus=-1;
SlGetRxStatResponse_t RxStatResp; //for rssi
//*****************************************************************************
// GLOBAL VARIABLES -- End
//*****************************************************************************
//*****************************************************************************
// Local Function Prototypes
//*****************************************************************************
extern void lp3p0_setup_power_policy(int power_policy);
extern int platform_init();
extern int set_gpio_as_wk_src(int pwr_mode, unsigned long wk_pin,
unsigned long trigger_type);
extern void set_host_irq_as_lpds_wk_src();
//*****************************************************************************
//
//! Application defined idle task hook
//!
//! \param none
//!
//! \return none
//!
//*****************************************************************************
void SimpleLinkSyncWaitLoopCallback()
{
//
// setting host IRQ as a wake up src
//
set_host_irq_as_lpds_wk_src(true);
//
// executing idle task
//
cc_idle_task_pm();
//
// removing host IRQ as a wake ip src
//
set_host_irq_as_lpds_wk_src(false);
}
//****************************************************************************
//*****************************************************************************
// SimpleLink Asynchronous Event Handlers -- Start
//*****************************************************************************
//*****************************************************************************
//
//! \brief The Function Handles WLAN Events
//!
//! \param[in] pWlanEvent - Pointer to WLAN Event Info
//!
//! \return None
//!
//*****************************************************************************
........
here is the "ConfigureSimpleLinkToDefaultState" which i did not change
//*****************************************************************************
static long ConfigureSimpleLinkToDefaultState()
{
SlVersionFull ver = {0};
_WlanRxFilterOperationCommandBuff_t RxFilterIdMask = {0};
unsigned char ucVal = 1;
unsigned char ucConfigOpt = 0;
unsigned char ucConfigLen = 0;
unsigned char ucPower = 0;
long lRetVal = -1;
long lMode = -1;
lMode = sl_Start(0, 0, 0);
ASSERT_ON_ERROR(lMode);
// If the device is not in station-mode, try configuring it in station-mode
if (ROLE_STA != lMode)
{
if (ROLE_AP == lMode)
{
// If the device is in AP mode, we need to wait for this event
// before doing anything
while(!IS_IP_ACQUIRED(g_ulStatus))
{
#ifndef SL_PLATFORM_MULTI_THREADED
_SlNonOsMainLoopTask();
#endif
}
}
// Switch to STA role and restart
lRetVal = sl_WlanSetMode(ROLE_STA);
ASSERT_ON_ERROR(lRetVal);
lRetVal = sl_Stop(0xFF);
ASSERT_ON_ERROR(lRetVal);
lRetVal = sl_Start(0, 0, 0);
ASSERT_ON_ERROR(lRetVal);
// Check if the device is in station again
if (ROLE_STA != lRetVal)
{
// We don't want to proceed if the device is not coming up in STA-mode
return DEVICE_NOT_IN_STATION_MODE;
}
}
// Get the device's version-information
ucConfigOpt = SL_DEVICE_GENERAL_VERSION;
ucConfigLen = sizeof(ver);
lRetVal = sl_DevGet(SL_DEVICE_GENERAL_CONFIGURATION, &ucConfigOpt,
&ucConfigLen, (unsigned char *)(&ver));
ASSERT_ON_ERROR(lRetVal);
UART_PRINT("Host Driver Version: %s\n\r",SL_DRIVER_VERSION);
UART_PRINT("Build Version %d.%d.%d.%d.31.%d.%d.%d.%d.%d.%d.%d.%d\n\r",
ver.NwpVersion[0],ver.NwpVersion[1],ver.NwpVersion[2],ver.NwpVersion[3],
ver.ChipFwAndPhyVersion.FwVersion[0],ver.ChipFwAndPhyVersion.FwVersion[1],
ver.ChipFwAndPhyVersion.FwVersion[2],ver.ChipFwAndPhyVersion.FwVersion[3],
ver.ChipFwAndPhyVersion.PhyVersion[0],ver.ChipFwAndPhyVersion.PhyVersion[1],
ver.ChipFwAndPhyVersion.PhyVersion[2],ver.ChipFwAndPhyVersion.PhyVersion[3]);
// Set connection policy to Auto + SmartConfig
// (Device's default connection policy)
lRetVal = sl_WlanPolicySet(SL_POLICY_CONNECTION,
SL_CONNECTION_POLICY(1, 0, 0, 0, 1), NULL, 0);
ASSERT_ON_ERROR(lRetVal);
// Remove all profiles
lRetVal = sl_WlanProfileDel(0xFF);
ASSERT_ON_ERROR(lRetVal);
//
// Device in station-mode. Disconnect previous connection if any
// The function returns 0 if 'Disconnected done', negative number if already
// disconnected Wait for 'disconnection' event if 0 is returned, Ignore
// other return-codes
//
lRetVal = sl_WlanDisconnect();
if(0 == lRetVal)
{
// Wait
while(IS_CONNECTED(g_ulStatus))
{
#ifndef SL_PLATFORM_MULTI_THREADED
_SlNonOsMainLoopTask();
#endif
}
}
// Enable DHCP client
lRetVal = sl_NetCfgSet(SL_IPV4_STA_P2P_CL_DHCP_ENABLE,1,1,&ucVal);
ASSERT_ON_ERROR(lRetVal);
// Disable scan
ucConfigOpt = SL_SCAN_POLICY(0);
lRetVal = sl_WlanPolicySet(SL_POLICY_SCAN , ucConfigOpt, NULL, 0);
ASSERT_ON_ERROR(lRetVal);
// Set Tx power level for station mode
// Number between 0-15, as dB offset from max power - 0 will set max power
ucPower = 0;
lRetVal = sl_WlanSet(SL_WLAN_CFG_GENERAL_PARAM_ID,
WLAN_GENERAL_PARAM_OPT_STA_TX_POWER, 1, (unsigned char *)&ucPower);
ASSERT_ON_ERROR(lRetVal);
// Set PM policy to normal
lRetVal = sl_WlanPolicySet(SL_POLICY_PM , SL_NORMAL_POLICY, NULL, 0);
ASSERT_ON_ERROR(lRetVal);
// Unregister mDNS services
lRetVal = sl_NetAppMDNSUnRegisterService(0, 0);
ASSERT_ON_ERROR(lRetVal);
// Remove all 64 filters (8*8)
memset(RxFilterIdMask.FilterIdMask, 0xFF, 8);
lRetVal = sl_WlanRxFilterSet(SL_REMOVE_RX_FILTER, (_u8 *)&RxFilterIdMask,
sizeof(_WlanRxFilterOperationCommandBuff_t));
ASSERT_ON_ERROR(lRetVal);
lRetVal = sl_Stop(SL_STOP_TIMEOUT);
ASSERT_ON_ERROR(lRetVal);
InitializeAppVariables();
return lRetVal; // Success
}
//****************************************************************************
...........................
this function i changed
int BsdTcpClient(unsigned short usPort)
{
/* clock_t start;
clock_t end;
double cpu_time_used;
start = clock();
end = clock();
cpu_time_used = ((double) (end-start)) / CLOCKS_PER_SEC;
*/
//////////entering low power deep sleep/////////////
// UART_PRINT("entering LPDS:\n\r");
// MAP_UtilsDelay(80000);
// MAP_PRCMDeepSleepEnter();
// UART_PRINT("exiting LPDS:\n\r");
// MAP_UtilsDelay(80000);
//////////exiting low power deep sleep/////////////
SlSockAddrIn_t sAddr;
int iAddrSize;
long lLoopCount = 0;
int i=0;
iStringLength=0;
cCharacter='q';
cString[0]='\0';
datatodisplay[0]='\0';
charindx=0;
EOS=0;
EOBcounter=0;
//concat the device's mac address
strcpy(cString,macAddressVal);
iStringLength=macAddressLen;
//concat the WAP's mac address
strcat(cString,g_ucConnectionBSSID);
iStringLength += BSSID_LEN_MAX;
packetindx=packetindx+1;
iStringLength= iStringLength+1;
cString[iStringLength-1]=packetindx;
cString[iStringLength]='\0';
UART_PRINT("recieving data:\n\r");
while (iStringLength < (MAX_STRING_LENGTH) && EOS==0)
{
// recieving chars from uart device
cCharacter = UartGetChard();
if (cCharacter=='!')
EOBcounter++;
else
EOBcounter=0;
charindx=charindx+1;
cString[iStringLength] = cCharacter;
iStringLength++;
if (EOBcounter==33)
{
EOS=1;
UART_PRINT("\n\rPACKET END\n\r");
UART_PRINT("\n\rPACKET END\n\r");
UART_PRINT("\n\rPACKET END\n\r");
UART_PRINT("\n\rPACKET END\n\r");
UART_PRINT("\n\rPACKET END\n\r");
UART_PRINT("\n\rPACKET END\n\r");
}
}
cString[iStringLength] = '\0';
UART_PRINT("\n\rSending TCP packets...\n\r");
//filling the TCP server socket address
sAddr.sin_family = SL_AF_INET;
sAddr.sin_port = sl_Htons((unsigned short)usPort);
sAddr.sin_addr.s_addr = sl_Htonl((unsigned int)g_ulDestinationIp);
iAddrSize = sizeof(SlSockAddrIn_t);
// creating a TCP socket
if (iSockID<0)
{
iSockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, 0);
if( iSockID < 0 )
{
ASSERT_ON_ERROR(SOCKET_CREATE_ERROR);
}
else
UART_PRINT(" socket created \n\r");
}
sl_WlanRxStatStart();// start collecting Rx Statistics data
// connecting to TCP server
if (iStatus<0)
{
iStatus = sl_Connect(iSockID, ( SlSockAddr_t *)&sAddr, iAddrSize);
if( iStatus < 0 )
{
// error
sl_Close(iSockID);
ASSERT_ON_ERROR(CONNECT_ERROR);
}
else
UART_PRINT(" connection established \n\r");
}
// sending multiple packets to the TCP server
while (lLoopCount < g_ulPacketCount)
{
// sending packet
iStatus = sl_Send(iSockID,cString , iStringLength, 0 );
if( iStatus < 0 )
{
// error
sl_Close(iSockID);
ASSERT_ON_ERROR(SEND_ERROR);
}
lLoopCount++;
}
iStatus = sl_Recv(iSockID,datatodisplay , sizeof(datatodisplay), 0 );
sl_WlanRxStatStop ();// stop collecting Rx Statistics data
Report("Sent %u packets successfully\n\r",g_ulPacketCount);
UART_PRINT(" packet number %d \n\r" ,packetindx );
UART_PRINT(" number of chars revieved %d \n\r" ,charindx );
UART_PRINT(" end of batch counter %d \n\r" ,EOBcounter );
UART_PRINT(" end of batch %d \n\r" ,EOS );
UART_PRINT(" \n\n\n\n\r" );
// iStatus = sl_Close(iSockID);
//closing the socket after sending 1000 packets
//ASSERT_ON_ERROR(iStatus);
//rssi read
sl_WlanRxStatGet(&RxStatResp,0);// Read statistics
// printf("\n\n*********************************Rx Statistics**********************************\n\n");
UART_PRINT("Received Packets: %d\n\r",RxStatResp.ReceivedValidPacketsNumber);
UART_PRINT("Average Rssi for management: %d\n\r Average Rssi for other packets: %d\n\r",RxStatResp.AvarageMgMntRssi,RxStatResp.AvarageDataCtrlRssi);
//////////////////signaling the watch that the wifi transmittion has ended
for (i=0; i<30; i++)
{
UartPutChard('E');
}
/////////////////////device is going to LOW POWER DEEP SLEEP///////////
lp3p0_setup_power_policy(POWER_POLICY_STANDBY);
cc_idle_task_pm(); //starting the PM tasks
///////////////////device has woken up/////////////////////////////////
////////////////////////////////signaling device is ready to recieve/////////////////////
for (i=0; i<30; i++)
{
UartPutChard('R');
}
return SUCCESS;
}
....................................
and this is the main
//****************************************************************************
// MAIN FUNCTION
//****************************************************************************
void main()
{
long lRetVal = -1;
_u16 PolicyBuff[4] = {0,0,800,0}; // PolicyBuff[2] is max sleep time in mSec
//////////////////gpio wake up source////////////////////////////
set_gpio_as_wk_src(0, GPIO_SRC_WKUP, PRCM_LPDS_RISE_EDGE);
// cc_hndl tGPIOHndl = cc_gpio_open(GPIO_SRC_WKUP, GPIO_DIR_INPUT);
//cc_gpio_enable_notification(tGPIOHndl, GPIO_SRC_WKUP, INT_BOTH_EDGE, (GPIO_TYPE_NORMAL | GPIO_TYPE_WAKE_SOURCE));
//
// Board Initialization
//
BoardInit();
//
// Initialize the uDMA
//
UDMAInit();
//
// Configure the pinmux settings for the peripherals exercised
//
PinMuxConfig();
// Initialize the platform
//
//
platform_init();
// Configuring UART
//
InitTerm();
//
// Display banner
//
DisplayBanner(APPLICATION_NAME);
InitializeAppVariables();
MAP_UtilsDelay(80000);
//
// Following function configure the device to default state by cleaning
// the persistent settings stored in NVMEM (viz. connection profiles &
// policies, power policy etc)
//
// Applications may choose to skip this step if the developer is sure
// that the device is in its default state at start of applicaton
//
// Note that all profiles and persistent settings that were done on the
// device will be lost
//
lRetVal = ConfigureSimpleLinkToDefaultState();
if(lRetVal < 0)
{
if (DEVICE_NOT_IN_STATION_MODE == lRetVal)
UART_PRINT("Failed to configure the device in its default state \n\r");
// LOOP_FOREVER();
}
UART_PRINT("Device is configured in default state \n\r");
//
// Asumption is that the device is configured in station mode already
// and it is in its default state
//
lRetVal = sl_Start(0, 0, 0);
if (lRetVal < 0)
{
UART_PRINT("Failed to start the device \n\r");
// LOOP_FOREVER();
}
UART_PRINT("Device started as STATION \n\r");
///// set wlan power policy///////
sl_WlanPolicySet(SL_POLICY_PM , SL_LONG_SLEEP_INTERVAL_POLICY, (_u8*)PolicyBuff,sizeof(PolicyBuff));
UART_PRINT("Connecting to AP: %s ...\r\n",SSID_NAME);
// Connecting to WLAN AP - Set with static parameters defined at common.h
// After this call we will be connected and have IP address
lRetVal = WlanConnect();
if(lRetVal < 0)
{
UART_PRINT("Connection to AP failed \n\r");
// LOOP_FOREVER();
}
UART_PRINT("Connected to AP: %s \n\r",SSID_NAME);
UART_PRINT("Device IP: %d.%d.%d.%d\n\r\n\r",
SL_IPV4_BYTE(g_ulIpAddr,3),
SL_IPV4_BYTE(g_ulIpAddr,2),
SL_IPV4_BYTE(g_ulIpAddr,1),
SL_IPV4_BYTE(g_ulIpAddr,0));
sl_NetCfgGet(SL_MAC_ADDRESS_GET,NULL,&macAddressLen,(unsigned char *)macAddressVal);
UART_PRINT("\n\rDevice mac address: %x",macAddressVal[0]);
UART_PRINT("-%x",macAddressVal[1]);
UART_PRINT("-%x",macAddressVal[2]);
UART_PRINT("-%x",macAddressVal[3]);
UART_PRINT("-%x",macAddressVal[4]);
UART_PRINT("-%x\n\r\n\r",macAddressVal[5]);
#ifdef USER_INPUT_ENABLE
lRetVal = UserInput();
if(lRetVal < 0)
{
ERR_PRINT(lRetVal);
// LOOP_FOREVER();
}
#else
lRetVal = BsdTcpClient(PORT_NUM);
if(lRetVal < 0)
{
UART_PRINT("TCP Client failed\n\r");
// LOOP_FOREVER();
}
lRetVal = BsdTcpServer(PORT_NUM);
if(lRetVal < 0)
{
UART_PRINT("TCP Server failed\n\r");
// LOOP_FOREVER();
}
#endif
UART_PRINT("Exiting Application ...\n\r");
//
// power of the Network processor
//
lRetVal = sl_Stop(SL_STOP_TIMEOUT);
while (1)
{
_SlNonOsMainLoopTask();
}
}
//*****************************************************************************
//
// Close the Doxygen group.
//! @}
//
//*****************************************************************************
basically the app reads a string from the uart pins and when it reaches an end string (33X!) it send the string to the tcp server
in what configuration are you using?
i did not change it from what is defaulte when i loaded the tcp socket example
maybe that is the problem?
do i need to change it to non_os_pm ?
please advise,
do i need to change the config to simplelink->non_os_pm or can you just tell me what configuration to change in the tcp_socket example
roi
hi
as you can see in the pics i attached, all of the configuration you mentioned i have already done, i duplicated all the configuration from the non os pm configuration but it is still not working
a different thing that i tried is in the manage configuration i did a new configuration and imported the non_os_pm from project "idle_profile_non_os"
when i tried to change the configuration to non_os_pm i did not see that i have a linker tab as you can see in the pic below