Exemplo n.º 1
0
void DataStore::_addScheduleRaw(const IncomingRadioMessage& aIncomingRadioMessage, uint8_t aDay, uint8_t aLocation) {
	if (xSemaphoreTake(mScheduleSemaphore, portMAX_DELAY) == pdTRUE) {
		mReader.setBuffer((unsigned char*)aIncomingRadioMessage.content(), aIncomingRadioMessage.length());

		// get the length and create a new array of events
		tp_integer_t eventCount = Utils::getInteger(mReader);
		Event* events = new Event[eventCount];

		for (int i = 0 ; i < eventCount ; ++i) {
			events[i].locationId = (LocationId)Utils::getInteger(mReader);
			events[i].typeId = (uint8_t)Utils::getInteger(mReader);
			events[i].startTimestamp = (uint32_t)Utils::getInteger(mReader);
			events[i].endTimestamp = (uint32_t)Utils::getInteger(mReader);
			events[i].speaker = Utils::getString(mReader);
			events[i].title = Utils::getString(mReader);
		};

		delete mSchedule[aDay][aLocation];
		mSchedule[aDay][aLocation] = new Schedule(events, eventCount);

		debug::log("DataStore: Got schedule: day: " +  String(aDay) + " location: " + String(aLocation) + " events: " + String(mSchedule[aDay][aLocation]->getEventCount()));

		xSemaphoreGive(mScheduleSemaphore);
	}
}
Exemplo n.º 2
0
void BadgeNotifications::handleMessage(const IncomingRadioMessage& aIncomingRadioMessage) {
    // parse the radio message content into mBadgeNotification
    // <3 bytes rgb1> <3 bytes rgb2> <1 byte sound> <text>

    if (xSemaphoreTake(mNotificationMutex, portMAX_DELAY) == pdTRUE) {
        mReader.setBuffer((unsigned char*)aIncomingRadioMessage.content(), aIncomingRadioMessage.length());

        RGBColor rgb1 = getRGBColor(mReader);
        RGBColor rgb2 = getRGBColor(mReader);
        boolean sound = Utils::getBoolean(mReader);
        uint8_t type = static_cast<uint8_t>(Utils::getInteger(mReader));
        char* textChars = Utils::getString(mReader);
        String text(textChars);
        delete textChars;
        debug::log("BADGER NOTIFICATION");
        debug::log(text);

        delete mBadgeNotification;
        mBadgeNotification = new BadgeNotification(text, rgb1, rgb2, sound, type);
        xSemaphoreGive(mNotificationMutex);
        Tilda::openApp(NotificationApp::New);
    }

    // start the notification app to start it
    //mAppManager->open(NotificationApp::New);
}
Exemplo n.º 3
0
void DataStore::_addWeatherForecastRaw(const IncomingRadioMessage& aIncomingRadioMessage) {
	if (xSemaphoreTake(mWeatherSemaphore, portMAX_DELAY) == pdTRUE) {
		mWeatherForecast->mValid = true;
		mReader.setBuffer((unsigned char*)aIncomingRadioMessage.content(), aIncomingRadioMessage.length());
		_unpackWeatherForecastPeriod(mWeatherForecast->mWeatherForecastPeriods[WEATHER_CURRENT], mReader);
		_unpackWeatherForecastPeriod(mWeatherForecast->mWeatherForecastPeriods[WEATHER_3_HOURS], mReader);
		_unpackWeatherForecastPeriod(mWeatherForecast->mWeatherForecastPeriods[WEATHER_6_HOURS], mReader);
		_unpackWeatherForecastPeriod(mWeatherForecast->mWeatherForecastPeriods[WEATHER_12_HOURS], mReader);
		_unpackWeatherForecastPeriod(mWeatherForecast->mWeatherForecastPeriods[WEATHER_24_HOURS], mReader);
		_unpackWeatherForecastPeriod(mWeatherForecast->mWeatherForecastPeriods[WEATHER_48_HOURS], mReader);

		debug::log("DataStore: Stored weather forecast: " +
				String(mWeatherForecast->mWeatherForecastPeriods[WEATHER_CURRENT].temperature) + "deg, Weather type: " + String((uint8_t) mWeatherForecast->mWeatherForecastPeriods[WEATHER_CURRENT].weatherType));

		xSemaphoreGive(mWeatherSemaphore);
	}
}
Exemplo n.º 4
0
void BadgeNotifications::handleMessage(const IncomingRadioMessage& aIncomingRadioMessage) {
    // parse the radio message content into mBadgeNotification
    // <3 bytes rgb1> <3 bytes rgb2> <1 byte sound> <text>

        mReader.setBuffer((unsigned char*)aIncomingRadioMessage.content(), aIncomingRadioMessage.length());

        RGBColor rgb1 = getRGBColor(mReader);
        RGBColor rgb2 = getRGBColor(mReader);
        boolean sound = Utils::getBoolean(mReader);
        uint8_t type = static_cast<uint8_t>(Utils::getInteger(mReader));
        char* textChars = Utils::getString(mReader);
        String text(textChars);
        delete[] textChars;
        debug::log("BADGER NOTIFICATION");
        debug::log(text);
        pushNotification(text, rgb1, rgb2, sound, type);
}