/* mxchip library manufacture test. */
void mxchip_mfg_test(void)
{
  char str[64];
  char mac[6];
  char *ssid;
  mico_uart_config_t uart_config;
  volatile ring_buffer_t  rx_buffer;
  volatile uint8_t *      rx_data;
  
  rx_data = malloc(50);
  require(rx_data, exit);
  
  /* Initialize UART interface */
  uart_config.baud_rate    = 115200;
  uart_config.data_width   = DATA_WIDTH_8BIT;
  uart_config.parity       = NO_PARITY;
  uart_config.stop_bits    = STOP_BITS_1;
  uart_config.flow_control = FLOW_CONTROL_DISABLED;
  uart_config.flags = UART_WAKEUP_DISABLE;
  
  ring_buffer_init  ( (ring_buffer_t *)&rx_buffer, (uint8_t *)rx_data, 50 );
  MicoUartInitialize( MFG_TEST, &uart_config, (ring_buffer_t *)&rx_buffer );  

  mf_printf("==== MXCHIP Manufacture Test ====\r\n");
  mf_printf("Bootloader Version: ");
  mf_printf(mico_get_bootloader_ver());
  mf_printf("\r\n");
  sprintf(str, "Library Version: %s\r\n", system_lib_version());
  mf_printf(str);
  mf_printf("APP Version: ");
  memset(str, 0, sizeof(str));
  system_version(str, sizeof(str));
  mf_printf(str);
  mf_printf("\r\n");
  memset(str, 0, sizeof(str));
  MicoGetRfVer(str, sizeof(str));
  mf_printf("Driver: ");
  mf_printf(str);
  mf_printf("\r\n");
  wlan_get_mac_address(mac);
  sprintf(str, "MAC: %02X-%02X-%02X-%02X-%02X-%02X\r\n",
          mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
  mf_printf(str);
  
  mfg_scan();
  
  ssid = ssid_get();
  mfg_connect(ssid);
  
exit:
  mico_thread_sleep(MICO_NEVER_TIMEOUT);
}
Exemple #2
0
/* mxchip library manufacture test. */
void mxchip_mfg_test(void)
{
  char str[128];
  char mac[6];
  char *ssid;
  mico_uart_config_t uart_config;
  volatile ring_buffer_t  rx_buffer;
  volatile uint8_t *      rx_data;
  mico_debug_enabled = 0;
  
  rx_data = malloc(50);
  require(rx_data, exit);
  
  /* Initialize UART interface */
  uart_config.baud_rate    = 115200;
  uart_config.data_width   = DATA_WIDTH_8BIT;
  uart_config.parity       = NO_PARITY;
  uart_config.stop_bits    = STOP_BITS_1;
  uart_config.flow_control = FLOW_CONTROL_DISABLED;
  uart_config.flags = UART_WAKEUP_DISABLE;

  ring_buffer_init ((ring_buffer_t *)&rx_buffer, (uint8_t *)rx_data, 50);
  MicoUartInitialize (MFG_TEST, &uart_config, (ring_buffer_t *)&rx_buffer);

  mf_printf ("==== MXCHIP Manufacture Test ====\r\n");
  mf_printf ("Serial Number: ");
  mf_printf (SERIAL_NUMBER);
  mf_printf ("\r\n");

  mf_printf ("App CRC: ");
  memset (str, 0, sizeof (str));
  app_crc (str, sizeof (str));
  mf_printf (str);
  mf_printf ("\r\n");

  mf_printf ("Bootloader Version: ");
  mf_printf (mico_get_bootloader_ver());
  mf_printf ("\r\n");
  sprintf (str, "Library Version: %s\r\n", system_lib_version());
  mf_printf (str);
  mf_printf ("APP Version: ");
  memset (str, 0, sizeof (str));
  system_version (str, sizeof (str));
  mf_printf (str);
  mf_printf ("\r\n");
  memset (str, 0, sizeof (str));
  wlan_driver_version (str, sizeof (str));
  mf_printf ("Driver: ");
  mf_printf (str);
  mf_printf ("\r\n");

#ifdef MICO_BLUETOOTH_ENABLE
  /* Initialise MICO SmartBridge */
  mico_bt_init( MICO_BT_HCI_MODE, "SmartBridge Device", 0, 0 );  //Client + server connections
  mico_bt_smartbridge_init( 0 );
  mico_bt_dev_read_local_addr( (uint8_t *)mac );
  sprintf( str, "Local Bluetooth Address: %02X-%02X-%02X-%02X-%02X-%02X\r\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5] );
  mf_printf (str);
  ble_scan();
#endif

  wlan_get_mac_address (mac);
  sprintf (str, "MAC: %02X-%02X-%02X-%02X-%02X-%02X\r\n",
          mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
  mf_printf(str);
  mfg_scan();

  if (test_for_app==0) {
  ssid = ssid_get();
    mfg_connect (ssid);
  }

exit:
  mico_thread_sleep(MICO_NEVER_TIMEOUT);
}