__CAPGO_KEEP_2__

MQTTの始め方

GitHub

AI-Assisted Setupを使用してプラグインをインストールできます。AIツールにCapgoスキルを追加するには、以下のコマンドを実行してください。

ターミナル画面
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

次に、以下のプロンプトを使用してください。

Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-mqtt` plugin in my project.

Manual Setupを使用する場合は、以下のコマンドを実行してプラグインをインストールし、以下のプラットフォーム固有の指示に従ってください。

ターミナル画面
bun add @capgo/capacitor-mqtt
bunx cap sync
import { MqttBridge } from '@capgo/capacitor-mqtt';

現在の契約のソース定義を参照してください。

import { MqttBridge } from '@capgo/capacitor-mqtt';
await MqttBridge.connect({} as {
serverURI: string;
port: number;
clientId: string;
username: string;
password: string;
setCleanSession: boolean;
connectionTimeout: number;
keepAliveInterval: number;
setAutomaticReconnect: boolean;
setLastWill?: {
willTopic: string;
willPayload: string;
willQoS: number;
setRetained: boolean;
};
});

現在の契約のソース定義を参照してください。

import { MqttBridge } from '@capgo/capacitor-mqtt';
await MqttBridge.disconnect();

現在の契約のソース定義を参照してください。

import { MqttBridge } from '@capgo/capacitor-mqtt';
await MqttBridge.subscribe({} as { topic: string; qos: number });

現在の契約のソース定義を参照してください。

import { MqttBridge } from '@capgo/capacitor-mqtt';
await MqttBridge.publish({} as { topic: string; payload: string; qos: number; retained: boolean });
export type onConnectionLostListener = (x: { connectionStatus: string; reasonCode: number; message: string }) => void;
export type onConnectCompleteListener = (x: { reconnected: boolean; serverURI: string }) => void;
export type onMessageArrivedListener = (x: { topic: string; message: string }) => void;

このページはプラグインから生成されています。 src/definitions.tsパブリック API がアップストリームで変更されたときは、再度同期を実行してください。

続けてGetting Started

続けてGetting Started

あなたが使用している場合 Getting Started ダッシュボードと API の計画と実行を計画している場合、 Using @capgo/capacitor-mqtt Using @capgo/capacitor-mqtt API の概要 API の概要 導入 導入の実装詳細について API キー API キーの実装詳細について デバイス デバイスの実装詳細について