Skip to content

Commit

Permalink
Merge pull request #942 from spark/feature/wifi_country
Browse files Browse the repository at this point in the history
wifi country
  • Loading branch information
m-mcgowan committed Apr 28, 2016
2 parents df065a0 + f88d2f6 commit 36a25ad
Show file tree
Hide file tree
Showing 10 changed files with 337 additions and 155 deletions.
24 changes: 21 additions & 3 deletions hal/src/photon/platforms/BCM9WCDUSI09/wifi_nvram_image.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
/** @file
*
* BCM43362 NVRAM variables for WM-N-BM-09 USI SiP
* 20151216 modify maxp2ga0 from 74 to 62(3dBm deduced);ofdm2gpo from 0x44111111 to all C; mcs2gpo0 from all 4 to all C ; mcs2gpo1=0x6444 to ALL C
*
*/

Expand All @@ -46,11 +47,19 @@
#include <stdint.h>
#include "../generated_mac_address.txt"

#ifndef WIFI_NVRAM_LTXP
#define WIFI_NVRAM_LTXP 0
#endif

/**
* Character array of NVRAM image
*/

static const char wifi_nvram_image[] =
#if !WIFI_NVRAM_LTXP
static const char wifi_main_nvram_image[] =
#else
static const char wifi_ltxp_nvram_image[] =
#endif
"manfid=0x2d0" "\x00"
"prodid=0x492" "\x00"
"vendid=0x14e4" "\x00"
Expand All @@ -65,10 +74,19 @@ static const char wifi_nvram_image[] =
NVRAM_GENERATED_MAC_ADDRESS "\x00"
"aa2g=3" "\x00"
"ag0=2" "\x00"

#if !WIFI_NVRAM_LTXP
"maxp2ga0=74" "\x00"
"ofdm2gpo=0x44111111" "\x00"
"mcs2gpo0=0x4444" "\x00"
"mcs2gpo1=0x6444" "\x00"
#else
"maxp2ga0=62" "\x00"
"ofdm2gpo=0xCCCCCCCC" "\x00"
"mcs2gpo0=0xCCCC" "\x00"
"mcs2gpo1=0xCCCC" "\x00"
#endif

"pa0maxpwr=80" "\x00"
"pa0b0=5264" "\x00" /*PA params*/
"pa0b1=64897" "\x00"
Expand Down Expand Up @@ -107,8 +125,8 @@ static const char wifi_nvram_image[] =
"rfreg033_cck=0x1f" "\x00"
"cckPwrIdxCorr=-8" "\x00"
"spuravoid_enable2g=1" "\x00"
"edonthd=-70" "\x00"
"edoffthd=-76" "\x00"
"edonthd=-70" "\x00"
"edoffthd=-76" "\x00"
"\x00\x00";

#else /* ifndef INCLUDED_NVRAM_IMAGE_H_ */
Expand Down
22 changes: 21 additions & 1 deletion hal/src/photon/platforms/BCM9WCDUSI14/wifi_nvram_image.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
*
* BCM43362 NVRAM variables for WICED Module (USI WM-N-BM-14)
* Created : 18 April 2012, ssamson
* BCM43362 NVRAM variables for WM-N-BM-09 USI SiP
* 20151216 modify maxp2ga0 from 74 to 62(3dBm deduced);ofdm2gpo from 0x44111111 to all C; mcs2gpo0 from all 4 to all C ; mcs2gpo1=0x6444 to ALL C
*
*/

#ifndef INCLUDED_NVRAM_IMAGE_H_
Expand All @@ -50,11 +53,19 @@
extern "C" {
#endif

#ifndef WIFI_NVRAM_LTXP
#define WIFI_NVRAM_LTXP 0
#endif

/**
* Character array of NVRAM image
*/

static const char wifi_nvram_image[] =
#if !WIFI_NVRAM_LTXP
static const char wifi_main_nvram_image[] =
#else
static const char wifi_ltxp_nvram_image[] =
#endif
"manfid=0x2d0" "\x00"
"prodid=0x492" "\x00"
"vendid=0x14e4" "\x00"
Expand All @@ -69,10 +80,19 @@ static const char wifi_nvram_image[] =
NVRAM_GENERATED_MAC_ADDRESS "\x00"
"aa2g=3" "\x00"
"ag0=2" "\x00"

#if !WIFI_NVRAM_LTXP
"maxp2ga0=74" "\x00"
"ofdm2gpo=0x44111111" "\x00"
"mcs2gpo0=0x4444" "\x00"
"mcs2gpo1=0x6444" "\x00"
#else
"maxp2ga0=62" "\x00"
"ofdm2gpo=0xCCCCCCCC" "\x00"
"mcs2gpo0=0xCCCC" "\x00"
"mcs2gpo1=0xCCCC" "\x00"
#endif

"pa0maxpwr=80" "\x00"
"pa0b0=5609" "\x00" /*PA params*/
"pa0b1=-672" "\x00"
Expand Down
38 changes: 32 additions & 6 deletions hal/src/photon/resources.c
Original file line number Diff line number Diff line change
@@ -1,16 +1,42 @@

#include "wiced_resource.h"
#include "wwd_resources.h"

#define WIFI_NVRAM_LTXP 1
#include "wifi_nvram_image.h"
#undef WIFI_NVRAM_LTXP
#undef INCLUDED_NVRAM_IMAGE_H_
#include "wifi_nvram_image.h"

#define NVRAM_SIZE sizeof( wifi_nvram_image )
#define NVRAM_IMAGE_VARIABLE wifi_nvram_image

const resource_hnd_t* wwd_nvram_image_resource(void) __attribute__((weak)) ;
static const resource_hnd_t wifi_nvram_resources[] = {
{ RESOURCE_IN_MEMORY, sizeof( wifi_main_nvram_image ), {.mem = { (const char *) wifi_main_nvram_image }}},
{ RESOURCE_IN_MEMORY, sizeof( wifi_ltxp_nvram_image ), {.mem = { (const char *) wifi_ltxp_nvram_image }}}
};


static uint8_t wifi_nvram_resource_index = 0;

/**
* This is a bit of a hack. The resources.c file is compiled in the HAL, but then it's borrowed for
* system-part1, which is linked as a dynamic library. The resources.o is still linked in the hal in
* part2, but part2 is also importing the dynamic library, leading to a double definition of these
* functions. Marking them weak sidesteps this.
* I imagine there's a more elegant way to solve this, but this was quick to implement.
*/
const resource_hnd_t* wwd_nvram_image_resource(void) __attribute__((weak));
int wwd_select_nvram_image_resource(uint8_t index, void* reserved) __attribute__((weak));

const resource_hnd_t* wwd_nvram_image_resource(void)
{
static const resource_hnd_t wifi_nvram_resource = { RESOURCE_IN_MEMORY, NVRAM_SIZE, {.mem = { (const char *) NVRAM_IMAGE_VARIABLE}}};
return &wifi_nvram_resource;
return &wifi_nvram_resources[wifi_nvram_resource_index];
}


/**
* @param index: 0 for regular, 1 for reduced transmit power (for TELEC certification.)
*/
int wwd_select_nvram_image_resource(uint8_t index, void* reserved)
{
wifi_nvram_resource_index = index;
return 0;
}
1 change: 1 addition & 0 deletions hal/src/photon/softap.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ extern "C" {
uint16_t passwordLen, wiced_security_t security, unsigned channel);

size_t hex_decode(uint8_t* buf, size_t len, const char* hex);
uint8_t hex_nibble(unsigned char c);

#ifdef __cplusplus
}
Expand Down
Loading

0 comments on commit 36a25ad

Please sign in to comment.