WiFi Settings Management
Table of Contents
Overview
WiFi settings are used to configure network connections for RCAMS light devices. Each school can have multiple WiFi networks configured, which can then be assigned to different light devices. This section details the API endpoints for managing WiFi settings, including listing, creating, updating, and deleting WiFi configurations.
Note: All WiFi settings management endpoints require basic authentication. The user must have appropriate permissions for the requested operations.
WiFi Settings Management API Endpoints
| Operation | Endpoint | Action Parameter |
|---|---|---|
| List WiFi Settings | /wifi.php |
list |
| Get WiFi Setting | /wifi.php |
get |
| Create WiFi Setting | /wifi.php |
insert |
| Update WiFi Setting | /wifi.php |
update |
| Delete WiFi Setting | /wifi.php |
remove |
List WiFi Settings
Retrieves all WiFi settings within a school.
POST/wifi.php
Returns a list of all WiFi settings configured for the specified school.
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
action |
String | Yes | Must be set to list |
school_id |
String | Yes | ID of the school to list WiFi settings from |
Response
Returns a list of WiFi settings with their IDs, names, passwords, descriptions, and status.
{
"status": "OK",
"message": "Wifi found",
"total": 3,
"wifi_list": [
{
"ssid_id": 1,
"ssid_name": "NETGEAR51",
"ssid_pass": "boldhippo192",
"ssid_desc": "Update NETGEAR51",
"status": "active"
},
{
"ssid_id": 2,
"ssid_name": "GPISD-Guest",
"ssid_pass": "light123.",
"ssid_desc": null,
"status": "active"
},
{
"ssid_id": 4,
"ssid_name": "New_Wifi Updated",
"ssid_pass": "NewPasswordUpdated1.",
"ssid_desc": "Update Desc",
"status": "inactive"
}
]
}
// Set up the request
const jsonData = JSON.stringify({
action: 'list',
school_id: '1'
});
// Make the API call
fetch('https://rcamsapi.spheronomics.com/api/v2/wifi.php', {
method: 'POST',
headers: {
'Authorization': 'Basic ' + btoa('api_username:api_password')
},
body: jsonData
})
.then(response => response.json())
.then(data => {
if (data.status === 'OK') {
console.log(`Found ${data.total} WiFi settings:`, data.wifi_list);
} else {
console.error('Error:', data.message);
}
})
.catch(error => console.error('Error:', error));
Get WiFi Setting
Retrieves details for a specific WiFi setting.
POST/wifi.php
Returns detailed information about a specific WiFi setting.
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
action |
String | Yes | Must be set to get |
ssid_id |
String | Yes | ID of the WiFi setting to retrieve |
Response
Returns the details of the specified WiFi setting.
{
"status": "OK",
"message": "Wifi found",
"school_id": "1",
"ssid_id": "2",
"ssid_name": "GPISD-Guest",
"ssid_pass": "light123.",
"ssid_desc": null,
"status": "active"
}
// Set up the request
const jsonData = JSON.stringify({
action: 'get',
ssid_id: '2'
});
// Make the API call
fetch('https://rcamsapi.spheronomics.com/api/v2/wifi.php', {
method: 'POST',
headers: {
'Authorization': 'Basic ' + btoa('api_username:api_password')
},
body: jsonData
})
.then(response => response.json())
.then(data => {
if (data.status === 'OK') {
console.log('WiFi Setting details:', data);
} else {
console.error('Error:', data.message);
}
})
.catch(error => console.error('Error:', error));
Create WiFi Setting
Creates a new WiFi setting for a school.
POST/wifi.php
Creates a new WiFi configuration with the specified details.
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
action |
String | Yes | Must be set to insert |
school_id |
String | Yes | ID of the school to add the WiFi setting to |
ssid_name |
String | Yes | Name of the WiFi network (SSID) |
ssid_pass |
String | Yes | WiFi password |
ssid_desc |
String | No | Description of the WiFi network |
Response
Returns confirmation that the WiFi setting was created and provides the new WiFi setting ID.
{
"status": "OK",
"message": "Wifi added successfully",
"wifi_id": "5"
}
// Set up the request
const jsonData = JSON.stringify({
action: 'insert',
school_id: '1',
ssid_name: 'School-Staff',
ssid_pass: 'securepass123',
ssid_desc: 'WiFi network for staff members'
});
// Make the API call
fetch('https://rcamsapi.spheronomics.com/api/v2/wifi.php', {
method: 'POST',
headers: {
'Authorization': 'Basic ' + btoa('api_username:api_password')
},
body: jsonData
})
.then(response => response.json())
.then(data => {
if (data.status === 'OK') {
console.log('WiFi setting created with ID:', data.wifi_id);
} else {
console.error('Error:', data.message);
}
})
.catch(error => console.error('Error:', error));
Update WiFi Setting
Updates an existing WiFi setting.
POST/wifi.php
Updates the details of an existing WiFi setting.
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
action |
String | Yes | Must be set to update |
ssid_id |
String | Yes | ID of the WiFi setting to update |
ssid_name |
String | Yes | Updated name for the WiFi network (SSID) |
ssid_pass |
String | Yes | Updated WiFi password |
ssid_desc |
String | No | Updated description of the WiFi network |
Response
Returns confirmation that the WiFi setting was updated.
{
"status": "OK",
"message": "Wifi updated successfully"
}
// Set up the request
const jsonData = JSON.stringify({
action: 'update',
ssid_id: '5',
ssid_name: 'School-Staff-Secure',
ssid_pass: 'updatedpass456',
ssid_desc: 'Updated WiFi network for staff members'
});
// Make the API call
fetch('https://rcamsapi.spheronomics.com/api/v2/wifi.php', {
method: 'POST',
headers: {
'Authorization': 'Basic ' + btoa('api_username:api_password')
},
body: jsonData
})
.then(response => response.json())
.then(data => {
if (data.status === 'OK') {
console.log('WiFi setting updated successfully');
} else {
console.error('Error:', data.message);
}
})
.catch(error => console.error('Error:', error));
Delete WiFi Setting
Removes a WiFi setting from the system.
Warning: Deleting a WiFi setting will affect any lights currently configured to use this network. Ensure lights are reassigned to a different WiFi network before deletion.
POST/wifi.php
Deletes a WiFi setting from the system.
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
action |
String | Yes | Must be set to remove |
ssid_id |
String | Yes | ID of the WiFi setting to delete |
Response
Returns confirmation that the WiFi setting was deleted.
{
"status": "OK",
"message": "Wifi removed successfully"
}
// Set up the request
const jsonData = JSON.stringify({
action: 'remove',
ssid_id: '5'
});
// Make the API call
fetch('https://rcamsapi.spheronomics.com/api/v2/wifi.php', {
method: 'POST',
headers: {
'Authorization': 'Basic ' + btoa('api_username:api_password')
},
body: jsonData
})
.then(response => response.json())
.then(data => {
if (data.status === 'OK') {
console.log('WiFi setting removed successfully');
} else {
console.error('Error:', data.message);
}
})
.catch(error => console.error('Error:', error));
Code Examples
WiFi Settings Management Example
The following example demonstrates a complete flow for WiFi settings management, including listing, creating, updating, and deleting WiFi configurations.
// Helper function for API requests
async function makeApiRequest(endpoint, params) {
// API credentials - replace with actual values
const apiUsername = 'your_api_username';
const apiPassword = 'your_api_password';
// Create form data from params
const json = {};
for (const [key, value] of Object.entries(params)) {
json[key] = value;
}
const jsonString = JSON.stringify(json);
try {
const response = await fetch(`https://rcamsapi.spheronomics.com/api/v2/${endpoint}`, {
method: 'POST',
headers: {
'Authorization': 'Basic ' + btoa(`${apiUsername}:${apiPassword}`)
},
body: jsonString
});
return await response.json();
} catch (error) {
console.error('API request failed:', error);
throw error;
}
}
// Example usage - WiFi Settings Management
async function wifiManagementExample(schoolId) {
try {
// 1. List all WiFi settings in the school
console.log(`Listing all WiFi settings in school ${schoolId}...`);
const listResponse = await makeApiRequest('wifi.php', {
action: 'list',
school_id: schoolId
});
console.log(`Found ${listResponse.total} WiFi settings:`, listResponse.wifi_list);
// 2. Create a new WiFi setting
console.log('Creating a new WiFi setting...');
const createResponse = await makeApiRequest('wifi.php', {
action: 'insert',
school_id: schoolId,
ssid_name: 'School-Students',
ssid_pass: 'student2025',
ssid_desc: 'WiFi network for student devices'
});
if (createResponse.status === 'OK') {
const newWifiId = createResponse.wifi_id;
console.log(`Created WiFi setting with ID: ${newWifiId}`);
// 3. Get the WiFi setting details
console.log('Getting WiFi setting details...');
const getResponse = await makeApiRequest('wifi.php', {
action: 'get',
ssid_id: newWifiId
});
console.log('WiFi setting details:', getResponse);
// 4. Update the WiFi setting
console.log('Updating WiFi setting...');
const updateResponse = await makeApiRequest('wifi.php', {
action: 'update',
ssid_id: newWifiId,
ssid_name: 'School-Students-Limited',
ssid_pass: 'limitedaccess2025',
ssid_desc: 'Limited access WiFi network for student devices'
});
console.log('Update result:', updateResponse.message);
// 5. Delete the WiFi setting (commented out for safety)
// Uncomment to actually delete the WiFi setting
/*
console.log('Deleting WiFi setting...');
const deleteResponse = await makeApiRequest('wifi.php', {
action: 'remove',
ssid_id: newWifiId
});
console.log('Delete result:', deleteResponse.message);
*/
}
} catch (error) {
console.error('An error occurred:', error);
}
}
// Run the example (you would need a valid school ID)
/*
async function runExample() {
const loginResponse = await makeApiRequest('login.php', {
user: 'user@example.com',
pass: 'password123'
});
if (loginResponse.status === 'OK') {
await wifiManagementExample('1'); // Replace '1' with actual school ID
} else {
console.error('Login failed:', loginResponse.message);
}
}
runExample();
*/