Node.js SDK รวมเข้ากับเซิร์ฟเวอร์เครือข่าย LoRawan Network (LNS) ของเครือข่ายได้อย่างราบรื่นทำให้นักพัฒนาสามารถเชื่อมต่อและจัดการอุปกรณ์ IoT ได้อย่างง่ายดาย ด้วยการสนับสนุน API ที่กว้างขวางแพ็คเกจนี้ทำให้การโต้ตอบกับแอปพลิเคชันง่ายขึ้นกับระบบนิเวศ Lorawan ของ TTN ทำให้การจัดเตรียมอุปกรณ์การส่งข้อมูลการส่งข้อมูลและการตรวจสอบสถานะอุปกรณ์ ใช้ประโยชน์จาก Node.js SDK ที่ใช้งานง่ายเพื่อเพิ่มการเชื่อมต่อและการจัดการข้อมูลภายในโครงสร้างพื้นฐาน Lorawan ของเครือข่าย
SDK นี้ยังทำงานร่วมกับ "The Things Industries" และโฮสต์ส่วนตัว "The Things Stack Instance"
พร้อมที่จะเริ่มใช้ SDK หรือยัง? เริ่มกันเถอะ!
เอกสาร : ttn-node-sdk.fuota.io
GitHub : The-Things-Network-Nodejs-Sdk
สำหรับวิธีการที่เกี่ยวข้องกับอุปกรณ์ปลายทาง: enddevice
สำหรับวิธีการที่เกี่ยวข้องกับแอปพลิเคชัน: แอปพลิเคชัน
สำหรับวิธีการที่เกี่ยวข้องกับเกตเวย์: เกตเวย์
สำหรับวิธีการที่เกี่ยวข้องกับผู้ใช้: ผู้ใช้
สำหรับวิธีการที่เกี่ยวข้องกับองค์กร: องค์กร
ในการติดตั้งเวอร์ชันล่าสุดบน NPM ในเครื่องและบันทึกไว้ในไฟล์แพ็คเกจของคุณ Json:
NPM ติดตั้ง Network-Save
เพื่อติดตั้งเวอร์ชันเฉพาะ:
NPM ติดตั้ง The-Things-Network@Version-Save
สมมติว่าคุณต้องการสร้างแอปพลิเคชันสามารถสร้างขึ้นได้สำหรับทั้ง ผู้ใช้ และ องค์กร ...
สำหรับข้อมูลเพิ่มเติมดูสิ่งนี้: สร้างแอปพลิเคชันสำหรับผู้ใช้
import { User } from 'the-things-network';
//just an example of config
const config = {
IDENTITY_SERVER: 'eu1.cloud.thethings.network',
NETWORK_SERVER: 'nam1.cloud.thethings.network',
APPLICATION_SERVER: 'nam1.cloud.thethings.network',
JOIN_SERVER: 'nam1.cloud.thethings.network',
API_KEY: 'xxxxxapi_keyxxxxxx',
};
//just an example of payload
const payload = {
application_id: 'test',
name: 'demo',
description: 'for testing',
};
const user = User('userId', config);
const result = async () => {
try {
const resp = await user.createApplication(payload);
console.log(resp);
} catch (err) {
console.log(err);
}
}
result();
สำหรับข้อมูลเพิ่มเติมดูสิ่งนี้: สร้างแอปพลิเคชันสำหรับองค์กร
import { Organization } from 'the-things-network';
//just an example of config
const config = {
IDENTITY_SERVER: 'eu1.cloud.thethings.network',
NETWORK_SERVER: 'nam1.cloud.thethings.network',
APPLICATION_SERVER: 'nam1.cloud.thethings.network',
JOIN_SERVER: 'nam1.cloud.thethings.network',
API_KEY: 'xxxxxapi_keyxxxxxx',
};
//just an example of payload
const payload = {
application_id: 'test',
name: 'demo',
description: 'for testing',
};
const org = new Organization('organizationId', config);
const result = async () => {
try {
const resp = await org.createApplication(payload);
console.log(resp);
} catch (err) {
console.log(err);
}
}
result();
import { Application } from 'the-things-network';
//just an example of config
const config = {
IDENTITY_SERVER: 'eu1.cloud.thethings.network',
NETWORK_SERVER: 'nam1.cloud.thethings.network',
APPLICATION_SERVER: 'nam1.cloud.thethings.network',
JOIN_SERVER: 'nam1.cloud.thethings.network',
API_KEY: 'xxxxxapi_keyxxxxxx',
};
const app = new Application('', config);
const result = async () => {
try {
const resp = await app.getApplicationList();
console.log(resp);
} catch (err) {
console.log(err);
}
}
result();
import { EndDevice } from 'the-things-network';
//just an example of config
const config = {
IDENTITY_SERVER: 'eu1.cloud.thethings.network',
NETWORK_SERVER: 'nam1.cloud.thethings.network',
APPLICATION_SERVER: 'nam1.cloud.thethings.network',
JOIN_SERVER: 'nam1.cloud.thethings.network',
API_KEY: 'xxxxxapi_keyxxxxxx',
};
//just an example of payload
const payload = {
end_device: {
ids: {
join_eui: 'DDFFDDFDFFDFDFDF',
dev_eui: '70B3D57ED005B59E',
device_id: 'eui-70b3d57ed005b59e',
application_ids: {
application_id: 'appId',
},
},
version_ids: {
brand_id: 'moko',
model_id: 'lw003',
hardware_version: '2.1',
firmware_version: '2.0',
band_id: 'AS_923',
},
network_server_address: 'nam1.cloud.thethings.network',
application_server_address: 'nam1.cloud.thethings.network',
join_server_address: 'nam1.cloud.thethings.network',
},
};
const device = new EndDevice('appId', config);
const result = async () => {
try {
const resp = await device.createEndDeviceIS(payload);
console.log(resp);
} catch (err) {
console.log(err);
}
}
result();
import { User } from 'the-things-network';
//just an example of config
const config = {
IDENTITY_SERVER: 'eu1.cloud.thethings.network',
NETWORK_SERVER: 'nam1.cloud.thethings.network',
APPLICATION_SERVER: 'nam1.cloud.thethings.network',
JOIN_SERVER: 'nam1.cloud.thethings.network',
API_KEY: 'xxxxxapi_keyxxxxxx',
};
//just an example of payload
const payload = {
gateway: {
ids: { gateway_id: 'eui-ee34634e6ada3425', eui: 'EE34634E6ADA3425' },
name: 'gateway',
description: 'testing',
gateway_server_address: 'nam1.cloud.thethings.network',
frequency_plan_id: 'US_902_928_FSB_3',
status_public: true,
location_public: true,
enforce_duty_cycle: true,
schedule_anytime_delay: '0.530s',
require_authenticated_connection: true,
},
};
const gateway = new User('userId', config);
const result = async () => {
try {
const resp = await gateway.createGateway(payload);
console.log(resp);
} catch (err) {
console.log(err);
}
}
result();
import { EndDevice } from 'the-things-network';
//just an example of config
const config = {
IDENTITY_SERVER: 'eu1.cloud.thethings.network',
NETWORK_SERVER: 'nam1.cloud.thethings.network',
APPLICATION_SERVER: 'nam1.cloud.thethings.network',
JOIN_SERVER: 'nam1.cloud.thethings.network',
API_KEY: 'xxxxxapi_keyxxxxxx',
TENANT_ID: 'xxxxxxxxxx',
};
//just an example of payload
const payload = {
device_id: 'deviceId',
down_type: '#',
host: 'nam1.cloud.thethings.industries',
port: 1883,
username: 'user@tenant',
callback_uplink_event: (data) => {
console.log('upEvent', data.toString('utf8'));
},
callback_subscribe_error: (data) => {
console.log('upEvent', data.toString('utf8'));
},
callback_subscribe_disconnect: (data) => {
console.log('upEvent', data.toString('utf8'));
}
};
const device = new EndDevice('appId', config);
const result = async () => {
try {
const resp = await device.subscribeUpLinkEvent(payload);
console.log(resp);
} catch (err) {
console.log(err);
}
}
result();
import { EndDevice } from 'the-things-network';
//just an example of config
const config = {
IDENTITY_SERVER: 'eu1.cloud.thethings.network',
NETWORK_SERVER: 'nam1.cloud.thethings.network',
APPLICATION_SERVER: 'nam1.cloud.thethings.network',
JOIN_SERVER: 'nam1.cloud.thethings.network',
API_KEY: 'xxxxxapi_keyxxxxxx',
TENANT_ID: 'xxxxxxxxxx',
};
//just an example of payload
const payload = {
device_id: 'deviceId',
down_type: '#',
host: 'nam1.cloud.thethings.industries',
port: 1883,
username: 'user@example',
callback_uplink_event: (data) => {
console.log('upEvent', data.toString('utf8'));
},
callback_subscribe_error: (data) => {
console.log('upEvent', data.toString('utf8'));
},
callback_subscribe_disconnect: (data) => {
console.log('upEvent', data.toString('utf8'));
}
};
const device = new EndDevice('appId', config);
const result = async () => {
try {
const upevent = await device.subscribeUpLinkEvent(payload);
console.log(upevent);
const resp = await device.unsubscribeEvent(upevent.client, upevent.topic);
console.log(resp);
} catch (err) {
console.log(err);
}
}
result();
เมื่อคุณสร้างอินสแตนซ์ของคลาสเฉพาะและตั้งค่าพารามิเตอร์ที่ต้องการแล้วคุณสามารถสำรวจวิธีการทั้งหมดที่เป็นของคลาสนั้นมันเป็นเรื่องง่าย ...
import { Application } from 'the-things-network';
//just an example of config
const config = {
IDENTITY_SERVER: 'eu1.cloud.thethings.network',
NETWORK_SERVER: 'nam1.cloud.thethings.network',
APPLICATION_SERVER: 'nam1.cloud.thethings.network',
JOIN_SERVER: 'nam1.cloud.thethings.network',
API_KEY: 'xxxxxapi_keyxxxxxx',
};
//just an example of payload
const payload = {
name: 'test',
description: 'For testing',
attributes: { 'key1': 'value1', 'key2': 'value2' },
};
const app = new Application('appId', config);
const result = async () => {
try {
const resp1 = await app.getApplicationList();
console.log(resp1);
const resp2 = await app.updateApplication(payload);
console.log(resp2);
const resp3 = await app.deleteApplication();
console.log(resp3);
const resp4 = await app.restoreApplication();
console.log(resp4);
} catch (err) {
console.log(err);
}
}
result();
เรายินดีต้อนรับการมีส่วนร่วมใน เครือข่าย-สิ่งต่าง ๆ ! หากคุณสนใจที่จะมีส่วนร่วมในแพ็คเกจนี้มีหลายวิธีในการเชื่อมต่อกับเครือข่าย-Things:
ปัญหารายงาน: หากคุณพบข้อบกพร่องข้อผิดพลาดหรือการปรับปรุงใด ๆ อย่าลังเลที่จะเปิดปัญหาเกี่ยวกับ GitHub
ส่งคำขอดึง: หากคุณสามารถแก้ไขปัญหาด้วยตัวเองหรือต้องการเพิ่มคุณสมบัติใหม่เรายินดีที่จะตรวจสอบคำขอดึงของคุณ
ปรับปรุงเอกสาร: ไม่ว่าคุณจะพบการพิมพ์ผิดเอกสารที่ไม่ชัดเจนหรือคุณมีความคิดในการปรับปรุงเอกสารของเราเราชอบที่จะได้ยินจากคุณ!
แบ่งปันข้อเสนอแนะ: ข้อเสนอแนะใด ๆ เกี่ยวกับประสบการณ์ของคุณกับแพ็คเกจของเราจะได้รับการชื่นชมอย่างมาก อินพุตของคุณช่วยให้เราทำให้แพ็คเกจนี้ดีขึ้นสำหรับทุกคน
โปรดทราบว่าโครงการนี้ได้รับการปล่อยตัวพร้อมกับจรรยาบรรณของผู้สนับสนุน โดยการเข้าร่วมในโครงการนี้คุณตกลงที่จะปฏิบัติตามข้อกำหนดของมัน
เราหวังว่าจะได้ร่วมมือกับคุณ!
fuota.io
SDK นี้ได้รับการดูแลโดย team @fuota.io
Fuota.io เป็นแพลตฟอร์ม All-in-One ของคุณสำหรับการอัปเดตเฟิร์มแวร์อย่างง่ายดายและการจัดการอุปกรณ์ที่ครอบคลุมสำหรับอุปกรณ์ Lorawan ด้วยเครือข่ายสิ่งต่าง ๆ และเซิร์ฟเวอร์เครือข่าย Lorawan ยอดนิยมอื่น ๆ อีกมากมาย
ในภูมิทัศน์ที่พัฒนาอย่างรวดเร็วของอุปกรณ์ที่เชื่อมต่อการรักษาอุปกรณ์ของคุณให้ทันสมัยด้วยเฟิร์มแวร์ล่าสุดเป็นปัจจัยสำคัญสำหรับประสิทธิภาพที่ดีที่สุดความปลอดภัยที่เพิ่มขึ้นและฟังก์ชั่นที่หลากหลาย ดังนั้นหากคุณกำลังมองหาโซลูชันที่พร้อมสำหรับโซลูชันการปรับใช้การอัปเดตเฟิร์มแวร์ เข้าร่วมกับเราที่ fuota.io และปลดล็อกศักยภาพเต็มรูปแบบของอุปกรณ์ Lorawan ที่เชื่อมต่อของคุณทำให้พวกเขาได้รับการปรับปรุงปลอดภัยและบูรณาการอย่างราบรื่น
เยี่ยมชมเรา : fuota.io
มิกซ์