With Google's reinforced security measures, there are a few settings you need to change in order to use the email app successfully with a gmail account.
In /apps/snip/email/email.c,
1. Change the RECIPIENT to your personal email account that you want to receive the message in. This does not have to be a gmail account.
2. In the send_email() function within the same file (line 121), you will have to change the following to your own gmail account. Other email providers can be used for this but may have additional security measures. We have verified the process for gmail accounts so we advise that you do the same.
1) account.email_address
2) account.user_name
3) account.password
**Previously we have provided an email account as default to use as the sender, but with the increased gmail security measures it will no longer be possible to use this account.
3. If you try running the program after the first two modifications you will get a notification email from google that they blocked a sign-in attempt to your Google account. You will have to login to your account and change your settings at the following link to allow access for less secure apps.
https://www.google.com/settings/security/lesssecureapps
4. You will also have to allow access to the new device from an already proven device(laptop, phone) on this link.
https://accounts.google.com/DisplayUnlockCaptcha
Press Continue and it will show the following.
5. In most cases the above steps should be sufficient. In the case you have the 2-step verification enabled on your account, you will have to generate a separate password in the below link.
https://support.google.com/accounts/troubleshooter/3141849#ts=3202254
6. Once you have gone through these settings you should be able to send an email to your account successfully.
This application snippet demonstrates the I2C device interface using WICED SDK-3.x.
The sample application sets up the I2C device interface and send commands to the I2C device then receives replies, if any, from the I2C device.
For this example "BlinkM - I2C Controlled RGB LED" (www.sparkfun.com/products/8579) I2C device is used to test the code. It could be any other I2C device chosen for your platform as well.
For BCM943362WCD4 evaluation platform update the platform.c and platform.h files for I2C device.
Update the .../platforms/BCM943362WCD4/platform.c file by adding the following changes to the file:
const platform_i2c_t platform_i2c_peripherals[] =
{
[WICED_I2C_1] =
{
.port = I2C1,
.pin_scl = &platform_gpio_pins[WICED_GPIO_11],
.pin_sda = &platform_gpio_pins[WICED_GPIO_12],
.peripheral_clock_reg = RCC_APB1Periph_I2C1,
.tx_dma = DMA1,
.tx_dma_peripheral_clock = RCC_AHB1Periph_DMA1,
.tx_dma_stream = DMA1_Stream7,
.rx_dma_stream = DMA1_Stream0,
.tx_dma_stream_id = 7,
.rx_dma_stream_id = 0,
.tx_dma_channel = DMA_Channel_1,
.rx_dma_channel = DMA_Channel_1,
.gpio_af = GPIO_AF_I2C1
}
};
For platforms/BCM943362WCD4/platform.h file add the WICED_I2C_1 to the wiced_i2c_t as below:
typedef enum
{
WICED_I2C_1,
WICED_I2C_MAX,
WICED_I2C_32BIT = 0x7FFFFFFF,
} wiced_i2c_t;
The platform files for BCM943362WCD4 are attached.
For BCM943341WCD1 I2C device of WICED_I2C_1 is already defined in the platform files. For completeness the platform files are attached. The I2C device of WICED_I2C_1 for BCM943362WCD1 is already defined in the platform files. For completeness the platform files are attached.
Your application specific platform files can be updated as above to interface the chosen I2C device to the WICED SDK 3.x platform.
1. To run the test, connect the I2C device to the evaluation board as following:
Connection setup for I2C device to STM32F4xx based WICED evaluation board
I2C-Device BCM943341WCD1 J7 Header
- J7-27
+ J7-28
SDA J7-26
SCL J7-25
Connection setup for I2C device to STM32F2xx based WICED evaluation board
I2C-Device BCM943362WCD4 J7 Header
- J7-2
+ J7-1
SDA J7-7
SCL J7-6
2. Unzip and copy the attached files to the WICED SDK-3.x version.
For I2C LED application snippet:
Copy the content of the i2c_led.7z source to .../apps/snip/i2c_led
For BCM943362WCD4:
Copy the content of the BCM943362WCD4.7z source to .../platforms/BCM943362WCD4
For BCM943341WCD1:
Copy the content of the BCM943341WCD1.7z source to .../platforms/BCM943341WCD1
3. To build, download and run the application below
For STM32F4xx MCU BCM943341WCD1:
snip.i2c_led-BCM943341WCD1-debug download run
For STM32F2xx MCU BCM943362WCD4:
snip.i2c_led-BCM943362WCD4-debug download run
This is the modified STM32F4xx MCU BCM943341WCD1 WICED evaluation board:
NOTE: There are no hardware nor platform file changes needed on the BCM943341WCD1 evaluation because the already defined I2C lines ,with pull-up resistors, are used.
This is the modified STM32F2xx MCU BCM943362WCD4 Wiced evaluation board:
NOTE: On BCM943362WCD4 evaluation board, SDA and SCL signals needs 4.7K pull up resistors.
Show LessThe BCM2073x chip (SoC) has 40 logical GPIOs (P0-P39).
The GPIOs themselves are broken out into three separate ports (meaningful when you start programming):
• P0 through P15 on port0
• P16 through P31 on port1
• P32 through P39 on port2
The 32 pin package (i.e. the SoC - BCM20736 and BCM20737 *without* the S) only brings out 14 of the 40 logical GPIOs. The System in Package/SIP (the BCM20736S and BCM20737S modules) follows the SoC closely with regards to which pins are brought out (but there is a slight difference) and these are what you see in the SIP module datasheets.
Since the 32 pin package (SoC) and the modules are pin-limited, some of the logical GPIOs within the SoC are multi-bonded before bringing them out on the balls on the chip.
For the 32 pin package, the following pins are bonded in this manner:
Very Important Note: The SOC packaged part described above is not used for the SIP module. The SIP uses the raw die and wirebonds it differently than the DFN part, so the IOs described above for the SoC are not bonded together from the die - they are bonded together on the DFN wirebond package.
Always refer to the BCM20737S Bluetooth Low Energy SiP Module Technical Reference for the bonding/alternate function information relevant to the SIP modules, not the BCM20737 SOC Data Sheet.
When leveraging the WICED™ Smart Hardware Interfaces for your development, you will run across several GPIO mapping tables in the document that look like this one:
Note here that you can use only one of the GPIOs (noted in black) from each of the vertical rows above. This is what is referenced in the WICED™ Smart Hardware Interfaces as a "group" (all signals must be selected from the same group, which is essentially the table).
All options may not be available in the package used within the SIP module (shown in red). Combinations shown in red text are also not generally available on the BCM20732 TAG. Additional options may be unavailable if they are being used for the peripheral UART interface.
All GPIOs support programmable pull-up and pull-down resistors, along with a 2 mA drive strength except P26, P27, and P28, which provide a 16 mA drive strength at 3.3V supply (this will change as the supply drops and the GPIO pins will sink less current).
The GPIOs are all capable of waking the device from sleep or deep sleep and the application can configure interrupts (both/either edges, level), pull-up/pull-down High-Z, etc.
The following GPIOs are available on the BCM2073XS based SIP Modules (remember, only 14 are brought out on the SIP module):
For unused dual bonded pins, the unused GPIO should be input/output disabled (especially when it is an input).
From the perspective of writing software against the GPIO mappings defined above, it's important to keep in mind that the GPIO is physically mapped to a BCM2073XS device within the platform.h file which is custom to the TAG development board by default.
However, this mapping in platform.h can be reconfigured for a custom design.
The values in platform.h then map to definitions and function prototypes in bleprofile.h
Note that the specific values in the bleprofile.h bitmasks themselves are not intended to be exposed as the code beneath these bitmasks is proprietary and cannot be released for reasons outside the scope of this discussion.
In addition to reconfiguring the mappings of your custom board within the bleprofile.h, GPIO can also be assigned within BLE_PROFILE_GPIO_CFG within the .c file for each application. This is also where you allocate/initialize the GPIO within your application. The bleprofile_xxx() routines are then how you use/access what you have configured above.
With this said, I realize there is some ambiguity in this message as we have documents like WICED™ Smart Hardware Interfaces which clearly states that the BCM2073X (note that this guide was written for the SoC, then modified slightly for the SIP module) includes two sets of APIs that are available for the application: the low-level driver API and the high-level profile API.
So yes, the Low Level API is there and in some cases ok to use, but we are not consistent in exposing everything a developer needs to actually use it effectively on a consistent basis.
Hopefully you guys find this helpful. I know many of you have tidbits to add, so feel free to comment (please stay on topic). I would love to see some examples and code snippets showing usage of the bleprofile_xxx() routines.
Show LessProduct Selection | Product Evaluation | WICED Sense | Product Development | Manufacturing / Production |
Introduction
WICED supports OTA(Over-The-Air) updates for distribution of software updates. This allows firmware upgrades when needed without requiring physical access, saving time and resources.
The ota_fr application in the apps/snip directory demonstrates how to use WICED multi-application support to perform factory reset and OTA upgrade. The following steps assume you have a BCM943362WCD4 WICED evaluation board (a BCM943362WCD4 WICED module on a WICED evaluation board). If your board is different, substitute BCM943362WCD4 for your platform name.
*This process was also verified and tested on the Avnet BCM94343W_AVN BCM4343W based development kit.
Features demonstrated
- WICED OTA Upgrade
- Factory Reset process
Prepare the WICED evaluation board for OTA upgrade
1. Build the snip.ota_fr application to function as your factory reset and OTA application
2. Notice that the factory reset application (FR_APP) is set in <WICED-SDK>/apps/snip/ota_fr/ota_fr.mk to point to the snip.ota_fr application elf file.
3. Run the following make target to download your production and factory reset applications to the board:
make snip.ota_fr-BCM943362WCD4 download download_apps run
On the terminal (putty / CoolTerm) it should show as following.
**NOTE
If you are using Linux or OSX you might get the following error.
Downloading Bootloader ...
make: *** [main_app] Segmentation fault: 11
No changes detected
In this case you should copy the make file over to the following location from your built-in make file. For the OSX, you might have to install Xcode and then copy the make file.
- Linux 32bit: /tools/common/Linux32
- Linux 64bit: /tools/common/Linux64
- OSX: /tools/common/OSX
4. Build an application that will upgrade the current application.
For this example we will build the snip.scan application:
make snip.scan-BCM943362WCD4
Upgrade the application running on the WICED evaluation board
After carefully completing the above steps, the WICED evaluation board is ready to for an OTA upgrade.
'Loading OTA upgrade app' log message is displayed in the terminal when the OTA upgrade application is ready.
Work through the following steps:
1. Using the Wi-Fi connection manager on your computer, search for, and connect to the Wi-Fi AP called : Wiced Device
The AP name and passphrase is defined in /include/default_wifi_config_dct.h file. The default passphrase in SDK 3.1.2 is WICED_PASSPHRASE.
/* This is the soft AP available for normal operation (if used)*/
#define SOFT_AP_SSID "WICED Device"
#define SOFT_AP_CHANNEL 1
#define SOFT_AP_SECURITY WICED_SECURITY_WPA2_AES_PSK
#define SOFT_AP_PASSPHRASE "WICED_PASSPHRASE"
2. Open a web browser and enter the IP address of the eval board: 192.168.10.1 (default)
After a short period, the WICED Webserver OTA Upgrade webpage will appear.
3. Click 'Choose File' and navigate to the file
<WICED-SDK>/build/snip_scan-BCM943362WCD4/Binary/snip_scan-BCM943362WCD4.stripped.elf
(this is the snip.scan application binary file that was created in step 2 above)
4. Click 'Open' (the dialogue box disappears)
5. Click 'Start upgrade' to begin the upgrade process
- The progress bar within the webpage indicates the upgrade progress
- The webpage displays 'Transfer completed, WICED device is rebooting now' when the process completes
6. With the upgrade complete, the snip.scan application runs and Wi-Fi scan results are regularly printed to the terminal
Perform factory reset on the WICED evaluation board
1. Push and hold the SW1 button THEN momentarily press and release the Reset button.
The D1 LED flashes quickly to indicate factory reset will occur *IF* SW1 is held for a further 5 seconds. Continue to hold SW1.
2. After the copy process is complete, the WICED evaluation board reboots and runs the factory reset (OTA_FR) application. Observe the log messages at the terminal to confirm the factory reset is completed successfully.
WICED Multi-Application Support
As of WICED-SDK 3.1.1, WICED Application Framework (WAF) supports loading and storing of multiple application binaries in the external serial flash. Up to 8 binaries are supported. The first five binaries are reserved for internal usage and the last three binaries are free for users to use. The binaries are organized as follows:
- Factory reset application (FR_APP)
- DCT backup image (DCT_IMAGE)
- OTA upgrade application (OTA_APP)
- Resources file system (FILESYSTEM_IMAGE)
- WIFI firmware (WIFI_FIRMWARE)
- Application 0 (APP0)
- Application 1 (APP1)
- Application 2 (APP2)
Show LessWICED WiFi modules can be setup to restrict the number of clients that can join the WICED Soft AP mode device.
If the number of clients to join the WICED Soft AP device is set to 1, one client is allowed to join at a time. Once the joined device is disconnected from the AP the next device is allowed to join.
Copy the following code anywhere in …/WICED/WWD/internal/wwd_wifi.c
wwd_result_t wwd_wifi_set_max_associations( uint32_t max_assoc ) {
wiced_buffer_t buffer;
uint32_t* data = (uint32_t*) wwd_sdpcm_get_iovar_buffer( &buffer, (uint16_t) 4,IOVAR_STR_MAX_ASSOC );
CHECK_IOCTL_BUFFER( data );
*data = max_assoc;
RETURN_WITH_ASSERT( wwd_sdpcm_send_iovar( SDPCM_SET, buffer, NULL, WWD_STA_INTERFACE ));
}
Copy the following code anywhere in …/WICED/WWD/include/wwd_wifi.h
/** Set the maximum number of associations in STA mode.
* Defined only on STA interface
*
* @param noise : number of allowed accociations
*
* @return WWD_SUCCESS : if success
* Error code : if Link quality was not enabled or not successful
*/
extern wwd_result_t wwd_wifi_set_max_associations( uint32_t max_assoc );
Add wwd_wifi_set_max_associations(…) after setting the WICED network.
For example …/apps/snip/apsta application could be updated by adding wwd_wifi_set_max_associations(…) after wiced_network_up(…).
/* Bring up the STA (client) interface ------------------------------------------------------- */
wiced_network_up(WICED_STA_INTERFACE, WICED_USE_EXTERNAL_DHCP_SERVER, NULL);
/* Restrict number of Soft AP clients */
wwd_wifi_set_max_associations(1);
WICED SDK could be connected to the STM32Fx-Discovery board (in this case STM32F4-Discovery board is used) with JTAG debugger.
Connect the JTAG debugger to the STM32F4-Discovery board using the following connections.
To build an application and run it on the target STM32F4-Discovery board add the following to the Make Target built command:
For Olimex: JTAG=Olimex_ARM-USB-TINY-H
For Segger: JTAG=jlink
<WicedApplication>-<YourPlatform> JTAG=Olimex_ARM-USB-TINY-H download run
For sample interface of interfacing SN8000 WiFi module to the STM32F4-Discovery board please check out this link SN8000 WiFi Module with STM Discovery Board.
Show LessHere is an example of interfacing the BCM43362 based SN8000 WiFi module (from Murata) with STM32F4-Discovery board (with STM32F407 MCU).
The schematic below illustrates the connections required to connect the SN8000 to the STM32F4-Discovery board. Since the SN8000 comes as a module to connect to a PCB, a carrier board is needed to connect the module to the STM32F4-Discovery board.
If you have the SN8000 module mounted on a SDIO carrier board, which comes with the SN800 evaluation board, the following connection schema can be used to connect the module to the STM32F4-Discovery board.
For terminal interface between the STM32F4-Discovery board and host PC the following serial (RS232) connection is needed.
To connect a JTAG debugger (Olimex_ARM-USB-TINY-H) to the STM32F4-Discovery board follow the below connection.
For more information please take a look at this link: Interfacing STM32Fx-Discovery with WICED using JTAG Debugger
After setting up the hardware connections WICED SDK-3.x should be updated to run WICED applications on STM32F4-Discovery board with SN8000 WiFi module. Unzip the attached file with the following expected updates.
The STM32F407 directory goes to .../WICED/platform/MCU/STM32F4xx/GCC directory of the WICED SDK.
The STDiscovery407_BCM43362 platform files goes to .../platforms directory of the WICED SDK.
To build and run application using WICED SDK following Make Target could be used;
<Application>-STDiscovery407_BCM43362 JTAG=Olimex_ARM-USB-TINY-H download run
To build and run a sample scan app use the following Make Target:
snip.scan-STDiscovery407_BCM43362-debug JTAG=Olimex_ARM-USB-TINY-H download run
Show LessHere is a patch for ThreadX for WICED SDK-3.1.x version.
The following is the patch for .../WICED/RTOS/ThreadX/WWD/wwd_rtos.c:
@@ -84,7 +84,7 @@ wwd_result_t host_rtos_create_thread_with_arg( /*@out@*/ host_thread_type_t* thr
tx_thread_stack_error_notify( wiced_threadx_stack_error_handler );
#endif /* ifdef DEBUG */
- status = tx_thread_create( thread, (char*) name, (void(*)( ULONG )) entry_function, arg, stack, (ULONG) stack_size, (UINT) priority, 0, TX_NO_TIME_SLICE, (UINT) TX_AUTO_START );
+ status = tx_thread_create( thread, (char*) name, (void(*)( ULONG )) entry_function, arg, stack, (ULONG) stack_size, (UINT) priority, (UINT) priority, TX_NO_TIME_SLICE, (UINT) TX_AUTO_START );
return ( status == TX_SUCCESS ) ? WWD_SUCCESS : WWD_THREAD_CREATE_FAILED;
}
@@ -266,7 +266,7 @@ wwd_result_t host_rtos_delay_milliseconds( uint32_t num_ms )
else
{
uint32_t time_reference = host_platform_get_cycle_count( );
- int32_t wait_time = (int32_t)num_ms * CPU_CLOCK_HZ / 1000;
+ int32_t wait_time = (int32_t)num_ms * (int32_t)CPU_CLOCK_HZ / 1000;
while ( wait_time > 0 )
{
uint32_t current_time = host_platform_get_cycle_count( );
The .../WICED/RTOS/ThreadX/WWD/wwd_rtos.c source file is also attached.
Show LessThis application snippet demonstrates the e-mail capability based on the state changes on the selected input.
The selected input could be discrete or analog input. Input could be the current temperature, security device going off, PIR detector, reed switch output, etc. For this example discrete input is used and the input is toggled by the push button switch (SW1) on the evaluation board.
To setup the application, please download the attached push2email snipped application and copy it to the WICED -SDK. For example the .../apps/snip directory of the WICED SDK.
Using .../apps/snip/push2email/wifi_config_dct.h, update the wi-fi configuration for WICED target platform board to connect to your network.
Change the CLIENT_AP_SSID with your access point SSID.
Change the CLIENT_AP_PASSPHRASE with your access point's security code.
You should change the "wiced.email.test@gmail.com" email address with your own email address, in the push2email.c file. This should first be changed after #define RECIPIENT (line 48) and then again in the section to setup email account (line 168).
Build the push2email application and download it to your target
snip.push2email-<YourPlatform> download run
For BCM943362WCD4 WICED evaluation board make target would be as following:
snip.push2email-BCM943362WCD4 download run
When the push2email application runs on the target, the initial state of the LED1, based on the state of the SW1 switch, is sent as an email to the recipient. The following would be received by the email recipient: "WICED device is up initial LED state is ON."
As the SW1 switch is pressed to toggle the LED1 state, the state changes of the LED1 are sent to email recipient.
With new smtp signin security added by the mail service providers, embedded devices sign-in is prevented. The wiced.email.test@gmail.com email address is created for demo purposes and the sign-in is set to access for less secure apps. Similar sign-in setup may require to send mail using your own smtp server. To receive email no such setup is required but Wiced device generated emails may end up in spam folder.