Wi-Fi Combo Forum Discussions
Hi.
I am having problems reconnecting upon an disconnect.
I am using WICED_SDK_3.5.1 and using secure MQTT (i.e. over TLS).
static wiced_result_t mqtt_connection_event_cb( wiced_mqtt_object_t mqtt_object, wiced_mqtt_event_info_t *event )
{
switch ( event->type )
{
:
case WICED_MQTT_EVENT_TYPE_DISCONNECTED:
{
if(reconnecting != WICED_TRUE) {
printf("Uh-Oh, I got disconnected in %s...\n", __FUNCTION__);
expected_event = event->type;
wiced_rtos_set_semaphore( &msg_semaphore );
reconnecting = WICED_TRUE;
iot_mqtt_connect();
}
}
break;
:
:
}
static void iot_aws_mqtt_reconnect()
{
mqtt_conn_close( mqtt_object );
mqtt_app_unsubscribe( mqtt_object, DELTA_TOPIC );
wiced_rtos_deinit_semaphore( &msg_semaphore );
WPRINT_APP_INFO(("[MQTT] Deinit connection in %s...\n", __FUNCTION__));
wiced_mqtt_deinit( mqtt_object );
wiced_rtos_deinit_semaphore( &wake_semaphore );
free( mqtt_object );
mqtt_object = NULL;
iot_mqtt_connect();
}
void iot_mqtt_connect( void )
{
wiced_result_t ret = WICED_SUCCESS;
uint32_t size_out = 0;
int connection_retries = 0;
int retries = 0;
int count = 0;
char* msg = SHADOW_PUBLISH_INVERTER_OFF;
/* Get AWS root certificate, client certificate and private key respectively */
ret = resource_get_readonly_buffer( &resources_apps_DIR_secure_mqtt_DIR_TestSolPadThing_DIR_rootCA_pem, 0, MQTT_MAX_RESOURCE_SIZE, &size_out, (const void **) &security.ca_cert );
ret = resource_get_readonly_buffer( &resources_apps_DIR_secure_mqtt_DIR_TestSolPadThing_DIR_cert_pem, 0, MQTT_MAX_RESOURCE_SIZE, &size_out, (const void **) &security.cert );
if(size_out < 64)
{
WPRINT_APP_INFO( ( "\nNot a valid Certificate! Please replace the dummy certificate file 'resources/app/aws_iot/client.cer' with the one got from AWS\n\n" ) );
return;
}
ret = resource_get_readonly_buffer( &resources_apps_DIR_secure_mqtt_DIR_TestSolPadThing_DIR_privKey_pem, 0, MQTT_MAX_RESOURCE_SIZE, &size_out, (const void **) &security.key );
if(size_out < 64)
{
WPRINT_APP_INFO( ( "\nNot a valid Private Key! Please replace the dummy private key file 'resources/app/aws_iot/privkey.cer' with the one got from AWS\n\n" ) );
return;
}
/* Disable roaming to other access points */
wiced_wifi_set_roam_trigger( -99 ); /* -99dBm ie. extremely low signal level */
/* Bring up the network interface */
ret = wiced_network_up( WICED_STA_INTERFACE, WICED_USE_EXTERNAL_DHCP_SERVER, NULL );
if ( ret != WICED_SUCCESS )
{
WPRINT_APP_INFO( ( "\nNot able to join the requested AP in %s...\n", __FUNCTION__));
return;
}
/* json register parser */
wiced_JSON_parser_register_callback(parse_json_control_message);
/* Allocate memory for MQTT object*/
mqtt_object = (wiced_mqtt_object_t) malloc( WICED_MQTT_OBJECT_MEMORY_SIZE_REQUIREMENT );
if ( mqtt_object == NULL )
{
WPRINT_APP_ERROR(("Dont have memory to allocate for mqtt objectin %s...\n", __FUNCTION__));
return;
}
WPRINT_APP_INFO( ( "Resolving IP address of MQTT broker in %s...\n", __FUNCTION__));
ret = resolve_dns_to_ip(MQTT_BROKER_ADDRESS, &broker_address);
if ( ret == WICED_ERROR || broker_address.ip.v4 == 0 )
{
WPRINT_APP_INFO(("Error in resolving DNS in %s...\n", __FUNCTION__));
return;
}
wiced_rtos_init_semaphore( &wake_semaphore );
wiced_mqtt_init( mqtt_object );
wiced_rtos_init_semaphore( &msg_semaphore );
do
{
WPRINT_APP_INFO(("[MQTT] Opening connection in %s...\n", __FUNCTION__));
do
{
ret = mqtt_conn_open( mqtt_object, &broker_address, WICED_STA_INTERFACE, mqtt_connection_event_cb, &security );
connection_retries++ ;
} while ( ( ret != WICED_SUCCESS ) && ( connection_retries < WICED_MQTT_CONNECTION_NUMBER_OF_RETRIES ) );
if ( ret != WICED_SUCCESS )
{
WPRINT_APP_INFO(("Failed in %s...\n", __FUNCTION__));
reconnecting = WICED_TRUE;
return;
}
WPRINT_APP_INFO(("Success in %s...\n", __FUNCTION__));
reconnecting = WICED_FALSE;
WPRINT_APP_INFO(("[MQTT] Subscribing in %s...\n", __FUNCTION__));
do
{
ret = mqtt_app_subscribe( mqtt_object, DELTA_TOPIC, WICED_MQTT_QOS_DELIVER_AT_MOST_ONCE );
retries++ ;
} while ( ( ret != WICED_SUCCESS ) && ( retries < MQTT_SUBSCRIBE_RETRY_COUNT ) );
if ( ret != WICED_SUCCESS )
{
failed_subscribe = WICED_TRUE;
return;
}
/* configure push button to publish a message */
wiced_gpio_input_irq_enable( WICED_BUTTON1, IRQ_TRIGGER_RISING_EDGE, publish_callback, NULL );
while ( reconnecting != WICED_TRUE )
{
wiced_rtos_get_semaphore( &wake_semaphore, WICED_NEVER_TIMEOUT );
if ( pub_in_progress == 1 )
{
WPRINT_APP_INFO(("[MQTT] Publishing in %s...\n", __FUNCTION__));
if ( count % 2 )
{
msg = SHADOW_PUBLISH_INVERTER_ON;
}
else
{
msg = SHADOW_PUBLISH_INVERTER_OFF;
}
do
{
ret = mqtt_app_publish( mqtt_object, WICED_MQTT_QOS_DELIVER_AT_LEAST_ONCE, (uint8_t*) STATE_TOPIC, (uint8_t*) msg, strlen( msg ) );
retries++ ;
} while ( ( ret != WICED_SUCCESS ) && ( retries < MQTT_PUBLISH_RETRY_COUNT ) );
if ( ret != WICED_SUCCESS )
{
WPRINT_APP_INFO((" Failed in %s...\n", __FUNCTION__));
failed_publish = WICED_TRUE;
return;
}
else
{
WPRINT_APP_INFO((" Success in %s...\n", __FUNCTION__));
}
pub_in_progress = 0;
count++ ;
}
wiced_rtos_delay_milliseconds( 100 );
}
wiced_rtos_delay_milliseconds( MQTT_DELAY_IN_MILLISECONDS * 2 );
} while ( reconnecting != WICED_TRUE );
}
Show LessHi
We found once the BLE transmit speed is not less than 5KB/s, the UART connection between the central device and PC will be lost.
Steps
1. Two 43438 device will be used on my test, one works as central device, another works as peripheral device.
2. Let PC connect the central device by serial port.
3. PC will send the data the central device, then the central device will send the data to peripheral device by BLE.
BTW: bt_ble_master_send_data will be used when the central device send the data to peripheral device by BLE.
Results:
When the BLE transmit speed is not less than 5KB/s, in a few minutes the UART connection between the central device and PC will be lost .
We use GDB to debug this. We can see the function relation when error happens. Please refer to gatt_write_trace.jpg attached.
The project information are below:
WICED SDK version :WICED3.6;
Module:BCM43438;
OS:FreeRtos
Show LessWICED SDK 3.3.1 snip.tftp app test result is ok.
But, SDK 3.5.2 sntp.tftp app test result is not ok.
SDK 3.3.1 tftp app run -> tftp server connect-> download binary -> download complete -> reboot -> update
SDK 3.5.2 tftp app run -> tftp server connect-> download binary timeout error.-> tftp is not work.
Show LessModule: 4343W
When joining an AP named CDW530AM, the return of host_rtos_get_semaphore is WWD_TIMEOUT, please refer the screenshot attached. The relevant code is below(WICED-SDK\WICED\WWD\internal\wwd_sdpcm.c):
/* Wait till response has been received */
retval = host_rtos_get_semaphore( &wwd_sdpcm_ioctl_sleep, (uint32_t) WWD_IOCTL_TIMEOUT_MS, WICED_FALSE );
if ( retval != WWD_SUCCESS )
{
/* Release the mutex since wwd_sdpcm_ioctl_response will no longer be referenced. */
host_rtos_set_semaphore( &wwd_sdpcm_ioctl_mutex, WICED_FALSE );
return retval;
}
The sniffer log named filter_with_mac_addr_60f1893e7335.pcap is also attached.
However this issue is only met on this type Access point, the failed rate is also not 100% on this type Access point.
More information about the wireshark packet:
1) mac address of client: 60:f1:89:3e:73:35 ;
2) mac address of AP: 00:50:18:5d:ff:62;
3) encryption type: WPA2_AES;
3) the ssid/password is "TestBench/TestBench";
4) channel is 1;
5) wpa psk is "caf739524381fd60b3229a7093b9164aed3f0e94c04a9ef08b3245f0a466d0a0"
thanks,
Hanson
Show Less
Hi all,
We try to certicate our product by an EMC laboratory and this laboratory asks to genarate this radio mode :
We use the USI module and to realize the software, I've took the snip.console example compiled with the WL commands, to generate the different mode with the following command :
But each time, I execute the pkteng_start command, I've the result “wl unsupported”.
So my question is how to realize the demand of the laboratory ?
Thank you for your help.
Baptiste
Show LessHello all,
I am working with the Cypress BCM4343 and the Avnet IoT Starter Kit. My environment is all setted up and I already did several demos with this development kit.
I was wondering if there is some kind of SDK documentation. I know that the SDK has MANY resources, but I couldn't find any documentation about them.
Does someone know where I can find this documentation?
Best Regards.
Show LessUsing 3.5.2 SDK
In dct_read_write.c
WPRINT_APP_INFO( ( "Modifying Single byte in App Section \r\n" ) );
/* Modify single byte value - test sflash single-byte writes */
app_dct->uint8_var = 0x22;
wiced_dct_write( (const void*) app_dct, DCT_APP_SECTION, 0, sizeof(uint8_t) );
WPRINT_APP_INFO( ( "Modifying uint32_t value at odd offset in App Section \r\n" ) );
/* Modify single byte value - test sflash uint32_t on a non-4-byte-boundary writes */
app_dct->uint32_var = 0x22;
wiced_dct_write( (const void*) app_dct, DCT_APP_SECTION, 0, sizeof(uint32_t) );
The assignment app_dct->uint32_var = 0x22 does not seem to work.
I printed the value right after the assignment and it does not show up correctly (the value still shows up as 99999999 )
Not able to figure out why.
Also the variable definition earlier on in the file is incorrect.
CONFIG_UINT32_DATA and CONFIG_UINT8_DATA are swapped.
But correcting this did not help either.
Show Lessstatic const configuration_entry_t app_config[] =
{
{"uint8_var ", DCT_OFFSET(dct_read_write_app_dct_t, uint8_var ), 4, CONFIG_UINT32_DATA },
{"uint32_var", DCT_OFFSET(dct_read_write_app_dct_t, uint32_var), 4, CONFIG_UINT8_DATA },
{"string_var", DCT_OFFSET(dct_read_write_app_dct_t, string_var), 50, CONFIG_STRING_DATA },
{0,0,0,0}
};
Dear support,
I will use the BCM4343W IOT starter kit based on BCM4343W and STM32F411 MCU. This kit is enable to talk with cloud service. By the way, my needs is to use a simple wifi connection with an external access Point. Do you have any simple example or application already developed that eable the IoT module to accept simple AT command or something like that?
Thanks,
Giordano
Show LessHello,
I am trying to connect Eval. Board via IOS client over TCP and I am using tcp_server_async snip in WICED 3.5.2. I used a Java script, but I m taking 7014 from wiced_tcp_accept() function all the time.
Java script:
System.out.println("Connecting...");
Socket socket = new Socket(host, port);
PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
System.out.println("Connected");
out.print(msg);
out.flush();
int chr;
int len = 0;
while ((chr = in.read()) != -1) {
System.out.print((char) chr);
if (++len == msg.length()) {
System.out.println();
break;
}
}
socket.close();
Is there any comment or solution for this situation.
Thank you,
Oguz.
Show LessI'm trying to find examples of using websockets with WICED-SDK-3.7.0 (module EMW3165, freeRTOS, LwIP). Are there any examples I can check out to wrap my head around implementing websockets?
Show Less