Skip to content
Oliver Schmidt edited this page Feb 10, 2021 · 6 revisions

The service If This Then That supports maker webhooks in both directions:

Sending a web request to IFTTT

This can be done via url_download. It is demonstrated by Tweet65, which contains the reusable IFTTT-specific wrapper ifttt_trigger.

Receiving a web request from IFTTT

This can be done via httpd_start. It requires to provide IFTTT with a URL that allows a TCP connection to be established from an IFTTT server to the machine running your IP65-based program. Doing so usually implies to use

  • Dynamic DNS to have a stable host name for the URL in question.
  • Port forwarding on your NAT router to forward incoming connections on a specific TCP port to the machine running your IP65-based program.

Because of this setup complexity there's no ready-to-run TCP/IP program demonstrating it. However here's a bare-bones program without any error-checks for the Apple II:

#include <tgi.h>
#include <string.h>
#include <apple2.h>
#include "ip65.h"

struct
{
  char *name;
  unsigned char code;
}
color[] = {{"black",  TGI_COLOR_BLACK},
           {"orange", TGI_COLOR_ORANGE},
           {"green",  TGI_COLOR_GREEN},
           {"blue",   TGI_COLOR_DARKBLUE},
           {"white",  TGI_COLOR_WHITE}};

void fill_screen(const char* color_name)
{
  unsigned char i;

  for (i = 0; i < sizeof(color) / sizeof(color[0]); ++i)
  {
    if (!strcmp(color_name, color[i].name))
    {
      tgi_setcolor(color[i].code);
      break;
    }
  }
  tgi_bar(0, 0, tgi_getmaxx(), tgi_getmaxy());
}

void http_server(uint32_t, const char*, const char* path)
{
  if (!strcmp(path, "/fillscreen"))
  {
    fill_screen(http_get_value('c'));
    httpd_send_response(HTTPD_RESPONSE_200_TEXT, "done", 4);
    return;
  }
  httpd_send_response(HTTPD_RESPONSE_404, 0, 0);
}

void main()
{
  ip65_init(3);
  dhcp_init();

  tgi_install(a2_lo_tgi);
  tgi_init();
  tgi_clear();

  httpd_start(6502, http_server);

  tgi_done();
  tgi_uninstall();
}

The program reacts on the five URLs

by - nomen est omen - filling the screen with that color. Depending on the IFTTT trigger used the actual color value can be an IFTTT Ingredient. The video Control Your Apple II With Alexa demonstrates that very process with the Amazon Alexa Say a specific phrase trigger that doesn't support Ingredients. Therefore the video required five individual IFTTT Applets.

Clone this wiki locally