Skip to content

Commit

Permalink
ASTYLE
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromecoutant committed Sep 4, 2020
1 parent 9e1851a commit 297a139
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 65 deletions.
6 changes: 3 additions & 3 deletions ISM43362/ATParser/BufferedSpi/BufferedPrint.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

size_t BufferedSpiThunk(void *buf_serial, const void *s, size_t length);

int BufferedPrintfC(void *stream, int size, const char* format, va_list arg)
int BufferedPrintfC(void *stream, int size, const char *format, va_list arg)
{
int r;
char buffer[512];
Expand All @@ -33,11 +33,11 @@ int BufferedPrintfC(void *stream, int size, const char* format, va_list arg)
memset(buffer, 0, size);
r = vsprintf(buffer, format, arg);
// this may not hit the heap but should alert the user anyways
if(r > (int32_t) size) {
if (r > (int32_t) size) {
error("%s %d buffer overwrite (max_buf_size: %d exceeded: %d)!\r\n", __FILE__, __LINE__, size, r);
return 0;
}
if ( r > 0 ) {
if (r > 0) {
BufferedSpiThunk(stream, buffer, r);
}
return r;
Expand Down
58 changes: 26 additions & 32 deletions ISM43362/ISM43362.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,42 +226,37 @@ Function is updating WIFI_module_country_code with FR.
*/

#ifdef MBED_CONF_ISM43362_WIFI_COUNTRY_CODE
bool ISM43362::check_country_code(const char* country_code)
bool ISM43362::check_country_code(const char *country_code)
{
if ((!strcmp(country_code, "CA")) || (!strcmp(country_code, "US"))
|| (!strcmp(country_code, "FR")) || (!strcmp(country_code, "JP")) )
{
strcpy(WIFI_module_country_code, country_code);
return true;
}
if ((!strcmp(country_code, "CA")) || (!strcmp(country_code, "US"))
|| (!strcmp(country_code, "FR")) || (!strcmp(country_code, "JP"))) {
strcpy(WIFI_module_country_code, country_code);
return true;
}

int k = 0;
int k = 0;

while (strcmp(CountryCodeThirteenChannels[k].cc, "ED")) {
if (!strcmp(CountryCodeThirteenChannels[k].cc, country_code)) {
strcpy(WIFI_module_country_code, "FR");
return true;
}

while (strcmp(CountryCodeThirteenChannels[k].cc, "ED"))
{
if (!strcmp(CountryCodeThirteenChannels[k].cc, country_code))
{
strcpy(WIFI_module_country_code, "FR");
return true;
k++;
}

k++;
}
k = 0;

k = 0;
while (strcmp(CountryCodeElevenChannels[k].cc, "ED")) {
if (!strcmp(CountryCodeElevenChannels[k].cc, country_code)) {
strcpy(WIFI_module_country_code, "US");
return true;
}

while (strcmp(CountryCodeElevenChannels[k].cc, "ED"))
{
if (!strcmp(CountryCodeElevenChannels[k].cc, country_code))
{
strcpy(WIFI_module_country_code, "US");
return true;
k++;
}

k++;
}

return false;
return false;
}
#endif

Expand All @@ -288,12 +283,11 @@ int ISM43362::connect(const char *ap, const char *passPhrase, ism_security_t ap_
}

#ifdef MBED_CONF_ISM43362_WIFI_COUNTRY_CODE
/* Check country code is acceptable */
/* Check country code is acceptable */
bool ret = check_country_code(MBED_CONF_ISM43362_WIFI_COUNTRY_CODE);
if (ret == false)
{
printf("ISM43362::connect Country Code ERROR\n");
return NSAPI_ERROR_PARAMETER;
if (ret == false) {
printf("ISM43362::connect Country Code ERROR\n");
return NSAPI_ERROR_PARAMETER;
}

if (!(_parser.send("CN=%s/0", WIFI_module_country_code) && check_response())) {
Expand Down
47 changes: 24 additions & 23 deletions ISM43362/ISM43362.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class ISM43362 {
bool check_response(void);

#ifdef MBED_CONF_ISM43362_WIFI_COUNTRY_CODE
bool check_country_code(const char* country_code);
bool check_country_code(const char *country_code);
char WIFI_module_country_code[5];
#endif

Expand All @@ -255,33 +255,34 @@ class ISM43362 {
nsapi_connection_status_t _conn_status;
mbed::Callback<void()> _conn_stat_cb;

typedef struct
{
char cc[3];
typedef struct {
char cc[3];
} COUNTRY_CODE;

COUNTRY_CODE CountryCodeElevenChannels[12] = {"AS", "CA", "FM", "GU", "KY", "MP", "PR", "TW",
"UM", "US", "VI", "ED"};
"UM", "US", "VI", "ED"
};

COUNTRY_CODE CountryCodeThirteenChannels[127] = {"AE", "AG", "AN", "AR", "AT", "AU", "AW",
"AZ", "BA", "BB", "BD", "BE", "BG", "BH",
"BM", "BN", "BO", "BR", "BS", "BT", "BY",
"CH", "CN", "CL", "CO", "CR", "CU", "CV",
"CY", "CZ", "DE", "DK", "DM", "DO", "EC",
"EE", "EG", "ES", "FI", "FK", "FR", "GB",
"GF", "GG", "GI", "GP", "GR", "GT", "HK",
"HN", "HR", "HT", "HU", "ID", "IE", "IL",
"IM", "IN", "IS", "IT", "JE", "JM", "JO",
"KE", "KI", "KR", "KW", "LA", "LB", "LI",
"LK", "LS", "LT", "LU", "LV", "MA", "MC",
"MK", "MO", "MQ", "MR", "MT", "MU", "MV",
"MW", "MX", "MY", "NG", "NI", "NL", "NO",
"NZ", "OM", "PA", "PE", "PG", "PH", "PK",
"PL", "PM", "PT", "RE", "RO", "RU", "SA",
"SE", "SG", "SI", "SK", "SV", "TH", "TJ",
"TN", "TR", "TT", "TZ", "UA", "UY", "UZ",
"VA", "VE", "VG", "VN", "YT", "ZA", "ZM",
"ED"};
"AZ", "BA", "BB", "BD", "BE", "BG", "BH",
"BM", "BN", "BO", "BR", "BS", "BT", "BY",
"CH", "CN", "CL", "CO", "CR", "CU", "CV",
"CY", "CZ", "DE", "DK", "DM", "DO", "EC",
"EE", "EG", "ES", "FI", "FK", "FR", "GB",
"GF", "GG", "GI", "GP", "GR", "GT", "HK",
"HN", "HR", "HT", "HU", "ID", "IE", "IL",
"IM", "IN", "IS", "IT", "JE", "JM", "JO",
"KE", "KI", "KR", "KW", "LA", "LB", "LI",
"LK", "LS", "LT", "LU", "LV", "MA", "MC",
"MK", "MO", "MQ", "MR", "MT", "MU", "MV",
"MW", "MX", "MY", "NG", "NI", "NL", "NO",
"NZ", "OM", "PA", "PE", "PG", "PH", "PK",
"PL", "PM", "PT", "RE", "RO", "RU", "SA",
"SE", "SG", "SI", "SK", "SV", "TH", "TJ",
"TN", "TR", "TT", "TZ", "UA", "UY", "UZ",
"VA", "VE", "VG", "VN", "YT", "ZA", "ZM",
"ED"
};
};

#endif
9 changes: 5 additions & 4 deletions ISM43362Interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static uint8_t *ism_wifi_thread_stack = NULL;
#endif // MBED_CONF_ISM43362_READ_THREAD_STACK_STATICALLY_ALLOCATED == 1
#endif // MBED_CONF_ISM43362_READ_THREAD_STACK_SIZE != 0

// Product ID,FW Revision,API Revision,Stack Revision,RTOS Revision,CPU Clock,Product Name
// Product ID,FW Revision,API Revision,Stack Revision,RTOS Revision,CPU Clock,Product Name
#define LATEST_FW_VERSION_NUMBER "C3.5.2.5" // ISM43362-M3G-L44-SPI,C3.5.2.5.STM,v3.5.2,v1.4.0.rc1,v8.2.1,120000000,Inventek eS-WiFi

// activate / de-activate debug
Expand Down Expand Up @@ -72,7 +72,7 @@ ISM43362Interface::ISM43362Interface(bool debug)

debug_if(_ism_debug, "ISM43362Interface: read_version = %" PRIu32 "\r\n", _FwVersion);
/* FW Revision should be with format "CX.X.X.X" with X as a single digit */
if ( (_FwVersion < 1000) || (_FwVersion > 9999) ) {
if ((_FwVersion < 1000) || (_FwVersion > 9999)) {
debug_if(_ism_debug, "ISM43362Interface: read_version issue\r\n");
}

Expand All @@ -87,7 +87,7 @@ ISM43362Interface::ISM43362Interface(bool debug)
}

nsapi_error_t ISM43362Interface::connect(const char *ssid, const char *pass, nsapi_security_t security,
uint8_t channel)
uint8_t channel)
{
if (channel != 0) {
return NSAPI_ERROR_UNSUPPORTED;
Expand Down Expand Up @@ -632,7 +632,8 @@ void ISM43362Interface::update_conn_state_cb()

#if MBED_CONF_ISM43362_PROVIDE_DEFAULT

WiFiInterface *WiFiInterface::get_default_instance() {
WiFiInterface *WiFiInterface::get_default_instance()
{
static ISM43362Interface ism;
return &ism;
}
Expand Down
5 changes: 2 additions & 3 deletions ISM43362Interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
/** ISM43362Interface class
* Implementation of the NetworkStack for the ISM43362
*/
class ISM43362Interface : public NetworkStack, public WiFiInterface
{
class ISM43362Interface : public NetworkStack, public WiFiInterface {
public:
/** ISM43362Interface lifetime
* @param debug Enable debugging
Expand All @@ -54,7 +53,7 @@ class ISM43362Interface : public NetworkStack, public WiFiInterface
* @return 0 on success, or error code on failure
*/
virtual nsapi_error_t connect(const char *ssid, const char *pass, nsapi_security_t security = NSAPI_SECURITY_NONE,
uint8_t channel = 0);
uint8_t channel = 0);

/** Set the WiFi network credentials
*
Expand Down

0 comments on commit 297a139

Please sign in to comment.