func (d *AdapterThingFuDemoAdapter) OnWrite(t *api.Thing, action string, req api.WriteRequest, db api.AppDB, handler api.ProtocolHandler) { var content string switch action { case "turnOnRed": content = "111111100000000110100001" break case "turnOffRed": content = "111111100000000110100000" break case "turnOnYellow": content = "111111100000000110110001" break case "turnOffYellow": content = "111111100000000110110000" break } req.Put("content", content) handler.Write(t, req) }
func (s SerialChannel) Write(req api.WriteRequest) { content := req.Get("content").(string) s.serial.Write([]byte(content)) }