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.

CC3220SF-LAUNCHXL: opening a socket in AP mode

Part Number: CC3220SF-LAUNCHXL
Other Parts Discussed in Thread: CC3220SF

Hello,

I try to open a socket when the device is in AP mode. I have the error

while(!IS_IP_LEASED(OutOfBox_ControlBlock.status));

iSockID = sl_Socket(SL_AF_INET, SL_SOCK_STREAM, SL_IPPROTO_TCP);

iSockID is SL_RET_CODE_DEV_NOT_STARTED at the end, although NWP should have started since an IP is leased.

  • Hi,

    Did you see event (message in log) when your client is connected to AP in CC3220? Did you see log from event SL_NETAPP_EVENT_IPV4_ACQUIRED?

    Jan
  • Yes, I can see it. Here is the log
    [Provisioning task] Wake up on Power ON

    [Provisioning task] detected device is CC3220SF

    [Provisioning task] Cannot connect to AP or profile does not exist

    [NETAPP EVENT] IP Acquired: IP=10.123.45.1 , Gateway=10.123.45.1

    [Provisioning task] Device is configured in default state

    [Provisioning task] Device started in AP role

    [NETAPP EVENT] IP Acquired: IP=10.123.45.1 , Gateway=10.123.45.1

    [Provisioning task] Host Driver Version: 2.0.1.19

    [Provisioning task] Build Version 3.4.0.0.31.2.0.0.0.2.2.0.5

    [Provisioning task] Starting Provisioning - [Provisioning task] in mode 2 (0 = AP, 1 = SC, 2 = AP+SC)
    [Provisioning task] Provisioning Started. Waiting to be provisioned..!!
    [WLAN EVENT] Provisioning stopped
    [WLAN EVENT] External Station connected to SimpleLink AP
    [WLAN EVENT] STA BSSID: 0c:84:dc:62:68:c8
    [NETAPP EVENT] IPv4 leased 10.123.45.2 for device xx:xx:xx:xx:xx:xx (I've changed data to xx in the forum post)
  • Hi,

    This behaviour not make me sense. Are you sure that you somewhere inside your code not call sl_Stop()?

    Jan
  • there is no call to sl_Stop, and the embedded web server is still working
  • Hi,

    It looks that you are using old SDK with old ServicePack (1.40). Can you update to latest version SDK and latest service pack and check again?

    Jan
  • CHIP: 0x30000019

    MAC: 2.0.0.0

    PHY: 2.2.0.6

    NWP: 3.6.0.3

    ROM: 0

    HOST: 2.0.1.26

    MAC address: 98:84:e3:4f:9a:ac


    ============================================


    [Provisioning task] Wake up on Power ON

    [NETAPP EVENT] IP Acquired: IP=10.123.45.1 , Gateway=10.123.45.1

    [WLAN EVENT] External Station connected to SimpleLink AP
    [WLAN EVENT] STA BSSID: 0c:84:dc:62:68:c8
    [NETAPP EVENT] IPv4 leased 10.123.45.2 for device xxxxxxx

    The same thing appends
  • Hi,

    I am really not sure want you can have wrong in your code. Maybe you can add NWP restart /sl_Stop(), sl_Start()/ into your connection code before your client is connected.

    Jan
  • That doesn't change anything...

    The fact is it works properly when the TCP server is started after provisionning.

    I've started my work from the out-of-box project. 

    I've spawned a new task in the mainThread, the code of the task is

    _i16 iSockID;
    _i16 iClientSID;
    _i16 Status;
    SlSockAddrIn_t Addr;
    _i8 tcpRxBuffer[50];
    
    _char tcpTxBuffer[]="Server started\r\n";
    
    //  sem_wait(&Provisioning_ControlBlock.provisioningDoneSignal);
    while(!IS_IP_LEASED(OutOfBox_ControlBlock.status));
    
    iSockID = sl_Socket(SL_AF_INET, SL_SOCK_STREAM, SL_IPPROTO_TCP);
    
    Addr.sin_family = SL_AF_INET;
    Addr.sin_port = sl_Htons(1234);
    Addr.sin_addr.s_addr = SL_INADDR_ANY;
    
    Status = sl_Bind(iSockID, (SlSockAddr_t *)&Addr, sizeof(SlSockAddrIn_t));
    Status = sl_Listen(iSockID, 1);
    iClientSID = 0;
    while(iClientSID==0)
      iClientSID = sl_Accept(iSockID, (SlSockAddr_t *)&Addr, sizeof(SlSockAddrIn_t));
    Status = sl_SendTo(iSockID, tcpTxBuffer, strlen(tcpTxBuffer), 0, (SlSockAddr_t*)&Addr,sizeof(SlSockAddr_t));
    Status = 0;
    while((Status==0)||(killUserIDServer==1)){
      Status = sl_Recv(iClientSID, tcpRxBuffer, 5, 0);
    
    Status = sl_Close(iSockID);
    while(1);

    if the semwait instruction is uncommented, it works properly, of course in station rule.

  • Hi,

    When NWP is in provisioning mode sl_ APIs are blocked (see comment from Ben at e2e.ti.com/.../2274796 ).

    Jan
  • Ok thanks that resolved the issue.