EmberStatus emberAfRf4ceMsoIrRfDatabaseOriginatorSet(EmberAfRf4ceMsoKeyCode keyCode,
                                                     const EmberAfRf4ceMsoIrRfDatabaseEntry *entry)
{
  uint8_t index = getEntryIndex(keyCode);
  if (index == 0xFF) {
    return EMBER_NOT_FOUND;
  }
  return setEntry(index, entry);
}
EmberStatus emberAfRf4ceMsoIrRfDatabaseOriginatorGet(EmberAfRf4ceMsoKeyCode keyCode,
                                                     EmberAfRf4ceMsoIrRfDatabaseEntry *entry)
{
  uint8_t index = getEntryIndex(keyCode);
  if (index == 0xFF) {
    return EMBER_NOT_FOUND;
  }
  MEMCOPY(entry, &database[index], sizeof(EmberAfRf4ceMsoIrRfDatabaseEntry));
  return EMBER_SUCCESS;
}
EmberStatus emberAfRf4ceMsoIrRfDatabaseOriginatorClear(EmberAfRf4ceMsoKeyCode keyCode)
{
  // Clearing an entry is the same as replacing it with a default.
  EmberAfRf4ceMsoIrRfDatabaseEntry entry;
  uint8_t index = getEntryIndex(keyCode);
  if (index == 0xFF) {
    return EMBER_NOT_FOUND;
  }
  SET_DEFAULT(&entry);
  return setEntry(index, &entry);
}
void emberAfPluginRf4ceMsoIncomingIrRfDatabaseAttributeCallback(uint8_t pairingIndex,
                                                                uint8_t entryIndex,
                                                                uint8_t valueLength,
                                                                const uint8_t *value)
{
  EmberAfRf4ceMsoIrRfDatabaseEntry entry;
  const uint8_t *finger;
  uint8_t index;

  // The entry index is the key code.  If we don't support the key code, we
  // ignore this entry.
  index = getEntryIndex((EmberAfRf4ceMsoKeyCode)entryIndex);
  if (index == 0xFF) {
    return;
  }

  // TODO: Check length of incoming data.

  finger = value;
  entry.flags = *finger++;

  // TODO: Extract RF descriptor parsing to a function.
  if (emberAfRf4ceMsoIrRfDatabaseEntryHasRfPressedDescriptor(&entry)) {
    entry.rfPressedDescriptor.rfConfig = *finger++;
    entry.rfPressedDescriptor.txOptions = *finger++;
    entry.rfPressedDescriptor.payloadLength = *finger++;
    entry.rfPressedDescriptor.payload = finger;
    finger += entry.rfPressedDescriptor.payloadLength;
  }
  if (emberAfRf4ceMsoIrRfDatabaseEntryHasRfRepeatedDescriptor(&entry)) {
    entry.rfRepeatedDescriptor.rfConfig = *finger++;
    entry.rfRepeatedDescriptor.txOptions = *finger++;
    entry.rfRepeatedDescriptor.payloadLength = *finger++;
    entry.rfRepeatedDescriptor.payload = finger;
    finger += entry.rfRepeatedDescriptor.payloadLength;
  }
  if (emberAfRf4ceMsoIrRfDatabaseEntryHasRfReleasedDescriptor(&entry)) {
    entry.rfReleasedDescriptor.rfConfig = *finger++;
    entry.rfReleasedDescriptor.txOptions = *finger++;
    entry.rfReleasedDescriptor.payloadLength = *finger++;
    entry.rfReleasedDescriptor.payload = finger;
    finger += entry.rfReleasedDescriptor.payloadLength;
  }
  if (emberAfRf4ceMsoIrRfDatabaseEntryHasIrDescriptor(&entry)) {
    entry.irDescriptor.irConfig = *finger++;
    entry.irDescriptor.irCodeLength = *finger++;
    entry.irDescriptor.irCode = finger;
    finger += entry.irDescriptor.irCodeLength;
  }

  setEntry(index, &entry);
}
Ejemplo n.º 5
0
int main()
{
    VisionCam * gCam = NULL;
    entryIndex index = 0;
    module_t handle = NULL;
    status_e ret = STATUS_SUCCESS;

#if defined(SOSAL_RUNTIME_DEBUG)
    debug_get_zone_mask("SOSAL_ZONE_MASK", &sosal_zone_mask);
#endif

#if defined(DVP_RUNTIME_DEBUG)
    debug_get_zone_mask("DVP_ZONE_MASK", &dvp_zone_mask);
#endif

    handle =  initModule( &gCam );
#ifdef VCAM_AS_SHARED
    if( handle == NULL )
        return -1;
#endif

    if( gCam )
    {
        setInitialValues( gCam );
        ret = startServices( gCam );
    }
    else
    {
        ret = STATUS_CATASTROPHIC;
    }

    if( ret !=  STATUS_SUCCESS )
    {
        ret = deinitModule( handle, &gCam );
    }
    else
    {
        while( 1 )
        {
            index = Menu( menu );
            if( index == -1 )
            {
                continue;
            }

            /// 'q' button (quit) is pressed
            if( menu[ index ]->ID == VCAM_CMD_QUIT )
            {
                index = getEntryIndex( menu , KEY_PREVIEW_STOP );
                ret = executeEntry( menu[ index ], gCam );
                break;
            }
            ret = executeEntry( menu[ index ] , gCam );
        }
        ret = stopServices( gCam );
        ret = deinitModule( handle, &gCam );
    }

    printf("\tvcam_test exiting with %d.\n", ret);

    if( STATUS_SUCCESS != ret )
        puts("\tTerminating application.");

    return ret;
}