コード例 #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);
	}
}
コード例 #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);
}
コード例 #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);
	}
}
コード例 #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);
}
コード例 #5
0
void DataStore::handleMessage(const IncomingRadioMessage& aIncomingRadioMessage) {
	if (aIncomingRadioMessage.rid() == CONTENT_RID_WEATHER_FORECAST) {
		_addWeatherForecastRaw(aIncomingRadioMessage);
	} else if (aIncomingRadioMessage.rid() >= CONTENT_RID_SCHEDULE_FRIDAY_START
				&& aIncomingRadioMessage.rid() < CONTENT_RID_SCHEDULE_FRIDAY_START + LOCATION_COUNT) {
		_addScheduleRaw(aIncomingRadioMessage, SCHEDULE_FRIDAY, aIncomingRadioMessage.rid() - CONTENT_RID_SCHEDULE_FRIDAY_START);
	} else if (aIncomingRadioMessage.rid() >= CONTENT_RID_SCHEDULE_SATURDAY_START
				&& aIncomingRadioMessage.rid() < CONTENT_RID_SCHEDULE_SATURDAY_START + LOCATION_COUNT) {
		_addScheduleRaw(aIncomingRadioMessage, SCHEDULE_SATURDAY, aIncomingRadioMessage.rid() - CONTENT_RID_SCHEDULE_SATURDAY_START);
	} else if (aIncomingRadioMessage.rid() >= CONTENT_RID_SCHEDULE_SUNDAY_START
				&& aIncomingRadioMessage.rid() < CONTENT_RID_SCHEDULE_SUNDAY_START + LOCATION_COUNT) {
		_addScheduleRaw(aIncomingRadioMessage, SCHEDULE_SUNDAY, aIncomingRadioMessage.rid() - CONTENT_RID_SCHEDULE_SUNDAY_START);
	} else {
		debug::log("DataStore: Rid not supported: " + String(aIncomingRadioMessage.rid()) + " " + String(aIncomingRadioMessage.length()));
	}
}