Created
January 11, 2019 13:30
-
-
Save SibeeshVenu/bbad6e7fba9f55aa9b8e8212b493f03c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void setup() | |
{ | |
Screen.init(); | |
Screen.print(0, "IoT Device Demo"); | |
Screen.print(2, "Initializing..."); | |
Screen.print(3, " > Serial"); | |
Serial.begin(115200); | |
// Initialize the WiFi module | |
Screen.print(3, " > WiFi"); | |
hasWifi = false; | |
initWifi(); | |
if (!hasWifi) | |
{ | |
return; | |
} | |
Screen.print(3, " > Sensors"); | |
sensorInit(); | |
Screen.print(3, " > IoT Hub"); | |
DevKitMQTTClient_Init(true); | |
DevKitMQTTClient_SetOption(OPTION_MINI_SOLUTION_NAME, "mlIoTPlatformDevice"); | |
DevKitMQTTClient_SetSendConfirmationCallback(sendConfirmationCallback); | |
DevKitMQTTClient_SetMessageCallback(messageCallback); | |
DevKitMQTTClient_SetDeviceTwinCallback(deviceTwinCallback); | |
DevKitMQTTClient_SetDeviceMethodCallback(deviceMethodCallback); | |
appstate = APPSTATE_Init; | |
Serial.begin(115200); | |
int filter_size = mfcc_GetInputSize(0); | |
if (filter_size != FEATURIZER_INPUT_SIZE) | |
{ | |
Serial.printf("Featurizer input size %d is not equal to %d\n", filter_size, FEATURIZER_INPUT_SIZE); | |
show_error("Featurizer Error"); | |
} | |
if (appstate != APPSTATE_Error) | |
{ | |
::memset(featurizer_input_buffers[0], 0, FEATURIZER_INPUT_SIZE); | |
// give it a whirl !! | |
mfcc_Filter(nullptr, featurizer_input_buffers[0], featurizer_output_buffer); | |
// check audio gain and print the result. | |
uint32_t id = Audio.readRegister(nau88c10_CHIPID_ADDR); | |
if (id == NAU88C10_ID) | |
{ | |
Serial.printf("Found audio device: NAU88C10\r\n"); | |
} | |
else | |
{ | |
Serial.printf("Found audio device: 0x%x\r\n", id); | |
} | |
// a default gain level of 4 seems to work pretty well. | |
start_recording(); | |
Screen.clean(); | |
Screen.print(0, "Listening..."); | |
Screen.print(1, "A = min gain"); | |
Screen.print(2, "B = max gain"); | |
minGain = 0; | |
maxGain = 7; | |
set_gain(); | |
display_gain(); | |
} | |
send_interval_ms = SystemTickCounterRead(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment